[Python-Dev] [Python-checkins] cpython (merge 3.4 -> default): Issue #22165: Fixed test_undecodable_filename on non-UTF-8 locales. (original) (raw)
Senthil Kumaran senthil at uthcode.com
Sun Aug 17 11:37:44 CEST 2014
- Previous message: [Python-Dev] PEP 4000 to explicitly declare we won't be doing a Py3k style compatibility break again?
- Next message: [Python-Dev] "embedded NUL character" exceptions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This change is okay and not harmful. But I think, It might still not fix the encoding issue that we encountered on Mac.
[localhost cpython]$ hg log -l 1 changeset: 92128:7cdc941d5180 tag: tip parent: 92126:3153a400b739 parent: 92127:a894b629bbea user: Serhiy Storchaka <storchaka at gmail.com> date: Sun Aug 17 12:21:06 2014 +0300 description: Issue #22165: Fixed test_undecodable_filename on non-UTF-8 locales.
[localhost cpython]$ ./python.exe -m test.regrtest test_httpservers [1/1] test_httpservers test test_httpservers failed -- Traceback (most recent call last): File "/Users/skumaran/python/cpython/Lib/test/test_httpservers.py", line 283, in test_undecodable_filename .encode(enc, 'surrogateescape'), body) AssertionError: b'href="%40test_5809_tmp%ED%B3%A7w%ED%B3%B0.txt"' not found in b'\n\n\n\nDirectory listing for tmpj54lc8m1/\n\n\n
Directory listing for tmpj54lc8m1/
\n\n\n
\n\n\n'
1 test failed: test_httpservers
The underlying problem seems to be difference in which os.listdir() which uses C-API and os.fsdecode represent the decoded chars. Ref: http://bugs.python.org/issue22165#msg225428
On Sun, Aug 17, 2014 at 2:52 PM, serhiy.storchaka < python-checkins at python.org> wrote:
http://hg.python.org/cpython/rev/7cdc941d5180 changeset: 92128:7cdc941d5180 parent: 92126:3153a400b739 parent: 92127:a894b629bbea user: Serhiy Storchaka <storchaka at gmail.com> date: Sun Aug 17 12:21:06 2014 +0300 summary: Issue #22165: Fixed testundecodablefilename on non-UTF-8 locales.
files: Lib/test/testhttpservers.py | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Lib/test/testhttpservers.py b/Lib/test/testhttpservers.py --- a/Lib/test/testhttpservers.py +++ b/Lib/test/testhttpservers.py @@ -272,6 +272,7 @@ @unittest.skipUnless(support.TESTFNUNDECODABLE, 'need support.TESTFNUNDECODABLE') def testundecodablefilename(self): + enc = sys.getfilesystemencoding() filename = os.fsdecode(support.TESTFNUNDECODABLE) + '.txt' with open(os.path.join(self.tempdir, filename), 'wb') as f: f.write(support.TESTFNUNDECODABLE) @@ -279,9 +280,9 @@ body = self.checkstatusandreason(response, 200) quotedname = urllib.parse.quote(filename, errors='surrogatepass') self.assertIn(('href="%s"' % quotedname) - .encode('utf-8', 'surrogateescape'), body) + .encode(enc, 'surrogateescape'), body) self.assertIn(('>%s<' % html.escape(filename)) - .encode('utf-8', 'surrogateescape'), body) + .encode(enc, 'surrogateescape'), body) response = self.request(self.tempdirname + '/' + quotedname) self.checkstatusandreason(response, 200, data=support.TESTFNUNDECODABLE) -- Repository URL: http://hg.python.org/cpython
Python-checkins mailing list Python-checkins at python.org https://mail.python.org/mailman/listinfo/python-checkins -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140817/a45b830c/attachment.html>
- Previous message: [Python-Dev] PEP 4000 to explicitly declare we won't be doing a Py3k style compatibility break again?
- Next message: [Python-Dev] "embedded NUL character" exceptions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]