]> granicus.if.org Git - python/commitdiff
Good catch Neal!
authorChristian Heimes <christian@cheimes.de>
Fri, 11 Jan 2008 07:03:05 +0000 (07:03 +0000)
committerChristian Heimes <christian@cheimes.de>
Fri, 11 Jan 2008 07:03:05 +0000 (07:03 +0000)
I completely forgot about pyo files and the tests are usually not run with -O. The modified code checks for *.py?

Lib/test/test_import.py
Python/import.c

index d8f2d51b206b0a2b7f10c97eebd8bfb0a0bce0df..6eac67e9900e4f3feb594ee38efc1487c1e20bd7 100644 (file)
@@ -213,7 +213,8 @@ class ImportTest(unittest.TestCase):
             os.remove(source)
             del sys.modules[TESTFN]
             mod = __import__(TESTFN)
-            self.failUnless(mod.__file__.endswith('.pyc'))
+            ext = mod.__file__[-4:]
+            self.failUnless(ext in ('.pyc', '.pyo'), ext)
         finally:
             sys.path.pop(0)
             remove_files(TESTFN)
index f9d4246a2bddfc84951b77ba7fcb4cdaa1ff0f4e..cce854fc7c2a71731bbedbe1bfdfd62acd59fc38 100644 (file)
@@ -982,7 +982,8 @@ get_sourcefile(const char *file)
        }
 
        len = strlen(file);
-       if (len > MAXPATHLEN || PyOS_stricmp(&file[len-4], ".pyc") != 0) {
+        /* match '*.py?' */
+       if (len > MAXPATHLEN || PyOS_strnicmp(&file[len-4], ".py", 3) != 0) {
                return PyUnicode_DecodeFSDefault(file);
        }