summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-08-30 11:08:39 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-08-30 11:08:39 (GMT)
commit095a421b1606ee27e00a5d9d253b05a9f0cfadb8 (patch)
tree8c5710eab63528c40b12216317eaa49bd8aa96b2 /Lib/test
parent2d1653aa43cf02e6b74f9d4f178fac9969a293e2 (diff)
downloadcpython-095a421b1606ee27e00a5d9d253b05a9f0cfadb8.zip
cpython-095a421b1606ee27e00a5d9d253b05a9f0cfadb8.tar.gz
cpython-095a421b1606ee27e00a5d9d253b05a9f0cfadb8.tar.bz2
[3.6] bpo-31291: Fixed an assertion failure in zipimport.zipimporter.get_data() (GH-3226) (#3243)
if pathname.replace('/', '\\') returns non-string. (cherry picked from commit 631fdee6e61b4ba8ce800f827fecdd536bfb04f3)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_zipimport.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index 7ddbc50..daa5138 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -521,6 +521,23 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
z.close()
os.remove(TEMP_ZIP)
+ def test_issue31291(self):
+ # There shouldn't be an assertion failure in get_data().
+ class FunnyStr(str):
+ def replace(self, old, new):
+ return 42
+ z = ZipFile(TEMP_ZIP, "w")
+ try:
+ name = "test31291.dat"
+ data = b'foo'
+ z.writestr(name, data)
+ z.close()
+ zi = zipimport.zipimporter(TEMP_ZIP)
+ self.assertEqual(data, zi.get_data(FunnyStr(name)))
+ finally:
+ z.close()
+ os.remove(TEMP_ZIP)
+
def testImporterAttr(self):
src = """if 1: # indent hack
def get_file():