Message150253
Thanks to Lars for suggesting the fix, replacing 'w|gz' with 'w:gz'. I attempted this change in the latest revision of my fork (774933cf7775.diff). While this change does address the issue if a unicode string is passed which can be encoded using the default encoding. However, if a latin-1 string is passed or another multi-byte unicode character is passed, a UnicodeDecodeError still occurs (though now in gzip.py). Here's the test results and tracebacks:
PS C:\Users\jaraco\projects\public\cpython> python .\lib\distutils\tests\test_archive_util.py
test_check_archive_formats (__main__.ArchiveUtilTestCase) ... ok
test_compress_deprecated (__main__.ArchiveUtilTestCase) ... skipped 'The compress program is required'
test_make_archive (__main__.ArchiveUtilTestCase) ... ok
test_make_archive_cwd (__main__.ArchiveUtilTestCase) ... ok
test_make_archive_owner_group (__main__.ArchiveUtilTestCase) ... ok
test_make_tarball (__main__.ArchiveUtilTestCase) ... ok
test_make_tarball_unicode (__main__.ArchiveUtilTestCase) ... ok
test_make_tarball_unicode_extended (__main__.ArchiveUtilTestCase) ... ERROR
test_make_tarball_unicode_latin1 (__main__.ArchiveUtilTestCase) ... ERROR
test_make_zipfile (__main__.ArchiveUtilTestCase) ... ok
test_tarfile_root_owner (__main__.ArchiveUtilTestCase) ... skipped 'Requires grp and pwd support'
test_tarfile_vs_tar (__main__.ArchiveUtilTestCase) ... skipped 'Need the tar command to run'
======================================================================
ERROR: test_make_tarball_unicode_extended (__main__.ArchiveUtilTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".\lib\distutils\tests\test_archive_util.py", line 305, in test_make_tarball_unicode_extended
self._make_tarball(u'のアーカイブ') # japanese for archive
File ".\lib\distutils\tests\test_archive_util.py", line 64, in _make_tarball
make_tarball(splitdrive(base_name)[1], '.')
File "C:\Users\jaraco\projects\public\cpython\Lib\distutils\archive_util.py",
line 101, in make_tarball
tar = tarfile.open(archive_name, 'w:%s' % tar_compression[compress])
File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 1676, in open
return func(name, filemode, fileobj, **kwargs)
File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 1724, in gzopen
gzip.GzipFile(name, mode, compresslevel, fileobj),
File "C:\Users\jaraco\projects\public\cpython\Lib\gzip.py", line 127, in __init__
self._write_gzip_header()
File "C:\Users\jaraco\projects\public\cpython\Lib\gzip.py", line 172, in _write_gzip_header
self.fileobj.write(fname + '\000')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)
======================================================================
ERROR: test_make_tarball_unicode_latin1 (__main__.ArchiveUtilTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".\lib\distutils\tests\test_archive_util.py", line 297, in test_make_tarball_unicode_latin1
self._make_tarball(u'årchiv') # note this isn't a real word
File ".\lib\distutils\tests\test_archive_util.py", line 64, in _make_tarball
make_tarball(splitdrive(base_name)[1], '.')
File "C:\Users\jaraco\projects\public\cpython\Lib\distutils\archive_util.py",
line 101, in make_tarball
tar = tarfile.open(archive_name, 'w:%s' % tar_compression[compress])
File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 1676, in open
return func(name, filemode, fileobj, **kwargs)
File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 1724, in gzopen
gzip.GzipFile(name, mode, compresslevel, fileobj),
File "C:\Users\jaraco\projects\public\cpython\Lib\gzip.py", line 127, in __init__
self._write_gzip_header()
File "C:\Users\jaraco\projects\public\cpython\Lib\gzip.py", line 172, in _write_gzip_header
self.fileobj.write(fname + '\000')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 0:
ordinal not in range(128)
----------------------------------------------------------------------
Ran 12 tests in 0.058s
FAILED (errors=2, skipped=3)
Traceback (most recent call last):
File ".\lib\distutils\tests\test_archive_util.py", line 311, in <module>
run_unittest(test_suite())
File "C:\Users\jaraco\projects\public\cpython\Lib\test\test_support.py", line
1094, in run_unittest
_run_suite(suite)
File "C:\Users\jaraco\projects\public\cpython\Lib\test\test_support.py", line
1077, in _run_suite
raise TestFailed(err)
test.test_support.TestFailed: multiple errors occurred |
|
Date |
User |
Action |
Args |
2011-12-26 05:39:30 | jaraco | set | recipients:
+ jaraco, lars.gustaebel, vstinner, tarek, eric.araujo, RonnyPfannschmidt, alexis, mu_mind, mikehoy, jens |
2011-12-26 05:39:30 | jaraco | set | messageid: <1324877970.1.0.754580260686.issue11638@psf.upfronthosting.co.za> |
2011-12-26 05:39:29 | jaraco | link | issue11638 messages |
2011-12-26 05:39:28 | jaraco | create | |
|