"Martin" == Martin v Löwis writes:
Martin> Skip Montanaro writes:
>> Yeah, me. I can't do anything this evening, but can look at it tomorrow.
>> What's the bug id?
Martin> No bug id: test_pep277 fails.
One problem seems obvious to me. test_pep277.UnicodeFileTests defines this
method:
def test_listdir(self):
f1 = os.listdir(test_support.TESTFN)
f1.sort()
f2 = os.listdir(unicode(test_support.TESTFN,"mbcs"))
f2.sort()
print f1
print f2
The unicode() call winds up trying to call codecs.mbcs_encode which is
imported from the _codecs module. mbcs_encode is only defined on Windows,
and only if there is a usable wchar_t. It's clear this is going to fail on
Mac OS X.
This seems better:
def test_listdir(self):
import sys
f1 = os.listdir(test_support.TESTFN)
f1.sort()
f2 = os.listdir(unicode(test_support.TESTFN,
sys.getfilesystemencoding()))
f2.sort()
print f1
print f2
If someone with ready access to a Windows machine can try that change
tonight I'll check it in, otherwise it will have to wait until I'm at work
tomorrow morning.
The second error is due to details.filename at line 53 being a plain string
containing non-ASCII characters. When it is
'not_@test/Gr\xc3\xbc\xc3\x9f-Gott' and is compared with filename which is
u'not_@test/Gr\xc3\xbc\xc3\x9f-Gott' a UnicodeDecodeError is raised trying
to coerce details.filename to unicode. Simply converting it using
unicode(details.filename, sys.getfilesystemencoding()) before comparison
doesn't seem correct, because there's no guarantee that details.filename is
in the file system encoding at that point. It certainly fails for me:
>>> s = 'not_@test/Gr\xfc\xdf-Gott'
>>> import sys
>>> unicode(s, sys.getfilesystemencoding())
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 12-17: unsupported Unicode code range
I suspect details.filename needs to be set to a unicode object, but I don't
know where or how.
Skip