Skip to content

gh-93096: Remove -t and -v flags from pickletools cli #131039

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 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
54 changes: 21 additions & 33 deletions Lib/pickletools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Original file line number Diff line number Diff line change
@@ -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.
Loading