Skip to content

Commit 1071bf5

Browse files
committed
Address Serhiy's comments
1 parent 3911731 commit 1071bf5

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

Lib/test/test_compileall.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,16 @@ def timestamp_metadata(self):
6262
def test_year_2038_mtime_compilation(self):
6363
# Test to make sure we can handle mtimes larger than what a 32-bit
6464
# signed number can hold as part of bpo-34990
65-
with open(self.source_path, 'r') as f:
66-
os.utime(f.name, (2**32 - 1, 2**32 - 1))
65+
os.utime(self.source_path, (2**32 - 1, 2**32 - 1))
6766
self.assertTrue(compileall.compile_file(self.source_path))
6867

69-
with open(self.source_path, 'r') as f:
70-
os.utime(f.name, (2**35, 2**35))
68+
def test_larger_than_32_bit_times(self):
69+
# This is similar to the test above but we skip it if the OS doesn't
70+
# support modification times larger than 32-bits.
71+
try:
72+
os.utime(self.source_path, (2**35, 2**35))
73+
except (OverflowError, OSError):
74+
self.skipTest("filesystem doesn't support large timestamps")
7175
self.assertTrue(compileall.compile_file(self.source_path))
7276

7377
def recreation_check(self, metadata):

Lib/test/test_zipimport.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ def get_file():
3434

3535
def make_pyc(co, mtime, size):
3636
data = marshal.dumps(co)
37-
if type(mtime) is type(0.0):
38-
# Mac mtimes need a bit of special casing
39-
if mtime < 0x7fffffff:
40-
mtime = int(mtime)
41-
else:
42-
mtime = int(-0x100000000 + int(mtime))
4337
pyc = (importlib.util.MAGIC_NUMBER +
4438
struct.pack("<iLL", 0,
4539
int(mtime) & 0xFFFF_FFFF, size & 0xFFFF_FFFF) + data)
@@ -262,11 +256,6 @@ def test2038MTime(self):
262256
TESTMOD + pyc_ext: (NOW, twenty_thirty_eight_pyc)}
263257
self.doTest(".py", files, TESTMOD)
264258

265-
larger_than_32_bit = make_pyc(test_co, 2**35, len(test_src))
266-
files = {TESTMOD + ".py": (NOW, test_src),
267-
TESTMOD + pyc_ext: (NOW, twenty_thirty_eight_pyc)}
268-
self.doTest(".py", files, TESTMOD)
269-
270259
def testPackage(self):
271260
packdir = TESTPACK + os.sep
272261
files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc),

0 commit comments

Comments
 (0)