Repository navigation
Fix non-empty slices of frozen Boxes - #365
Open
anticipate218 wants to merge 1 commit into
Open
anticipate218 wants to merge 1 commit into
anticipate218 wants to merge 1 commit into
Conversation
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.
Problem
Non-empty slices of a frozen
BoxraiseBoxError: Box is frozeninstead of returning a frozen subset:Both slice paths create an already-frozen destination and then assign the selected entries into it. Python 3.11 reaches the
TypeErrorpath because slices are unhashable; Python 3.12+ normally reaches theKeyErrorpath.Change
Pass the selected key/value pairs into the configured Box class's constructor, so they are populated before construction finishes. Use an iterable of pairs rather than a mapping to preserve explicit
Noneentries withdefault_box=True. Keep key selection outside the generator expression for compatibility with the Cython build.The regressions cover mutable/frozen Boxes,
ConfigBox, full/partial/reversed/empty slices, nested frozen values, hashes, default-box and dotted options, recast calls, and an explicitly stored slice key on Python 3.12+. This does not change the separate merge/union operators orBoxListslicing.Validation
Against
developate6d83100b32019eca1f53bc14544e8e353229217, on Windows 11:python -m build --no-isolationon both interpreters. Installed each wheel into a separate target and verified that tests imported its.pyd, not the source checkout. The complete suites produced the same passing counts as above.twine checkpassed for both sdists and wheels.ruff check .,ruff format --check .,mypy box, and configured pre-commit checks for the changed files passed.Tests ran with Python UTF-8 mode. Other operating systems, PyPy, and the remaining CPython versions were not run locally. An initial candidate exposed a Cython
super()/generator compatibility failure; the final implementation above fixes it and both compiled suites were rerun successfully.