diff options
Diffstat (limited to 'Lib/test/test_import.py')
-rw-r--r-- | Lib/test/test_import.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index c695757..48443ea 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -11,6 +11,7 @@ import stat import sys import unittest import textwrap +import errno from test.support import ( EnvironmentVarGuard, TESTFN, check_warnings, forget, is_jython, @@ -310,6 +311,30 @@ class ImportTests(unittest.TestCase): """)) script_helper.assert_python_ok(testfn) + def test_timestamp_overflow(self): + # A modification timestamp larger than 2**32 should not be a problem + # when importing a module (issue #11235). + sys.path.insert(0, os.curdir) + try: + source = TESTFN + ".py" + compiled = imp.cache_from_source(source) + with open(source, 'w') as f: + pass + try: + os.utime(source, (2 ** 33 - 5, 2 ** 33 - 5)) + except OverflowError: + self.skipTest("cannot set modification time to large integer") + except OSError as e: + if e.errno != getattr(errno, 'EOVERFLOW', None): + raise + self.skipTest("cannot set modification time to large integer ({})".format(e)) + __import__(TESTFN) + # The pyc file was created. + os.stat(compiled) + finally: + del sys.path[0] + remove_files(TESTFN) + class PycRewritingTests(unittest.TestCase): # Test that the `co_filename` attribute on code objects always points |