@@ -146,42 +146,35 @@ def fcmp(x, y): # fuzzy comparison function
146146 TESTFN = 'testfile'
147147else :
148148 TESTFN = '@test'
149- # Unicode name only used if TEST_FN_ENCODING exists for the platform.
150- if have_unicode :
151- # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding()
152- # TESTFN_UNICODE is a filename that can be encoded using the
153- # file system encoding, but *not* with the default (ascii) encoding
154- if isinstance ('' , str ):
155- # python -U
156- # XXX perhaps unicode() should accept Unicode strings?
157- TESTFN_UNICODE = "@test-\xe0 \xf2 "
158- else :
159- # 2 latin characters.
160- TESTFN_UNICODE = str ("@test-\xe0 \xf2 " , "latin-1" )
161- TESTFN_ENCODING = sys .getfilesystemencoding ()
162- # TESTFN_UNICODE_UNENCODEABLE is a filename that should *not* be
163- # able to be encoded by *either* the default or filesystem encoding.
164- # This test really only makes sense on Windows NT platforms
165- # which have special Unicode support in posixmodule.
166- if (not hasattr (sys , "getwindowsversion" ) or
167- sys .getwindowsversion ()[3 ] < 2 ): # 0=win32s or 1=9x/ME
168- TESTFN_UNICODE_UNENCODEABLE = None
149+
150+ # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding()
151+ # TESTFN_UNICODE is a filename that can be encoded using the
152+ # file system encoding, but *not* with the default (ascii) encoding
153+ TESTFN_UNICODE = "@test-\xe0 \xf2 "
154+ TESTFN_ENCODING = sys .getfilesystemencoding ()
155+ # TESTFN_UNICODE_UNENCODEABLE is a filename that should *not* be
156+ # able to be encoded by *either* the default or filesystem encoding.
157+ # This test really only makes sense on Windows NT platforms
158+ # which have special Unicode support in posixmodule.
159+ if (not hasattr (sys , "getwindowsversion" ) or
160+ sys .getwindowsversion ()[3 ] < 2 ): # 0=win32s or 1=9x/ME
161+ TESTFN_UNICODE_UNENCODEABLE = None
162+ else :
163+ # Japanese characters (I think - from bug 846133)
164+ TESTFN_UNICODE_UNENCODEABLE = "@test-\u5171 \u6709 \u3055 \u308c \u308b "
165+ try :
166+ # XXX - Note - should be using TESTFN_ENCODING here - but for
167+ # Windows, "mbcs" currently always operates as if in
168+ # errors=ignore' mode - hence we get '?' characters rather than
169+ # the exception. 'Latin1' operates as we expect - ie, fails.
170+ # See [ 850997 ] mbcs encoding ignores errors
171+ TESTFN_UNICODE_UNENCODEABLE .encode ("Latin1" )
172+ except UnicodeEncodeError :
173+ pass
169174 else :
170- # Japanese characters (I think - from bug 846133)
171- TESTFN_UNICODE_UNENCODEABLE = eval ('u"@test-\u5171 \u6709 \u3055 \u308c \u308b "' )
172- try :
173- # XXX - Note - should be using TESTFN_ENCODING here - but for
174- # Windows, "mbcs" currently always operates as if in
175- # errors=ignore' mode - hence we get '?' characters rather than
176- # the exception. 'Latin1' operates as we expect - ie, fails.
177- # See [ 850997 ] mbcs encoding ignores errors
178- TESTFN_UNICODE_UNENCODEABLE .encode ("Latin1" )
179- except UnicodeEncodeError :
180- pass
181- else :
182- print ('WARNING: The filename %r CAN be encoded by the filesystem. ' \
183- 'Unicode filename tests may not be effective' \
184- % TESTFN_UNICODE_UNENCODEABLE )
175+ print ('WARNING: The filename %r CAN be encoded by the filesystem. ' \
176+ 'Unicode filename tests may not be effective' \
177+ % TESTFN_UNICODE_UNENCODEABLE )
185178
186179# Make sure we can write to TESTFN, try in /tmp if we can't
187180fp = None
0 commit comments