9090 "anticipate_failure" , "load_package_tests" , "detect_api_mismatch" ,
9191 "check__all__" , "skip_unless_bind_unix_socket" ,
9292 # sys
93- "JYTHON " , "ANDROID " , "check_impl_detail" , "unix_shell" ,
94- "setswitchinterval" , "MS_WINDOWS" , "MACOS" ,
93+ "is_jython " , "is_android " , "check_impl_detail" , "unix_shell" ,
94+ "setswitchinterval" ,
9595 # network
9696 "HOST" , "IPV6_ENABLED" , "find_unused_port" , "bind_port" , "open_urlresource" ,
9797 "bind_unix_socket" ,
108108 "run_with_tz" , "PGO" , "missing_compiler_executable" , "fd_count" ,
109109 ]
110110
111-
112- # True if Python is running on Microsoft Windows.
113- MS_WINDOWS = (sys .platform == 'win32' )
114-
115- # True if Python is running on Apple macOS.
116- MACOS = (sys .platform == 'darwin' )
117-
118- # True if Python runs on Jython
119- # (Python implemented in Java running in a Java VM)
120- JYTHON = sys .platform .startswith ('java' )
121-
122- # True if Python runs on Android
123- ANDROID = hasattr (sys , 'getandroidapilevel' )
124-
125-
126111class Error (Exception ):
127112 """Base class for regression test exceptions."""
128113
@@ -499,7 +484,7 @@ class USEROBJECTFLAGS(ctypes.Structure):
499484 raise ctypes .WinError ()
500485 if not bool (uof .dwFlags & WSF_VISIBLE ):
501486 reason = "gui not available (WSF_VISIBLE flag not set)"
502- elif MACOS :
487+ elif sys . platform == 'darwin' :
503488 # The Aqua Tk implementations on OS X can abort the process if
504489 # being called in an environment where a window server connection
505490 # cannot be made, for instance when invoked by a buildbot or ssh
@@ -615,7 +600,7 @@ def requires_mac_ver(*min_version):
615600 def decorator (func ):
616601 @functools .wraps (func )
617602 def wrapper (* args , ** kw ):
618- if MACOS :
603+ if sys . platform == 'darwin' :
619604 version_txt = platform .mac_ver ()[0 ]
620605 try :
621606 version = tuple (map (int , version_txt .split ('.' )))
@@ -803,12 +788,14 @@ def dec(*args, **kwargs):
803788
804789requires_lzma = unittest .skipUnless (lzma , 'requires lzma' )
805790
806- if MS_WINDOWS :
807- unix_shell = None
808- elif ANDROID :
809- unix_shell = '/system/bin/sh'
791+ is_jython = sys .platform .startswith ('java' )
792+
793+ is_android = hasattr (sys , 'getandroidapilevel' )
794+
795+ if sys .platform != 'win32' :
796+ unix_shell = '/system/bin/sh' if is_android else '/bin/sh'
810797else :
811- unix_shell = '/bin/sh'
798+ unix_shell = None
812799
813800# Filename used for testing
814801if os .name == 'java' :
@@ -867,7 +854,7 @@ def dec(*args, **kwargs):
867854
868855# TESTFN_UNICODE is a non-ascii filename
869856TESTFN_UNICODE = TESTFN + "-\xe0 \xf2 \u0258 \u0141 \u011f "
870- if MACOS :
857+ if sys . platform == 'darwin' :
871858 # In Mac OS X's VFS API file names are, by definition, canonically
872859 # decomposed Unicode, encoded using UTF-8. See QA1173:
873860 # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
@@ -879,7 +866,7 @@ def dec(*args, **kwargs):
879866# encoded by the filesystem encoding (in strict mode). It can be None if we
880867# cannot generate such filename.
881868TESTFN_UNENCODABLE = None
882- if MS_WINDOWS :
869+ if os . name == 'nt' :
883870 # skip win32s (0) or Windows 9x/ME (1)
884871 if sys .getwindowsversion ().platform >= 2 :
885872 # Different kinds of characters from various languages to minimize the
@@ -894,8 +881,8 @@ def dec(*args, **kwargs):
894881 'Unicode filename tests may not be effective'
895882 % (TESTFN_UNENCODABLE , TESTFN_ENCODING ))
896883 TESTFN_UNENCODABLE = None
897- # macOS denies unencodable filenames (invalid utf-8)
898- elif not MACOS :
884+ # Mac OS X denies unencodable filenames (invalid utf-8)
885+ elif sys . platform != 'darwin' :
899886 try :
900887 # ascii and utf-8 cannot encode the byte 0xff
901888 b'\xff ' .decode (TESTFN_ENCODING )
@@ -1536,7 +1523,7 @@ def gc_collect():
15361523 objects to disappear.
15371524 """
15381525 gc .collect ()
1539- if JYTHON :
1526+ if is_jython :
15401527 time .sleep (0.1 )
15411528 gc .collect ()
15421529 gc .collect ()
@@ -1995,7 +1982,7 @@ def _check_docstrings():
19951982 """Just used to check if docstrings are enabled"""
19961983
19971984MISSING_C_DOCSTRINGS = (check_impl_detail () and
1998- not MS_WINDOWS and
1985+ sys . platform != 'win32' and
19991986 not sysconfig .get_config_var ('WITH_DOC_STRINGS' ))
20001987
20011988HAVE_DOCSTRINGS = (_check_docstrings .__doc__ is not None and
@@ -2605,7 +2592,7 @@ def __enter__(self):
26052592 except (ValueError , OSError ):
26062593 pass
26072594
2608- if MACOS :
2595+ if sys . platform == 'darwin' :
26092596 # Check if the 'Crash Reporter' on OSX was configured
26102597 # in 'Developer' mode and warn that it will get triggered
26112598 # when it is.
@@ -2749,7 +2736,7 @@ def setswitchinterval(interval):
27492736 # Setting a very low gil interval on the Android emulator causes python
27502737 # to hang (issue #26939).
27512738 minimum_interval = 1e-5
2752- if ANDROID and interval < minimum_interval :
2739+ if is_android and interval < minimum_interval :
27532740 global _is_android_emulator
27542741 if _is_android_emulator is None :
27552742 _is_android_emulator = (subprocess .check_output (
@@ -2795,7 +2782,7 @@ def fd_count():
27952782 pass
27962783
27972784 old_modes = None
2798- if MS_WINDOWS :
2785+ if sys . platform == 'win32' :
27992786 # bpo-25306, bpo-31009: Call CrtSetReportMode() to not kill the process
28002787 # on invalid file descriptor if Python is compiled in debug mode
28012788 try :
0 commit comments