From b15e26758ddd618bcd24d3327adc7cbf98be0d1b Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Tue, 15 Jul 2025 13:52:02 +0300 Subject: [PATCH] Update shlex from 3.13.5 --- Lib/shlex.py | 9 ++------- Lib/test/test_shlex.py | 14 ++++++-------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Lib/shlex.py b/Lib/shlex.py index 4801a6c1d4..f4821616b6 100644 --- a/Lib/shlex.py +++ b/Lib/shlex.py @@ -305,9 +305,7 @@ def __next__(self): def split(s, comments=False, posix=True): """Split the string *s* using shell-like syntax.""" if s is None: - import warnings - warnings.warn("Passing None for 's' to shlex.split() is deprecated.", - DeprecationWarning, stacklevel=2) + raise ValueError("s argument must not be None") lex = shlex(s, posix=posix) lex.whitespace_split = True if not comments: @@ -335,10 +333,7 @@ def quote(s): def _print_tokens(lexer): - while 1: - tt = lexer.get_token() - if not tt: - break + while tt := lexer.get_token(): print("Token: " + repr(tt)) if __name__ == '__main__': diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py index c3d632a64c..baabccf19f 100644 --- a/Lib/test/test_shlex.py +++ b/Lib/test/test_shlex.py @@ -3,7 +3,6 @@ import shlex import string import unittest -from unittest import mock # The original test data set was from shellwords, by Hartmut Goebel. @@ -162,18 +161,17 @@ def oldSplit(self, s): tok = lex.get_token() return ret - @mock.patch('sys.stdin', io.StringIO()) - def testSplitNoneDeprecation(self): - with self.assertWarns(DeprecationWarning): + def testSplitNone(self): + with self.assertRaises(ValueError): shlex.split(None) - # TODO: RUSTPYTHON + # TODO: RUSTPYTHON; ValueError: Error Retrieving Value @unittest.expectedFailure def testSplitPosix(self): """Test data splitting with posix parser""" self.splitTest(self.posix_data, comments=True) - # TODO: RUSTPYTHON + # TODO: RUSTPYTHON; ValueError: Error Retrieving Value @unittest.expectedFailure def testCompat(self): """Test compatibility interface""" @@ -315,7 +313,7 @@ def testEmptyStringHandling(self): s = shlex.shlex("'')abc", punctuation_chars=True) self.assertEqual(list(s), expected) - # TODO: RUSTPYTHON + # TODO: RUSTPYTHON; ValueError: Error Retrieving Value @unittest.expectedFailure def testUnicodeHandling(self): """Test punctuation_chars and whitespace_split handle unicode.""" @@ -356,7 +354,7 @@ def testJoin(self): joined = shlex.join(split_command) self.assertEqual(joined, command) - # TODO: RUSTPYTHON + # TODO: RUSTPYTHON; ValueError: Error Retrieving Value @unittest.expectedFailure def testJoinRoundtrip(self): all_data = self.data + self.posix_data