Skip to content

Commit c7675c3

Browse files
committed
use new-style module creation in zipimporter
1 parent 67b1739 commit c7675c3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/zipimporter/ZipImporterBuiltins.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,11 @@ public PBytes doit(PZipImporter self, String pathname) {
328328
ZipFile zip = new ZipFile(archive);
329329
ZipEntry entry = zip.getEntry(key);
330330
InputStream in = zip.getInputStream(entry);
331-
byte[] bytes = new byte[(int) fileSize];
331+
int byteSize = (int) fileSize;
332+
if (byteSize != fileSize) {
333+
throw raise(PythonErrorType.ZipImportError, "zipimport: cannot read archive members large than 2GB");
334+
}
335+
byte[] bytes = new byte[byteSize];
332336
in.read(bytes);
333337
in.close();
334338
return factory().createBytes(bytes);

graalpython/lib-graalpython/zipimport.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@
3939

4040
import sys
4141
sys.path_hooks.append(zipimporter)
42+
43+
44+
zipimporter.create_module = lambda self, spec: None
45+
zipimporter.exec_module = lambda self, module: exec(self.get_code(module.__name__), module.__dict__)

0 commit comments

Comments
 (0)