Skip to content

Commit 6fc2901

Browse files
fixups
1 parent 01809a9 commit 6fc2901

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Lib/test/test_urlparse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ def test_mixed_types_rejected(self):
12571257

12581258
def test_non_string_true_values_rejected(self):
12591259
# True values raise informative TypeErrors
1260-
msg = "Expected a string or bytes object: got <class "
1260+
msg = "Expected a string, bytes, or None: got <class "
12611261
with self.assertRaisesRegex(TypeError, msg):
12621262
urllib.parse.urlsplit(1, b'http')
12631263

@@ -1998,12 +1998,12 @@ def test_falsey_deprecation(self):
19981998
cases = [
19991999
(urllib.parse.urljoin, ['http://www.python.org', []]),
20002000
(urllib.parse.urljoin, [[], b'docs']),
2001-
(urllib.parse.urlparse, [b'www.python.org', None]),
2001+
(urllib.parse.urlparse, [b'www.python.org', {}]),
20022002
(urllib.parse.urlparse, [{}, '']),
20032003
(urllib.parse.urlsplit, [0, b'http']),
2004-
(urllib.parse.urlsplit, [b'http://www.python.org', None]),
2004+
(urllib.parse.urlsplit, [b'http://www.python.org', 0]),
20052005
(urllib.parse.urldefrag, [{}]),
2006-
(urllib.parse.urlunparse, [[None, b'www.python.org', None, None, None, None]]),
2006+
(urllib.parse.urlunparse, [[None, b'www.python.org', (), (), (), ()]]),
20072007
(urllib.parse.urlunsplit, [['http', 0, '', '', '']]),
20082008
]
20092009
for callable, args in cases:

Lib/urllib/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _coerce_args(*args):
134134
raise TypeError("Cannot mix str and non-str arguments")
135135
if str_input is False and arg is not None and not hasattr(arg, "decode"):
136136
raise TypeError(f"Expected a string, bytes, or None: got {type(arg)}")
137-
elif arg not in empty_values:
137+
elif arg is not None and arg != "" and arg != b"":
138138
warnings.warn(
139139
f"Providing false values other than empty strings, bytes, or"
140140
f"None to urllib.parse is deprecated: got {type(arg)}",

0 commit comments

Comments
 (0)