--- Python-2.7.15/configure.orig	2018-04-30 00:47:33.000000000 +0200
+++ Python-2.7.15/configure	2018-12-26 12:46:08.163275913 +0100
@@ -12177,6 +12177,32 @@ _ACEOF
 
 fi
 
+ac_fn_c_check_member "$LINENO" "struct passwd" "pw_gecos" "ac_cv_member_struct_passwd_pw_gecos" "
+  #include <sys/types.h>
+  #include <pwd.h>
+
+"
+if test "x$ac_cv_member_struct_passwd_pw_gecos" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_PASSWD_PW_GECOS 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct passwd" "pw_passwd" "ac_cv_member_struct_passwd_pw_passwd" "
+  #include <sys/types.h>
+  #include <pwd.h>
+
+"
+if test "x$ac_cv_member_struct_passwd_pw_passwd" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_PASSWD_PW_PASSWD 1
+_ACEOF
+
+
+fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for time.h that defines altzone" >&5
 $as_echo_n "checking for time.h that defines altzone... " >&6; }
--- Python-2.7.15/configure.ac.orig	2018-04-30 00:47:33.000000000 +0200
+++ Python-2.7.15/configure.ac	2018-12-26 12:50:20.679273505 +0100
@@ -3562,6 +3562,10 @@ AC_CHECK_MEMBERS([struct stat.st_flags])
 AC_CHECK_MEMBERS([struct stat.st_gen])
 AC_CHECK_MEMBERS([struct stat.st_birthtime])
 AC_CHECK_MEMBERS([struct stat.st_blocks])
+AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[
+  #include <sys/types.h>
+  #include <pwd.h>
+]])

 AC_MSG_CHECKING(for time.h that defines altzone)
 AC_CACHE_VAL(ac_cv_header_time_altzone,[
--- Python-2.7.15/pyconfig.h.in.orig	2018-04-30 00:47:33.000000000 +0200
+++ Python-2.7.15/pyconfig.h.in	2018-12-26 12:52:13.247272432 +0100
@@ -737,6 +737,12 @@
 /* Define to 1 if you have the <stropts.h> header file. */
 #undef HAVE_STROPTS_H

+/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */
+#undef HAVE_STRUCT_PASSWD_PW_GECOS
+
+/* Define to 1 if `pw_passwd' is a member of `struct passwd'. */
+#undef HAVE_STRUCT_PASSWD_PW_PASSWD
+
 /* Define to 1 if `st_birthtime' is a member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_BIRTHTIME

--- Python-2.7.15/Modules/pwdmodule.c.orig	2018-04-30 00:47:33.000000000 +0200
+++ Python-2.7.15/Modules/pwdmodule.c	2018-12-26 12:38:47.611280115 +0100
@@ -68,17 +68,17 @@ mkpwent(struct passwd *p)
 #define SETS(i,val) sets(v, i, val)

     SETS(setIndex++, p->pw_name);
-#ifdef __VMS
-    SETS(setIndex++, "");
-#else
+#if defined(HAVE_STRUCT_PASSWD_PW_PASSWD)
     SETS(setIndex++, p->pw_passwd);
+#else
+    SETS(setIndex++, "");
 #endif
     PyStructSequence_SET_ITEM(v, setIndex++, _PyInt_FromUid(p->pw_uid));
     PyStructSequence_SET_ITEM(v, setIndex++, _PyInt_FromGid(p->pw_gid));
-#ifdef __VMS
-    SETS(setIndex++, "");
-#else
+#if defined(HAVE_STRUCT_PASSWD_PW_GECOS)
     SETS(setIndex++, p->pw_gecos);
+#else
+    SETS(setIndex++, "");
 #endif
     SETS(setIndex++, p->pw_dir);
     SETS(setIndex++, p->pw_shell);