Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Lib/test/test_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,11 @@ def check(result):
check(func(burl))
check(func(burl, missing_as_none=True))

for cls in (urllib.parse.DefragResult, urllib.parse.SplitResult, urllib.parse.ParseResult):
check(cls(*[''] * len(cls._fields)))
for cls in (urllib.parse.DefragResultBytes, urllib.parse.SplitResultBytes, urllib.parse.ParseResultBytes):
check(cls(*[b''] * len(cls._fields)))

def test_result_compat_unpickling(self):
def check(result, pickles):
for pickled in pickles:
Expand Down
2 changes: 2 additions & 0 deletions Lib/urllib/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ def __deepcopy__(self, memo):

def __getstate__(self):
state = super().__getstate__()
if state is None:
return None
Comment thread
austinaviv marked this conversation as resolved.
try:
if state[1]['_keep_empty'] == _MISSING_AS_NONE_DEFAULT:
del state[1]['_keep_empty']
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :exc:`TypeError` when pickling directly instantiated :mod:`urllib.parse` result objects.
Loading