8000 Update pickle from CPython 3.12.3 by youknowone · Pull Request #5260 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Update pickle from CPython 3.12.3 #5260

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 3 commits into from
Apr 23, 2024
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
Prev Previous commit
Update pickletools from CPython 3.12.3
  • Loading branch information
CPython Developers authored and youknowone committed Apr 23, 2024
commit d0f680b37995fac942dd00087fc2e19a50ad0e48
33 changes: 22 additions & 11 deletions Lib/pickletools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ def __init__(self, name, code, arg,
stack_before=[],
stack_after=[pyint],
proto=2,
doc="""Long integer using found-byte length.
doc="""Long integer using four-byte length.

A more efficient encoding of a Python long; the long4 encoding
says it all."""),
Expand Down Expand Up @@ -2848,10 +2848,10 @@ def _test():
parser = argparse.ArgumentParser(
description='disassemble one or more pickle files')
parser.add_argument(
'pickle_file', type=argparse.FileType('br'),
'pickle_file',
nargs='*', help='the pickle file')
parser.add_argument(
'-o', '--output', default=sys.stdout, type=argparse.FileType('w'),
'-o', '--output',
help='the file where the output should be written')
parser.add_argument(
'-m', '--memo', action='store_true',
Expand All @@ -2876,15 +2876,26 @@ def _test():
if args.test:
_test()
else:
annotate = 30 if args.annotate else 0
if not args.pickle_file:
parser.print_help()
elif len(args.pickle_file) == 1:
dis(args.pickle_file[0], args.output, None,
args.indentlevel, annotate)
else:
annotate = 30 if args.annotate else 0
memo = {} if args.memo else None
for f in args.pickle_file:
preamble = args.preamble.format(name=f.name)
args.output.write(preamble + '\n')
dis(f, args.output, memo, args.indentlevel, annotate)
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()
2 changes: 0 additions & 2 deletions Lib/test/test_pickletools.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ def loads(self, buf, **kwds):
# Test relies on writing by chunks into a file object.
test_framed_write_sizes_with_delayed_writer = None

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_optimize_long_binget(self):
data = [str(i) for i in range(257)]
data.append(data[-1])
Expand Down
0