Issue #11235: Fix OverflowError when trying to import a source file whose modification time doesn't fit in a 32-bit timestamp.

This commit is contained in:
Antoine Pitrou 2012-01-24 17:44:06 +01:00
parent dfdc46f274
commit d1c818a9c0
3 changed files with 20 additions and 7 deletions

View file

@ -277,6 +277,19 @@ class ImportTests(unittest.TestCase):
finally:
os.rmdir(source)
def test_timestamp_overflow(self):
# A modification timestamp larger than 2**32 should not be a problem
# when importing a module (issue #11235).
source = TESTFN + ".py"
self.addCleanup(remove_files, TESTFN)
compiled = source + ('c' if __debug__ else 'o')
with open(source, 'w') as f:
pass
os.utime(source, (2 ** 33, 2 ** 33))
__import__(TESTFN)
# The pyc file was created.
os.stat(compiled)
class PycRewritingTests(unittest.TestCase):
# Test that the `co_filename` attribute on code objects always points