diff options
author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-06-19 23:35:22 (GMT) |
---|---|---|
committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-06-19 23:35:22 (GMT) |
commit | 103e8113e4bb4ad3687d641f660481c72904d571 (patch) | |
tree | 6cbac120aa945c22821830b42077fa933d486431 /Lib/test | |
parent | f29ec4b0c89bbb3a4ee4549b3b4a8535d040833f (diff) | |
download | cpython-103e8113e4bb4ad3687d641f660481c72904d571.zip cpython-103e8113e4bb4ad3687d641f660481c72904d571.tar.gz cpython-103e8113e4bb4ad3687d641f660481c72904d571.tar.bz2 |
Fix GzipFile's handling of filenames given as bytes objects.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_gzip.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 5ae7467..ced226f 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -331,6 +331,20 @@ class TestGzip(unittest.TestCase): with gzip.GzipFile(fileobj=f, mode="w") as g: pass + def test_bytes_filename(self): + str_filename = self.filename + try: + bytes_filename = str_filename.encode("ascii") + except UnicodeEncodeError: + self.skipTest("Temporary file name needs to be ASCII") + with gzip.GzipFile(bytes_filename, "wb") as f: + f.write(data1 * 50) + with gzip.GzipFile(bytes_filename, "rb") as f: + self.assertEqual(f.read(), data1 * 50) + # Sanity check that we are actually operating on the right file. + with gzip.GzipFile(str_filename, "rb") as f: + self.assertEqual(f.read(), data1 * 50) + # Testing compress/decompress shortcut functions def test_compress(self): |