Validate a hash-based pyc by checking the real source hash against the one in the pyc header. *data* is the contents of the pyc file. (Only the first 16 bytes are required.) *source_hash* is the importlib.util.source_hash() of the source file. *name* is the name of the module
(data, source_hash, name, exc_details)
| 472 | |
| 473 | |
| 474 | def _validate_hash_pyc(data, source_hash, name, exc_details): |
| 475 | """Validate a hash-based pyc by checking the real source hash against the one in |
| 476 | the pyc header. |
| 477 | |
| 478 | *data* is the contents of the pyc file. (Only the first 16 bytes are |
| 479 | required.) |
| 480 | |
| 481 | *source_hash* is the importlib.util.source_hash() of the source file. |
| 482 | |
| 483 | *name* is the name of the module being imported. It is used for logging. |
| 484 | |
| 485 | *exc_details* is a dictionary passed to ImportError if it raised for |
| 486 | improved debugging. |
| 487 | |
| 488 | An ImportError is raised if the bytecode is stale. |
| 489 | |
| 490 | """ |
| 491 | if data[8:16] != source_hash: |
| 492 | raise ImportError( |
| 493 | f'hash in bytecode doesn\'t match hash of source {name!r}', |
| 494 | **exc_details, |
| 495 | ) |
| 496 | |
| 497 | |
| 498 | def _compile_bytecode(data, name=None, bytecode_path=None, source_path=None): |
no outgoing calls
no test coverage detected
searching dependent graphs…