@@ -720,21 +720,21 @@ def requires_lzma(reason='requires lzma'):
720720# Filename used for testing
721721if os .name == 'java' :
722722 # Jython disallows @ in module names
723- TESTFN = '$test'
723+ TESTFN_ASCII = '$test'
724724else :
725- TESTFN = '@test'
725+ TESTFN_ASCII = '@test'
726726
727727# Disambiguate TESTFN for parallel testing, while letting it remain a valid
728728# module name.
729- TESTFN = "{}_{}_tmp" .format (TESTFN , os .getpid ())
729+ TESTFN_ASCII = "{}_{}_tmp" .format (TESTFN_ASCII , os .getpid ())
730730
731731# Define the URL of a dedicated HTTP server for the network tests.
732732# The URL must use clear-text HTTP: no redirection to encrypted HTTPS.
733733TEST_HTTP_URL = "http://www.pythontest.net"
734734
735735# FS_NONASCII: non-ASCII character encodable by os.fsencode(),
736- # or None if there is no such character.
737- FS_NONASCII = None
736+ # or an empty string if there is no such character.
737+ FS_NONASCII = ''
738738for character in (
739739 # First try printable and common characters to have a readable filename.
740740 # For each character, the encoding list are just example of encodings able
@@ -781,7 +781,7 @@ def requires_lzma(reason='requires lzma'):
781781 break
782782
783783# TESTFN_UNICODE is a non-ascii filename
784- TESTFN_UNICODE = TESTFN + "-\xe0 \xf2 \u0258 \u0141 \u011f "
784+ TESTFN_UNICODE = TESTFN_ASCII + "-\xe0 \xf2 \u0258 \u0141 \u011f "
785785if sys .platform == 'darwin' :
786786 # In Mac OS X's VFS API file names are, by definition, canonically
787787 # decomposed Unicode, encoded using UTF-8. See QA1173:
@@ -799,7 +799,7 @@ def requires_lzma(reason='requires lzma'):
799799 if sys .getwindowsversion ().platform >= 2 :
800800 # Different kinds of characters from various languages to minimize the
801801 # probability that the whole name is encodable to MBCS (issue #9819)
802- TESTFN_UNENCODABLE = TESTFN + "-\u5171 \u0141 \u2661 \u0363 \uDC80 "
802+ TESTFN_UNENCODABLE = TESTFN_ASCII + "-\u5171 \u0141 \u2661 \u0363 \uDC80 "
803803 try :
804804 TESTFN_UNENCODABLE .encode (TESTFN_ENCODING )
805805 except UnicodeEncodeError :
@@ -816,7 +816,7 @@ def requires_lzma(reason='requires lzma'):
816816 b'\xff ' .decode (TESTFN_ENCODING )
817817 except UnicodeDecodeError :
818818 # 0xff will be encoded using the surrogate character u+DCFF
819- TESTFN_UNENCODABLE = TESTFN \
819+ TESTFN_UNENCODABLE = TESTFN_ASCII \
820820 + b'-\xff ' .decode (TESTFN_ENCODING , 'surrogateescape' )
821821 else :
822822 # File system encoding (eg. ISO-8859-* encodings) can encode
@@ -850,13 +850,14 @@ def requires_lzma(reason='requires lzma'):
850850 try :
851851 name .decode (TESTFN_ENCODING )
852852 except UnicodeDecodeError :
853- TESTFN_UNDECODABLE = os .fsencode (TESTFN ) + name
853+ TESTFN_UNDECODABLE = os .fsencode (TESTFN_ASCII ) + name
854854 break
855855
856856if FS_NONASCII :
857- TESTFN_NONASCII = TESTFN + '-' + FS_NONASCII
857+ TESTFN_NONASCII = TESTFN_ASCII + FS_NONASCII
858858else :
859859 TESTFN_NONASCII = None
860+ TESTFN = TESTFN_NONASCII or TESTFN_ASCII
860861
861862# Save the initial cwd
862863SAVEDCWD = os .getcwd ()
0 commit comments