Skip to content

compileall doesn't recompile when invalidation mode changes even if timestamps match #117204

@hauntsaninja

Description

@hauntsaninja

Bug report

Bug description:

λ rm -rf __pycache__                                                                                                                            130 
λ python -m compileall x.py --invalidation-mode timestamp
Compiling 'x.py'...
λ python -m compileall x.py --invalidation-mode timestamp
λ python -m compileall x.py --invalidation-mode checked-hash

λ python
>>> import importlib.util
>>> with open("__pycache__/x.cpython-311.pyc", "rb") as f:
...     d = f.read()
... 
>>> d[:4]
b'\xa7\r\r\n'
>>> d[4:8]
b'\x00\x00\x00\x00'

λ rm -rf __pycache__
λ python -m compileall x.py --invalidation-mode checked-hash
Compiling 'x.py'...

λ python
>>> with open("__pycache__/x.cpython-311.pyc", "rb") as f:
...     d = f.read()
... 
>>> d[:4]
b'\xa7\r\r\n'
>>> d[4:8]
b'\x03\x00\x00\x00'

CPython versions tested on:

3.11

Operating systems tested on:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions