Fix potential IndexError in _convert_pbn for short PBN deal strings.#186
Open
tameware wants to merge 3 commits into
Open
Fix potential IndexError in _convert_pbn for short PBN deal strings.#186tameware wants to merge 3 commits into
tameware wants to merge 3 commits into
Conversation
Check bp < len(pbn_deal) before indexing while scanning for the dealer letter, and return early when the string ends before a direction is found. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a potential IndexError in the Python example helper _convert_pbn() when given short/malformed PBN deal strings, and adds Bazel-native test coverage for the conversion behavior.
Changes:
- Hardened
_convert_pbn()scanning logic to avoid indexing past the end ofpbn_deal. - Added a new unit test validating behavior for short/malformed strings and a known-good example deal.
- Refactored Bazel targets to expose
dd_table_for_deal.pyas apy_libraryfor reuse by tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| python/examples/dd_table_for_deal.py | Adds length guarding in the initial dealer scan to prevent IndexError on short strings. |
| python/tests/test_convert_pbn.py | New unittest coverage for _convert_pbn() (short inputs + basic bitmask correctness). |
| python/examples/BUILD.bazel | Introduces dd_table_for_deal_lib so tests can import dd_table_for_deal. |
| python/BUILD.bazel | Adds convert_pbn_test Bazel py_test target. |
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.
No description provided.