@@ -785,7 +785,6 @@ def requires_lzma(reason='requires lzma'):
785785 # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
786786 import unicodedata
787787 TESTFN_UNICODE = unicodedata .normalize ('NFD' , TESTFN_UNICODE )
788- TESTFN_ENCODING = sys .getfilesystemencoding ()
789788
790789# TESTFN_UNENCODABLE is a filename (str type) that should *not* be able to be
791790# encoded by the filesystem encoding (in strict mode). It can be None if we
@@ -798,23 +797,23 @@ def requires_lzma(reason='requires lzma'):
798797 # probability that the whole name is encodable to MBCS (issue #9819)
799798 TESTFN_UNENCODABLE = TESTFN + "-\u5171 \u0141 \u2661 \u0363 \uDC80 "
800799 try :
801- TESTFN_UNENCODABLE .encode (TESTFN_ENCODING )
800+ TESTFN_UNENCODABLE .encode (sys . getfilesystemencoding () )
802801 except UnicodeEncodeError :
803802 pass
804803 else :
805804 print ('WARNING: The filename %r CAN be encoded by the filesystem encoding (%s). '
806805 'Unicode filename tests may not be effective'
807- % (TESTFN_UNENCODABLE , TESTFN_ENCODING ))
806+ % (TESTFN_UNENCODABLE , sys . getfilesystemencoding () ))
808807 TESTFN_UNENCODABLE = None
809808# Mac OS X denies unencodable filenames (invalid utf-8)
810809elif sys .platform != 'darwin' :
811810 try :
812811 # ascii and utf-8 cannot encode the byte 0xff
813- b'\xff ' .decode (TESTFN_ENCODING )
812+ b'\xff ' .decode (sys . getfilesystemencoding () )
814813 except UnicodeDecodeError :
815814 # 0xff will be encoded using the surrogate character u+DCFF
816815 TESTFN_UNENCODABLE = TESTFN \
817- + b'-\xff ' .decode (TESTFN_ENCODING , 'surrogateescape' )
816+ + b'-\xff ' .decode (sys . getfilesystemencoding () , 'surrogateescape' )
818817 else :
819818 # File system encoding (eg. ISO-8859-* encodings) can encode
820819 # the byte 0xff. Skip some unicode filename tests.
@@ -845,7 +844,7 @@ def requires_lzma(reason='requires lzma'):
845844 b'\x81 \x98 ' ,
846845):
847846 try :
848- name .decode (TESTFN_ENCODING )
847+ name .decode (sys . getfilesystemencoding () )
849848 except UnicodeDecodeError :
850849 TESTFN_UNDECODABLE = os .fsencode (TESTFN ) + name
851850 break
0 commit comments