Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions Lib/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
2 changes: 1 addition & 1 deletion Lib/test/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def test_multiprocessing_exceptions(self):


def load_tests(loader, tests, pattern):
tests.addTest(doctest.DocTestSuite())
tests.addTest(doctest.DocTestSuite(pickle))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this looks like a bugfix. It should be backported. Can you extract this change into a new PR? It's not directly related to CLI changes.

Copy link
Contributor Author

@donBarbos donBarbos Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure, should i open new issue or can i send PR for the current issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can reuse the same issue.

return tests


Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Loading