https://github.com/python/cpython/commit/3ddf983afda7173277666bb5f9033634e59363f8
commit: 3ddf983afda7173277666bb5f9033634e59363f8
branch: main
author: donBarbos <[email protected]>
committer: vstinner <[email protected]>
date: 2025-03-11T12:06:26+01:00
summary:
gh-93096: Remove `-t` and `-v` flags from `pickletools` cli (#131039)
Remove `python -m pickletools -t`
files:
A Misc/NEWS.d/next/Library/2025-03-10-14-44-04.gh-issue-93096.kmt59U.rst
M Lib/pickletools.py
diff --git a/Lib/pickletools.py b/Lib/pickletools.py
index d9c4fb1e63e91a..02aad12985dafe 100644
--- a/Lib/pickletools.py
+++ b/Lib/pickletools.py
@@ -2838,9 +2838,6 @@ def __init__(self, value):
'disassembler_memo_test': _memo_test,
}
-def _test():
- import doctest
- return doctest.testmod()
if __name__ == "__main__":
import argparse
@@ -2865,36 +2862,27 @@ def _test():
'-p', '--preamble', default="==> {name} <==",
help='if more than one pickle file is specified, print this before'
' each disassembly')
- 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()
+ annotate = 30 if args.annotate else 0
+ memo = {} if args.memo else None
+ if args.output is None:
+ output = sys.stdout
else:
- annotate = 30 if args.annotate else 0
- memo = {} if args.memo else None
- if args.output is None:
- output = sys.stdout
- else:
- output = open(args.output, 'w')
- try:
- for arg in args.pickle_file:
- if len(args.pickle_file) > 1:
- name = '<stdin>' if arg == '-' else arg
- preamble = args.preamble.format(name=name)
- output.write(preamble + '\n')
- if arg == '-':
- dis(sys.stdin.buffer, output, memo, args.indentlevel,
annotate)
- else:
- with open(arg, 'rb') as f:
- dis(f, output, memo, args.indentlevel, annotate)
- finally:
- if output is not sys.stdout:
- output.close()
+ output = open(args.output, 'w')
+ try:
+ for arg in args.pickle_file:
+ if len(args.pickle_file) > 1:
+ name = '<stdin>' if arg == '-' else arg
+ preamble = args.preamble.format(name=name)
+ output.write(preamble + '\n')
+ if arg == '-':
+ dis(sys.stdin.buffer, output, memo, args.indentlevel,
annotate)
+ else:
+ with open(arg, 'rb') as f:
+ dis(f, output, memo, args.indentlevel, annotate)
+ finally:
+ if output is not sys.stdout:
+ output.close()
diff --git
a/Misc/NEWS.d/next/Library/2025-03-10-14-44-04.gh-issue-93096.kmt59U.rst
b/Misc/NEWS.d/next/Library/2025-03-10-14-44-04.gh-issue-93096.kmt59U.rst
new file mode 100644
index 00000000000000..7b85becc304410
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-03-10-14-44-04.gh-issue-93096.kmt59U.rst
@@ -0,0 +1,3 @@
+Removed undocumented ``-t`` and ``-v`` arguments of ``python -m
+pickletools``. Use ``python -m doctest Lib/pickletools.py -v`` instead.
+Patch by Semyon Moroz.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]