gh-140950: Read pushed shlex source after EOF #144560
Open
+13
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
shlex.push_source()so pushing a new source after EOF can continue tokenization.test_push_source_after_eofinLib/test/test_shlex.pycovering both POSIX and non-POSIX modes.gh-140950.Repro
Verification
python -m py_compile Lib/shlex.py Lib/test/test_shlex.pypython -c "import importlib.util, sys, unittest; shlex_spec=importlib.util.spec_from_file_location('shlex', r'D:\Code\cpython\Lib\shlex.py'); shlex_mod=importlib.util.module_from_spec(shlex_spec); shlex_spec.loader.exec_module(shlex_mod); sys.modules['shlex']=shlex_mod; test_spec=importlib.util.spec_from_file_location('test_shlex_local', r'D:\Code\cpython\Lib\test\test_shlex.py'); test_mod=importlib.util.module_from_spec(test_spec); test_spec.loader.exec_module(test_mod); suite=unittest.TestSuite([test_mod.ShlexTest('test_push_source_after_eof')]); result=unittest.TextTestRunner(verbosity=2).run(suite); raise SystemExit(0 if result.wasSuccessful() else 1)"