Use os.environ.get() in stead of os.getenv() (which is platform-dependent).
diff --git a/Lib/getopt.py b/Lib/getopt.py
index 46aa702..1b835a5 100644
--- a/Lib/getopt.py
+++ b/Lib/getopt.py
@@ -117,7 +117,7 @@
     if shortopts.startswith('+'):
         shortopts = shortopts[1:]
         all_options_first = True
-    elif os.getenv("POSIXLY_CORRECT"):
+    elif os.environ.get("POSIXLY_CORRECT"):
         all_options_first = True
     else:
         all_options_first = False