Repository navigation
Conversation
_OuterBinding is a str subclass whose __new__ needs levels, so pickle could not rebuild it and build failed with BrokenProcessPool on a nested class that calls a field of its outer class. Define __reduce__ to keep levels. Closes tirth8205#1214
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Linked issue
Closes #1214
Implements the fix suggested in the issue (#1214).
What & why
parser._OuterBindingis astrsubclass whose__new__takes a second argument,levels. C# nested classes that use a field of their outer class store it inextra["receiver_type"]of the CALLS edge. The process-pool parser pickles every worker result; pickle rebuilds astrsubclass through__new__(cls, str(self)), which dropslevels. The parent process then fails withTypeError: _OuterBinding.__new__() missing 1 required positional argument: 'levels', andbuild(andupdatewith 8 or more files) ends withBrokenProcessPool.The fix adds
_OuterBinding.__reduce__, which returns(_OuterBinding, (str(self), self.levels)). The value andlevelsnow survive the round trip, and nothing else changes. The_OuterBindingalready sits inreceiver_type, so it has to survive the process-pool queue; keeping the type means the edge is the same on the serial, thread and process paths. (The resolver itself reads the intextra["csharp_receiver_levels"], which the worker sets before pickling, not.levelsof the unpickled value.) I checked for otherstr/int/tuplesubclasses incode_review_graph/: this is the only one.Changes:
code_review_graph/parser.py:_OuterBinding.__reduce__.tests/test_csharp_outer_binding_pickle.py: pickle round trip of_OuterBinding; pickle round trip of the(nodes, edges)parsed from the snippet in the issue;full_buildwithCRG_PARSE_EXECUTOR=processon 9 C# files with a nested outer-field call (it also asserts that the parallel executor was built, so a serial fallback cannot make it pass).CHANGELOG.md: a bullet under## [Unreleased]/### Fixed.Without the fix all three new tests fail (the last one with the
BrokenProcessPoolfrom the issue); with it they pass.How it was tested
The same 11 tests fail on an unmodified
stagingin my environment (8252 passedthere, 3 fewer than here: my 3 new tests), also with a clean temporary directory (TMPDIRpointed at a fresh directory). They exercise git and non-repository directory handling, not the parser code changed here. Python 3.13.Checklist
uv run pytest tests/ --tb=short -q(11 tests fail locally, identically onstagingwithout this change; see above; CI is the reference)uv run ruff check code_review_graph/uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optionaldocs/, docstrings)This PR was prepared with AI assistance (Claude Code). I reproduced the bug, reviewed the change, and ran the tests myself.