From e3761571cfe9c21baa138d58c1f304bdbca572ae Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 10 Jan 2018 21:47:09 -0500 Subject: Python 3.7 tweaked the layout of .pyc files --- lab/show_pyc.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'lab') diff --git a/lab/show_pyc.py b/lab/show_pyc.py index 0a28e4fb..525797a8 100644 --- a/lab/show_pyc.py +++ b/lab/show_pyc.py @@ -13,14 +13,25 @@ import types def show_pyc_file(fname): f = open(fname, "rb") magic = f.read(4) - moddate = f.read(4) - modtime = time.asctime(time.localtime(struct.unpack('= (3, 3): - # 3.3 added another long to the header (size). - size = f.read(4) - print("pysize %s (%d)" % (binascii.hexlify(size), struct.unpack('= (3, 7): + # 3.7 added a flags word + flags = struct.unpack('= (3, 3): + # 3.3 added another long to the header (size). + size = f.read(4) + print("pysize %s (%d)" % (binascii.hexlify(size), struct.unpack('