File tree Expand file tree Collapse file tree 2 files changed +8
-15
lines changed Expand file tree Collapse file tree 2 files changed +8
-15
lines changed Original file line number Diff line number Diff line change @@ -62,12 +62,16 @@ def timestamp_metadata(self):
62
62
def test_year_2038_mtime_compilation (self ):
63
63
# Test to make sure we can handle mtimes larger than what a 32-bit
64
64
# 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 ))
67
66
self .assertTrue (compileall .compile_file (self .source_path ))
68
67
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" )
71
75
self .assertTrue (compileall .compile_file (self .source_path ))
72
76
73
77
def recreation_check (self , metadata ):
Original file line number Diff line number Diff line change @@ -34,12 +34,6 @@ def get_file():
34
34
35
35
def make_pyc (co , mtime , size ):
36
36
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 ))
43
37
pyc = (importlib .util .MAGIC_NUMBER +
44
38
struct .pack ("<iLL" , 0 ,
45
39
int (mtime ) & 0xFFFF_FFFF , size & 0xFFFF_FFFF ) + data )
@@ -262,11 +256,6 @@ def test2038MTime(self):
262
256
TESTMOD + pyc_ext : (NOW , twenty_thirty_eight_pyc )}
263
257
self .doTest (".py" , files , TESTMOD )
264
258
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
-
270
259
def testPackage (self ):
271
260
packdir = TESTPACK + os .sep
272
261
files = {packdir + "__init__" + pyc_ext : (NOW , test_pyc ),
You can’t perform that action at this time.
0 commit comments