Skip to content

round-trip APL items with an unknown address family through text - #1313

Open
youdie006 wants to merge 1 commit into
rthalley:mainfrom
youdie006:apl-unknown-family-text
Open

youdie006 wants to merge 1 commit into
rthalley:mainfrom
youdie006:apl-unknown-family-text

Conversation

@youdie006

Copy link
Copy Markdown
Contributor

For an APL item whose address family is not 1 or 2, the wire parser keeps the address as hex bytes, so to_text() prints 3:b'e0'/4. from_text() rejects that and also 3:e0/4, because the constructor wants bytes, not str. The 127-octet limit was also checked against the hex string, so a wire address of 64-127 octets raised FormError: too long.

The constructor now takes the hex address as text (up to 254 characters, checked with unhexlify), and __str__ prints it without the bytes wrapper. Families 1 and 2 are unchanged.

The new test parses wire data with a 2-octet and a 64-octet address, checks that the text parses back to the same wire, and rejects odd-length hex. ruff, black and the full test suite (3.10) pass.

Written with AI assistance (Claude); I have reviewed the change.

The wire parser kept the address as hex bytes, so to_text() printed a
Python bytes literal, from_text() rejected every such item, and the
127-octet limit was checked against the hex string.

This branch has not been deployed

No deployments
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.

1 participant