mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
gh-131178: Add tests for pickle
command-line interface (#131275)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
dbfc6a417a
commit
f247e1d04c
2 changed files with 64 additions and 5 deletions
|
@ -1907,7 +1907,7 @@ except ImportError:
|
|||
dump, dumps, load, loads = _dump, _dumps, _load, _loads
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def _main(args=None):
|
||||
import argparse
|
||||
import pprint
|
||||
parser = argparse.ArgumentParser(
|
||||
|
@ -1915,7 +1915,7 @@ if __name__ == "__main__":
|
|||
parser.add_argument(
|
||||
'pickle_file',
|
||||
nargs='+', help='the pickle file')
|
||||
args = parser.parse_args()
|
||||
args = parser.parse_args(args)
|
||||
for fn in args.pickle_file:
|
||||
if fn == '-':
|
||||
obj = load(sys.stdin.buffer)
|
||||
|
@ -1923,3 +1923,7 @@ if __name__ == "__main__":
|
|||
with open(fn, 'rb') as f:
|
||||
obj = load(f)
|
||||
pprint.pprint(obj)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
_main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue