Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: py3k
Changeset: r84182:f8f5beaa6782
Date: 2016-05-04 01:23 +0100
http://bitbucket.org/pypy/pypy/changeset/f8f5beaa6782/

Log:    Update zipimport for the change in pyc format (fixes zipimport -A
        tests)

diff --git a/pypy/module/zipimport/interp_zipimport.py 
b/pypy/module/zipimport/interp_zipimport.py
--- a/pypy/module/zipimport/interp_zipimport.py
+++ b/pypy/module/zipimport/interp_zipimport.py
@@ -200,7 +200,8 @@
         timestamp = importing._get_long(buf[4:8])
         if not self.can_use_pyc(space, filename, magic, timestamp):
             return None
-        buf = buf[8:] # XXX ugly copy, should use sequential read instead
+        # zipimport ignores the size field
+        buf = buf[12:] # XXX ugly copy, should use sequential read instead
         w_mod = w(Module(space, w(modname)))
         real_name = self.filename + os.path.sep + self.corr_zname(filename)
         space.setattr(w_mod, w('__loader__'), space.wrap(self))
@@ -305,8 +306,9 @@
                     if not self.can_use_pyc(space, filename + ext,
                                             magic, timestamp):
                         continue
+                    # zipimport ignores the size field
                     code_w = importing.read_compiled_module(
-                        space, filename + ext, source[8:])
+                        space, filename + ext, source[12:])
                 else:
                     co_filename = self.make_co_filename(filename+ext)
                     code_w = importing.parse_source_module(
@@ -327,7 +329,7 @@
                     w_data = self.get_data(space, fname)
                     # XXX CPython does not handle the coding cookie either.
                     return space.call_method(w_data, "decode",
-                                             space.wrap("utf-8")) 
+                                             space.wrap("utf-8"))
                 else:
                     found = True
         if found:
diff --git a/pypy/module/zipimport/test/test_zipimport.py 
b/pypy/module/zipimport/test/test_zipimport.py
--- a/pypy/module/zipimport/test/test_zipimport.py
+++ b/pypy/module/zipimport/test/test_zipimport.py
@@ -93,8 +93,9 @@
 def get_file():
     return __file__"""
         data = marshal.dumps(compile(source, 'uuu.py', 'exec'))
+        size = len(data).to_bytes(4, 'little', signed=True)
 
-        return imp.get_magic() + mtimeb + data
+        return imp.get_magic() + mtimeb + size + data
 
     def w_now_in_the_future(self, delta):
         self.now += delta
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to