Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/ctypes/test/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class struct_frozen(Structure):
bootstrap_expected = [
b'_frozen_importlib',
b'_frozen_importlib_external',
b'zipimport',
]
for entry in ft:
# This is dangerous. We *can* iterate over a pointer, but
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_bdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def main():
('line', 2, 'tfunc_import'), ('step', ),
('line', 3, 'tfunc_import'), ('quit', ),
]
skip = ('importlib*', TEST_MODULE)
skip = ('importlib*', 'zipimport', TEST_MODULE)
Comment thread
warsaw marked this conversation as resolved.
with TracerRun(self, skip=skip) as tracer:
tracer.runcall(tfunc_import)

Expand Down
22 changes: 11 additions & 11 deletions Lib/test/test_zipimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,24 +677,24 @@ def testBytesPath(self):

zipimport.zipimporter(filename)
zipimport.zipimporter(os.fsencode(filename))
with self.assertWarns(DeprecationWarning):
with self.assertRaises(TypeError):
zipimport.zipimporter(bytearray(os.fsencode(filename)))
with self.assertWarns(DeprecationWarning):
with self.assertRaises(TypeError):
zipimport.zipimporter(memoryview(os.fsencode(filename)))

@support.cpython_only
def testUninitializedZipimporter(self):
# The interpreter shouldn't crash in case of calling methods of an
# uninitialized zipimport.zipimporter object.
zi = zipimport.zipimporter.__new__(zipimport.zipimporter)
self.assertRaises(ValueError, zi.find_module, 'foo')
self.assertRaises(ValueError, zi.find_loader, 'foo')
self.assertRaises(ValueError, zi.load_module, 'foo')
self.assertRaises(ValueError, zi.get_filename, 'foo')
self.assertRaises(ValueError, zi.is_package, 'foo')
self.assertRaises(ValueError, zi.get_data, 'foo')
self.assertRaises(ValueError, zi.get_code, 'foo')
self.assertRaises(ValueError, zi.get_source, 'foo')
self.assertRaises((ValueError, AttributeError), zi.find_module, 'foo')
Comment thread
warsaw marked this conversation as resolved.
self.assertRaises((ValueError, AttributeError), zi.find_loader, 'foo')
self.assertRaises((ValueError, AttributeError), zi.load_module, 'foo')
self.assertRaises((ValueError, AttributeError), zi.get_filename, 'foo')
self.assertRaises((ValueError, AttributeError), zi.is_package, 'foo')
self.assertRaises((ValueError, AttributeError), zi.get_data, 'foo')
self.assertRaises((ValueError, AttributeError), zi.get_code, 'foo')
self.assertRaises((ValueError, AttributeError), zi.get_source, 'foo')


@support.requires_zlib
Expand All @@ -712,7 +712,7 @@ def bad_decompress(*args):
zip_file.writestr('bar.py', b'print("hello world")', ZIP_DEFLATED)
zi = zipimport.zipimporter(TEMP_ZIP)
with support.swap_attr(zlib, 'decompress', bad_decompress):
self.assertRaises(TypeError, zi.get_source, 'bar')
self.assertRaises((TypeError, AttributeError), zi.get_source, 'bar')
Comment thread
warsaw marked this conversation as resolved.


class BadFileZipImportTestCase(unittest.TestCase):
Expand Down
Loading