GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Fix stale Python bytecode after apply (#819) by mikolalysenko · Pull Request #1722 · SocketDev/socket-patch Conversation
|
| Issue / case | Test | Before fix | After |
|---|---|---|---|
| #819 apply, real CPython venv, same-second same-size patch | e2e_pypi_bytecode::same_second_same_size_apply_and_rollback_change_imported_code |
FAILED (import printed original after apply) |
ok |
| #819 rollback, same test, second half | same test | (unreached) | ok |
| #819 core write path | apply::tests::test_apply_file_patch_py_removes_stale_bytecode, ..._top_level_py_..., ..._in_readonly_cache |
FAILED | ok |
| #819 rollback restore | rollback::tests::test_rollback_modified_py_removes_stale_bytecode |
FAILED | ok |
| Upgrade re-run over an already-patched module | apply::tests::test_apply_already_patched_py_removes_older_bytecode |
n/a (added with the review fix) | ok |
Non-.py writes leave bytecode alone; exact name match |
test_apply_file_patch_non_py_keeps_bytecode, test_is_bytecode_of |
ok / n/a | ok |
The e2e test makes the race deterministic: after each write it sets the
source's mtime back to the second the bytecode was compiled against,
which is exactly the on-disk state a same-second apply leaves.
Commands run locally (Linux):
cargo fmt --all -- --check: cleancargo clippy --workspace --all-features -- -D warnings: cleancargo test -p socket-patch-cli --all-features --test e2e_pypi_bytecode: red on df7d35c (tests only), green on the fixcargo test --workspace --all-features --no-fail-fast: everything passes except 11 permission and write-failure tests (copy_tree relax loop, vlt_heal, poetry and requirements wire failures, repair cleanup, in_process_redirect write failures, 2 in e2e_bun_lockb). This sandbox runs as root, which bypasses chmod-based failure injection. I re-ran the 4 core-lib ones on an origin/main worktree and they fail identically there. CI runs unprivileged.I ran /code-review high and fixed the findings above (upgrade
re-run, silent failures, sourceless-.pyc deletion, dotted-stem
match, rollback ordering). Not changed, with reasons:
PYTHONPYCACHEPREFIX / sys.pycache_prefix: with these set,apply can't see.__pycache__ once per patched .py: patches touch apython_on_path, set_mtime): small, andhttps://claude.ai/code/session_01Bb9iRCn4pmjPCK4q37zC6Z
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Assisted-by: Claude Code:claude-opus-5-5
A same-size patch applied in the same second pip compiled the module leaves the timestamp .pyc valid, so Python keeps running the unpatched code. Rollback has the mirror problem. These tests cover the core write path and a real CPython venv end to end (#819). Assisted-by: Claude Code:claude-opus-5-5
Agent-mode apply and rollback now delete the __pycache__ bytecode (and a legacy sibling .pyc/.pyo) compiled from each .py file they rewrite. Before, a same-size patch applied in the same second as the install left the timestamp .pyc valid, so Python kept running the unpatched code while apply reported success and VEX attested not_affected. Rollback could keep the patched code running the same way. Python recompiles the bytecode on the next import. The helper rollback used for patch-added modules moves into the shared write path so both use one rule (#819). Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
Address review findings on the #819 fix: - A re-run of apply over a module an older release already patched now drops bytecode that predates the patched source, so upgrading and re-running apply repairs it. - A .pyc that can't be deleted is reported as a warning instead of being ignored. - Sourceless <stem>.pyc files beside the source are left alone: under Python 3 a package may ship them, and rollback could not bring them back. - Only exact <stem>.<tag>[.opt-N].pyc names match, so a dotted sibling module's bytecode is kept. - Rollback drops a deleted module's bytecode even when it can't prune the directories above it. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Labeled Ready for review by the burn-down agent.
Slack announcement not sent this run (Slack send unavailable to the agent). Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Labeled Ready for review by the burn-down agent.
Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Final review briefWhat it does. Agent-mode Risk: low. The new code only deletes regular files matching the exact PEP 3147/488 name of the rewritten module inside its Look here
Verified
Changes I made. None. Open questions (non-blocking)
Auto-merge (squash) is armed, so approving sends this straight to the merge queue. Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
A .pyc that apply or rollback could not delete was put on the result as a note, but the CLI only surfaced ownership notes: apply dropped it, and rollback labelled it ownership_not_restored. Map each advisory note to its warning code by marker, so the failure shows up as stale_bytecode_not_removed. Notes from several already patched files are now all kept instead of only the last, and a --force skip message no longer replaces them. Assisted-by: Claude Code:claude-opus-5-5
|
[agent] Re the final review brief's first open question: fixed in a98b93d. A failed Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Final reviewer: I turned auto-merge off. The brief above covers Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Final review briefWhat it does: When agent-mode Risk: low. It only deletes CPython cache files, which the next import rebuilds. Names must match exactly, so dotted sibling modules and sourceless Look here:
Verified: I read the full diff (6 files, +712/−67) and checked the name matcher's edge cases ( Changes I made: none. Open questions: none blocking. The PR body lists Auto-merge is armed: approving sends it straight to the merge queue. Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Burn-down agent: Ready for review still holds at the new head
Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…bytecode # Conflicts: # crates/socket-patch-cli/CLI_CONTRACT.md
|
bugbot run Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Rolling back a patch-added .py file removed its stale bytecode but dropped the warning when a .pyc could not be deleted. It now joins the rollback result, so the CLI reports stale_bytecode_not_removed just as it does for restored files. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit de736a0. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
[final reviewer] Re-added to the merge queue at 16:49 UTC. Head Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Resolve conflicts with main's advisory-warning refactor (#1722) and the global Go tool tests (#1717). apply.rs keeps main's advisory_warning_codes loop (it covers ownership_not_restored too) and drops main's nested_skip_warnings, because this branch already reports those skips through run_warnings. e2e_golang_build.rs keeps both sides' new tests. Co-Authored-By: Claude <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Agent-mode apply of a same-size PyPI patch in the same second aspip install leaves pip's __pycache__ bytecode valid, so Python keeps running the unpatched code while apply reports it patched
There was an error while loading. Please reload this page.