Skip to content

Commit bd6a959

Browse files
committed
post review
1 parent 89e0164 commit bd6a959

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Lib/shlex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def join(split_command):
320320
def quote(s):
321321
"""Return a shell-escaped version of the string *s*."""
322322
if not isinstance(s, str):
323-
raise TypeError(f"expected str, not {type(s)!r}")
323+
raise TypeError(f"expected string object, got {type(s).__name__!r}")
324324

325325
if not s:
326326
return "''"

Lib/test/test_shlex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ def testQuote(self):
338338
for u in unsafe:
339339
self.assertEqual(shlex.quote("test%s'name'" % u),
340340
"'test%s'\"'\"'name'\"'\"''" % u)
341-
with self.assertRaises(TypeError):
342-
shlex.quote(42)
341+
self.assertRaises(TypeError, shlex.quote, 42)
342+
self.assertRaises(TypeError, shlex.quote, b"abc")
343343

344344
def testJoin(self):
345345
for split_command, command in [
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
Check argument passed to ``shlex.quote`` to be a string
1+
Raise :exc:`TypeError` instead of :exc:`AttributeError` when an argument of
2+
incorrect type is passed to :func:`shlex.quote`. This restores the behavior of
3+
that function pre-3.14.

0 commit comments

Comments
 (0)