diff options
| author | Victor Stinner <vstinner@python.org> | 2022-07-04 13:29:19 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-04 13:29:19 (GMT) |
| commit | fbcee570d1e15e5260a456cb71c8b0897dc76237 (patch) | |
| tree | 0f59827fabc49ed3e88724ed3bbcced7ff4fe8f3 /Lib | |
| parent | 670f7f10cf9cd7bdde9e62660d85506823f5bf7c (diff) | |
| download | cpython-fbcee570d1e15e5260a456cb71c8b0897dc76237.zip cpython-fbcee570d1e15e5260a456cb71c8b0897dc76237.tar.gz cpython-fbcee570d1e15e5260a456cb71c8b0897dc76237.tar.bz2 | |
gh-94352: shlex.split() no longer accepts None (#94353)
shlex.split(): Passing None for s argument now raises an exception,
rather than reading sys.stdin. The feature was deprecated in Python
3.9.
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/shlex.py | 4 | ||||
| -rw-r--r-- | Lib/test/test_shlex.py | 5 |
2 files changed, 3 insertions, 6 deletions
diff --git a/Lib/shlex.py b/Lib/shlex.py index 4801a6c..a91c9b0 100644 --- a/Lib/shlex.py +++ b/Lib/shlex.py @@ -305,9 +305,7 @@ class shlex: 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: diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py index 3081a78..92598db 100644 --- a/Lib/test/test_shlex.py +++ b/Lib/test/test_shlex.py @@ -162,9 +162,8 @@ class ShlexTest(unittest.TestCase): 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) def testSplitPosix(self): |
