From 05daf0dce20d1c601e98a18c05e091b82704b036 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Tue, 11 Mar 2025 08:07:39 +0400 Subject: [PATCH 1/2] Remove `python -m pickle -t` --- Lib/pickle.py | 33 ++++++------------- Lib/test/test_pickle.py | 2 +- ...5-03-11-08-07-07.gh-issue-93096.DyPXUX.rst | 2 ++ 3 files changed, 13 insertions(+), 24 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-03-11-08-07-07.gh-issue-93096.DyPXUX.rst diff --git a/Lib/pickle.py b/Lib/pickle.py index 8afb4aa4285f37..8f7406d2534f2c 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -1906,10 +1906,6 @@ def _loads(s, /, *, fix_imports=True, encoding="ASCII", errors="strict", Pickler, Unpickler = _Pickler, _Unpickler dump, dumps, load, loads = _dump, _dumps, _load, _loads -# Doctest -def _test(): - import doctest - return doctest.testmod() if __name__ == "__main__": import argparse @@ -1918,24 +1914,15 @@ def _test(): parser.add_argument( 'pickle_file', nargs='*', help='the pickle file') - parser.add_argument( - '-t', '--test', action='store_true', - help='run self-test suite') - parser.add_argument( - '-v', action='store_true', - help='run verbosely; only affects self-test run') args = parser.parse_args() - if args.test: - _test() + if not args.pickle_file: + parser.print_help() else: - if not args.pickle_file: - parser.print_help() - else: - import pprint - for fn in args.pickle_file: - if fn == '-': - obj = load(sys.stdin.buffer) - else: - with open(fn, 'rb') as f: - obj = load(f) - pprint.pprint(obj) + import pprint + for fn in args.pickle_file: + if fn == '-': + obj = load(sys.stdin.buffer) + else: + with open(fn, 'rb') as f: + obj = load(f) + pprint.pprint(obj) diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index 4ec966d8351490..385b257164ef95 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -700,7 +700,7 @@ def test_multiprocessing_exceptions(self): def load_tests(loader, tests, pattern): - tests.addTest(doctest.DocTestSuite()) + tests.addTest(doctest.DocTestSuite(pickle)) return tests diff --git a/Misc/NEWS.d/next/Library/2025-03-11-08-07-07.gh-issue-93096.DyPXUX.rst b/Misc/NEWS.d/next/Library/2025-03-11-08-07-07.gh-issue-93096.DyPXUX.rst new file mode 100644 index 00000000000000..919cc43cd6b200 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-03-11-08-07-07.gh-issue-93096.DyPXUX.rst @@ -0,0 +1,2 @@ +Removed undocumented ``-t`` and ``-v`` arguments of ``python -m pickle``. +Use ``python -m doctest Lib/pickle.py -v`` instead. Patch by Semyon Moroz. From f6f4e1865f9f95f9e9411d255d1ba17c005c413b Mon Sep 17 00:00:00 2001 From: donBarbos Date: Tue, 11 Mar 2025 12:09:34 +0400 Subject: [PATCH 2/2] Revert adding doctest to unittests --- Lib/test/test_pickle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index 385b257164ef95..4ec966d8351490 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -700,7 +700,7 @@ def test_multiprocessing_exceptions(self): def load_tests(loader, tests, pattern): - tests.addTest(doctest.DocTestSuite(pickle)) + tests.addTest(doctest.DocTestSuite()) return tests