Validate a pyc against the source last-modified time. *data* is the contents of the pyc file. (Only the first 16 bytes are required.) *source_mtime* is the last modified timestamp of the source file. *source_size* is None or the size of the source file in bytes. *name* is the
(data, source_mtime, source_size, name,
exc_details)
| 444 | |
| 445 | |
| 446 | def _validate_timestamp_pyc(data, source_mtime, source_size, name, |
| 447 | exc_details): |
| 448 | """Validate a pyc against the source last-modified time. |
| 449 | |
| 450 | *data* is the contents of the pyc file. (Only the first 16 bytes are |
| 451 | required.) |
| 452 | |
| 453 | *source_mtime* is the last modified timestamp of the source file. |
| 454 | |
| 455 | *source_size* is None or the size of the source file in bytes. |
| 456 | |
| 457 | *name* is the name of the module being imported. It is used for logging. |
| 458 | |
| 459 | *exc_details* is a dictionary passed to ImportError if it raised for |
| 460 | improved debugging. |
| 461 | |
| 462 | An ImportError is raised if the bytecode is stale. |
| 463 | |
| 464 | """ |
| 465 | if _unpack_uint32(data[8:12]) != (source_mtime & 0xFFFFFFFF): |
| 466 | message = f'bytecode is stale for {name!r}' |
| 467 | _bootstrap._verbose_message('{}', message) |
| 468 | raise ImportError(message, **exc_details) |
| 469 | if (source_size is not None and |
| 470 | _unpack_uint32(data[12:16]) != (source_size & 0xFFFFFFFF)): |
| 471 | raise ImportError(f'bytecode is stale for {name!r}', **exc_details) |
| 472 | |
| 473 | |
| 474 | def _validate_hash_pyc(data, source_hash, name, exc_details): |
no test coverage detected
searching dependent graphs…