Skip to content

Fix potential IndexError in _convert_pbn for short PBN deal strings.#186

Open
tameware wants to merge 3 commits into
dds-bridge:developfrom
tameware:fix-python-example
Open

Fix potential IndexError in _convert_pbn for short PBN deal strings.#186
tameware wants to merge 3 commits into
dds-bridge:developfrom
tameware:fix-python-example

Conversation

@tameware

Copy link
Copy Markdown
Contributor

No description provided.

tameware and others added 2 commits June 11, 2026 20:00
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>
@tameware tameware marked this pull request as ready for review June 12, 2026 21:37
@zzcgumn zzcgumn requested a review from Copilot June 14, 2026 16:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 of pbn_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.py as a py_library for 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.

Comment thread python/examples/BUILD.bazel

@zzcgumn zzcgumn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants