Skip to content

Commit d5f6c5f

Browse files
generatedunixname1734921407115435facebook-github-bot
authored andcommitted
Import upstream CPython branch '3.14'
Summary: Python `3.14.0rc2+` (`3.14`) was **published** on 2025-09-13 18:29:50+00:00. # Commit Info Base: (`3.14.0rc2+`) - `fbfbfdf33c3cfe00c6319423ac69f5fb4e877034` (commit date: 2025-09-12 13:23:03+00:00) Imported: (`3.14.0rc2+`) - `3.14` (commit date: 2025-09-13 18:29:50+00:00) # Files added ``` Misc/NEWS.d/next/Library/2025-09-12-01-01-05.gh-issue-138804.46ZukT.rst ``` Reviewed By: itamaro Differential Revision: D82398872 fbshipit-source-id: 58e9d763dfcb2a4b4ad0ecc10b762b3249776090
1 parent ad010b4 commit d5f6c5f

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

Lib/shlex.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ def quote(s):
322322
if not s:
323323
return "''"
324324

325+
if not isinstance(s, str):
326+
raise TypeError(f"expected string object, got {type(s).__name__!r}")
327+
325328
# Use bytes.translate() for performance
326329
safe_chars = (b'%+,-./0123456789:=@'
327330
b'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'

Lib/test/test_shlex.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ def testQuote(self):
330330
unsafe = '"`$\\!' + unicode_sample
331331

332332
self.assertEqual(shlex.quote(''), "''")
333+
self.assertEqual(shlex.quote(None), "''")
333334
self.assertEqual(shlex.quote(safeunquoted), safeunquoted)
334335
self.assertEqual(shlex.quote('test file name'), "'test file name'")
335336
for u in unsafe:
@@ -338,6 +339,8 @@ def testQuote(self):
338339
for u in unsafe:
339340
self.assertEqual(shlex.quote("test%s'name'" % u),
340341
"'test%s'\"'\"'name'\"'\"''" % u)
342+
self.assertRaises(TypeError, shlex.quote, 42)
343+
self.assertRaises(TypeError, shlex.quote, b"abc")
341344

342345
def testJoin(self):
343346
for split_command, command in [
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
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+
the function prior to 3.14.

0 commit comments

Comments
 (0)