Skip to content

Fix ParseResultBytes.authority for references without an authority - #166

Open
mayuriphad wants to merge 1 commit into
python-hyper:mainfrom
mayuriphad:fix/parseresultbytes-unsplit-no-authority
Open

mayuriphad wants to merge 1 commit into
python-hyper:mainfrom
mayuriphad:fix/parseresultbytes-unsplit-no-authority

Conversation

@mayuriphad

Copy link
Copy Markdown

Fixes #163.

ParseResultBytes.authority called encode() on self.reference.authority without a None check. For any reference without an authority (/a, a, mailto:x, ?q) unsplit() and copy_with() raised AttributeError, while ParseResult handles the same input and returns None.

The property now returns None when the reference has no authority, and its return type is Optional[bytes], matching ParseResult.authority.

Test: test_unsplit_reference_without_authority round-trips five such references through both classes. Three of its cases fail without the change and all pass with it. The rest of the suite is unchanged. I also added a line to unreleased.rst.

ParseResultBytes.authority called encode() on None, so unsplit() and copy_with() raised AttributeError for any reference with no authority, while ParseResult returned None. Return None in that case. Fixes python-hyper#163.

Signed-off-by: mayuriphad <mayuriphad656@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 03:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

ParseResultBytes.unsplit() raises AttributeError for a reference without an authority

2 participants