Reads a pyc file and returns the unmarshalled code object within. No header validation is performed.
(pyc_path)
| 132 | |
| 133 | |
| 134 | def get_code_from_pyc(pyc_path): |
| 135 | """Reads a pyc file and returns the unmarshalled code object within. |
| 136 | |
| 137 | No header validation is performed. |
| 138 | """ |
| 139 | with open(pyc_path, 'rb') as pyc_f: |
| 140 | pyc_f.seek(16) |
| 141 | return marshal.load(pyc_f) |
| 142 | |
| 143 | |
| 144 | @contextlib.contextmanager |