mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
Good catch Neal!
I completely forgot about pyo files and the tests are usually not run with -O. The modified code checks for *.py?
This commit is contained in:
parent
61ecb7768f
commit
3540b50884
2 changed files with 4 additions and 2 deletions
|
@ -213,7 +213,8 @@ class ImportTest(unittest.TestCase):
|
||||||
os.remove(source)
|
os.remove(source)
|
||||||
del sys.modules[TESTFN]
|
del sys.modules[TESTFN]
|
||||||
mod = __import__(TESTFN)
|
mod = __import__(TESTFN)
|
||||||
self.failUnless(mod.__file__.endswith('.pyc'))
|
ext = mod.__file__[-4:]
|
||||||
|
self.failUnless(ext in ('.pyc', '.pyo'), ext)
|
||||||
finally:
|
finally:
|
||||||
sys.path.pop(0)
|
sys.path.pop(0)
|
||||||
remove_files(TESTFN)
|
remove_files(TESTFN)
|
||||||
|
|
|
@ -982,7 +982,8 @@ get_sourcefile(const char *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(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);
|
return PyUnicode_DecodeFSDefault(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue