# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt """ Dump the contents of a .pyc file. The output will only be correct if run with the same version of Python that produced the .pyc. """ import binascii import dis import marshal import struct import sys import time import types def show_pyc_file(fname): f = open(fname, "rb") magic = f.read(4) print("magic %s" % (binascii.hexlify(magic))) read_date_and_size = True if sys.version_info >= (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('