[pypy-svn] r71869 - in pypy/trunk/pypy/module/imp: . test

arigo at codespeak.net arigo at codespeak.net
Mon Mar 8 10:32:08 CET 2010


Author: arigo
Date: Mon Mar  8 10:32:07 2010
New Revision: 71869

Modified:
   pypy/trunk/pypy/module/imp/importing.py
   pypy/trunk/pypy/module/imp/test/test_import.py
Log:
Remove the special-casing of mtime=0, which was bogus anyway
because the stream's position would not be advanced past the
modification time stored in the .pyc.


Modified: pypy/trunk/pypy/module/imp/importing.py
==============================================================================
--- pypy/trunk/pypy/module/imp/importing.py	(original)
+++ pypy/trunk/pypy/module/imp/importing.py	Mon Mar  8 10:32:07 2010
@@ -647,9 +647,9 @@
     d = x & 0xff
     stream.write(chr(a) + chr(b) + chr(c) + chr(d))
 
-def check_compiled_module(space, pycfilename, expected_mtime=0):
+def check_compiled_module(space, pycfilename, expected_mtime):
     """
-    Check if a pyc file's magic number and (optionally) mtime match.
+    Check if a pyc file's magic number and mtime match.
     """
     stream = None
     try:
@@ -658,11 +658,10 @@
         if magic != get_pyc_magic(space):
             stream.close()
             return None
-        if expected_mtime != 0:
-            pyc_mtime = _r_long(stream)
-            if pyc_mtime != expected_mtime:
-                stream.close()
-                return None
+        pyc_mtime = _r_long(stream)
+        if pyc_mtime != expected_mtime:
+            stream.close()
+            return None
         return stream
     except StreamErrors:
         if stream:

Modified: pypy/trunk/pypy/module/imp/test/test_import.py
==============================================================================
--- pypy/trunk/pypy/module/imp/test/test_import.py	(original)
+++ pypy/trunk/pypy/module/imp/test/test_import.py	Mon Mar  8 10:32:07 2010
@@ -496,6 +496,12 @@
                                               cpathname,
                                               mtime+1)
         assert ret is None
+
+        # also check with expected mtime==0 (nothing special any more about 0)
+        ret = importing.check_compiled_module(space,
+                                              cpathname,
+                                              0)
+        assert ret is None
         os.remove(cpathname)
 
         # check for wrong version



More information about the Pypy-commit mailing list