[Python-checkins] cpython: Issue #17220: two fixes for changeset 2528e4aea338.

brett.cannon python-checkins at python.org
Mon Feb 25 23:10:22 CET 2013


http://hg.python.org/cpython/rev/d98a82f4c9bd
changeset:   82385:d98a82f4c9bd
user:        Brett Cannon <brett at python.org>
date:        Mon Feb 25 17:10:11 2013 -0500
summary:
  Issue #17220: two fixes for changeset 2528e4aea338.

First, because the mtime can exceed 4 bytes, make sure to mask it down to 4
bytes before getting its little-endian representation for writing out to a .pyc
file.

Two, cap an rsplit() call to 1 split, else can lead to too many values being
returned for unpacking.

files:
  Lib/importlib/_bootstrap.py |     4 +-
  Python/importlib.h          |  8448 +++++++++++-----------
  2 files changed, 4227 insertions(+), 4225 deletions(-)


diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -48,7 +48,7 @@
     XXX Temporary until marshal's long functions are exposed.
 
     """
-    return int(x).to_bytes(4, 'little')
+    return (int(x) & 0xFFFFFFFF).to_bytes(4, 'little')
 
 
 # TODO: Expose from marshal
@@ -74,7 +74,7 @@
         return front, tail
     for x in reversed(path):
         if x in path_separators:
-            front, tail = path.rsplit(x)
+            front, tail = path.rsplit(x, maxsplit=1)
             return front, tail
     return '', path
 
diff --git a/Python/importlib.h b/Python/importlib.h
--- a/Python/importlib.h
+++ b/Python/importlib.h
[stripped]

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list