@@ -375,31 +375,29 @@ def _read_pyc(
375
375
except OSError :
376
376
return None
377
377
with fp :
378
- # https://www.python.org/dev/peps/pep-0552/
379
- has_flags = sys .version_info >= (3 , 7 )
380
378
try :
381
379
stat_result = os .stat (source )
382
380
mtime = int (stat_result .st_mtime )
383
381
size = stat_result .st_size
384
- data = fp .read (16 if has_flags else 12 )
382
+ data = fp .read (16 )
385
383
except OSError as e :
386
384
trace (f"_read_pyc({ source } ): OSError { e } " )
387
385
return None
388
386
# Check for invalid or out of date pyc file.
389
- if len (data ) != (16 if has_flags else 12 ):
387
+ if len (data ) != (16 ):
390
388
trace ("_read_pyc(%s): invalid pyc (too short)" % source )
391
389
return None
392
390
if data [:4 ] != importlib .util .MAGIC_NUMBER :
393
391
trace ("_read_pyc(%s): invalid pyc (bad magic number)" % source )
394
392
return None
395
- if has_flags and data [4 :8 ] != b"\x00 \x00 \x00 \x00 " :
393
+ if data [4 :8 ] != b"\x00 \x00 \x00 \x00 " :
396
394
trace ("_read_pyc(%s): invalid pyc (unsupported flags)" % source )
397
395
return None
398
- mtime_data = data [8 if has_flags else 4 : 12 if has_flags else 8 ]
396
+ mtime_data = data [8 : 12 ]
399
397
if int .from_bytes (mtime_data , "little" ) != mtime & 0xFFFFFFFF :
400
398
trace ("_read_pyc(%s): out of date" % source )
401
399
return None
402
- size_data = data [12 if has_flags else 8 : 16 if has_flags else 12 ]
400
+ size_data = data [12 : 16 ]
403
401
if int .from_bytes (size_data , "little" ) != size & 0xFFFFFFFF :
404
402
trace ("_read_pyc(%s): invalid pyc (incorrect size)" % source )
405
403
return None
0 commit comments