instance, passing ``None`` for *s* will read the string to split from
standard input.
- .. deprecated:: 3.9
- Passing ``None`` for *s* will raise an exception in future Python
- versions.
+ .. versionchanged:: 3.12
+ Passing ``None`` for *s* argument now raises an exception, rather than
+ reading :data:`sys.stdin`.
.. function:: join(split_command)
to :term:`filesystem encoding and error handler`.
Argument files should be encoded in UTF-8 instead of ANSI Codepage on Windows.
+* :func:`shlex.split`: Passing ``None`` for *s* argument now raises an
+ exception, rather than reading :data:`sys.stdin`. The feature was deprecated
+ in Python 3.9.
+ (Contributed by Victor Stinner in :gh:`94352`.)
+
Build Changes
=============
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:
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):
--- /dev/null
+:func:`shlex.split`: Passing ``None`` for *s* argument now raises an exception,
+rather than reading :data:`sys.stdin`. The feature was deprecated in Python
+3.9. Patch by Victor Stinner.