8000 gh-93096: Remove `-t` and `-v` flags from `pickle` cli by donBarbos · Pull Request #131068 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-93096: Remove -t and -v flags from pickle cli #131068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2025
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
8000
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
0