compileall doesn't recompile when invalidation mode changes even if timestamps match
Open
Nobody has claimed this yet.
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior with x.py using python -m compileall and inspect the generated file in pycache. Start at the compileall command entry point and compare repeated timestamp and checked-hash runs. Done means changing the invalidation mode causes recompilation or otherwise updates the pyc header even when timestamps match.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100