← 输入框|github.com|刷新
Skip to content

gh-160761: Fix TypeError when pickling directly instantiated urllib.parse result objects - #160762

Open
austinaviv wants to merge 1 commit into
python:mainfrom
austinaviv:fix-urlparse-getstate-none
Open

austinaviv wants to merge 1 commit into
python:mainfrom
austinaviv:fix-urlparse-getstate-none

Conversation

@austinaviv

Copy link
Copy Markdown

Fixes gh-160761

When URL result objects (SplitResult, ParseResult, DefragResult, etc.) are instantiated directly rather than returned from urlsplit() or urlparse(), their _keep_empty attribute is not set.

In this case, super().__getstate__() returns None. _ResultBase.__getstate__() attempted to subscript state[1], causing TypeError: 'NoneType' object is not subscriptable.

This change checks if state is not None before accessing state[1], and adds tests verifying that all result types can be pickled when created directly.

@python-cla-bot

python-cla-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError when pickling directly instantiated urllib.parse result objects

1 participant