mirror of
https://github.com/python/cpython.git
synced 2025-10-15 03:10:29 +00:00
Paper over bug 1054615 by passing sane values to os.utime().
The underlying bug still exists, but also existed in 2.3.4: import.c's load_source_module() returns NULL if PyOS_GetLastModificationTime() returns -1, but PyOS_GetLastModificationTime() doesn't set any exception when it returns -1, and neither does load_source_module() when it gets back -1. This leads to "SystemError: NULL result without error in PyObject_Call" on an import that fails in this way.
This commit is contained in:
parent
48aa84b24d
commit
f1af9c0896
1 changed files with 5 additions and 2 deletions
|
@ -41,7 +41,8 @@ class TracebackCases(unittest.TestCase):
|
||||||
self.assert_(err[1].strip() == "[x for x in x] = x")
|
self.assert_(err[1].strip() == "[x for x in x] = x")
|
||||||
|
|
||||||
def test_bug737473(self):
|
def test_bug737473(self):
|
||||||
import sys, os, tempfile
|
import sys, os, tempfile, time
|
||||||
|
|
||||||
savedpath = sys.path[:]
|
savedpath = sys.path[:]
|
||||||
testdir = tempfile.mkdtemp()
|
testdir = tempfile.mkdtemp()
|
||||||
try:
|
try:
|
||||||
|
@ -51,8 +52,10 @@ class TracebackCases(unittest.TestCase):
|
||||||
def test():
|
def test():
|
||||||
raise ValueError"""
|
raise ValueError"""
|
||||||
|
|
||||||
|
# XXX Unclear why we're doing this next bit.
|
||||||
if hasattr(os, 'utime'):
|
if hasattr(os, 'utime'):
|
||||||
os.utime(testfile, (0, 0))
|
past = time.time() - 3
|
||||||
|
os.utime(testfile, (past, past))
|
||||||
else:
|
else:
|
||||||
import time
|
import time
|
||||||
time.sleep(3) # not to stay in same mtime.
|
time.sleep(3) # not to stay in same mtime.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue