Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 61ecb77 commit 3540b50Copy full SHA for 3540b50
2 files changed
Lib/test/test_import.py
@@ -213,7 +213,8 @@ def test_file_to_source(self):
213
os.remove(source)
214
del sys.modules[TESTFN]
215
mod = __import__(TESTFN)
216
- self.failUnless(mod.__file__.endswith('.pyc'))
+ ext = mod.__file__[-4:]
217
+ self.failUnless(ext in ('.pyc', '.pyo'), ext)
218
finally:
219
sys.path.pop(0)
220
remove_files(TESTFN)
Python/import.c
@@ -982,7 +982,8 @@ get_sourcefile(const char *file)
982
}
983
984
len = strlen(file);
985
- if (len > MAXPATHLEN || PyOS_stricmp(&file[len-4], ".pyc") != 0) {
+ /* match '*.py?' */
986
+ if (len > MAXPATHLEN || PyOS_strnicmp(&file[len-4], ".py", 3) != 0) {
987
return PyUnicode_DecodeFSDefault(file);
988
989
0 commit comments