(
fp: IO[bytes], source_stat: os.stat_result, co: types.CodeType
)
| 298 | |
| 299 | |
| 300 | def _write_pyc_fp( |
| 301 | fp: IO[bytes], source_stat: os.stat_result, co: types.CodeType |
| 302 | ) -> None: |
| 303 | # Technically, we don't have to have the same pyc format as |
| 304 | # (C)Python, since these "pycs" should never be seen by builtin |
| 305 | # import. However, there's little reason to deviate. |
| 306 | fp.write(importlib.util.MAGIC_NUMBER) |
| 307 | # https://www.python.org/dev/peps/pep-0552/ |
| 308 | flags = b"\x00\x00\x00\x00" |
| 309 | fp.write(flags) |
| 310 | # as of now, bytecode header expects 32-bit numbers for size and mtime (#4903) |
| 311 | mtime = int(source_stat.st_mtime) & 0xFFFFFFFF |
| 312 | size = source_stat.st_size & 0xFFFFFFFF |
| 313 | # "<LL" stands for 2 unsigned longs, little-endian. |
| 314 | fp.write(struct.pack("<LL", mtime, size)) |
| 315 | fp.write(marshal.dumps(co)) |
| 316 | |
| 317 | |
| 318 | def _write_pyc( |
no test coverage detected
searching dependent graphs…