-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-127079, pickletools: Remove check for items on stack #127080
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
base: main
Are you sure you want to change the base?
Conversation
@@ -2539,8 +2539,6 @@ def dis(pickle, out=None, memo=None, indentlevel=4, annotate=0): | |||
stack.extend(after) | |||
|
|||
print("highest protocol among opcodes =", maxproto, file=out) | |||
if stack: | |||
raise ValueError("stack not empty after STOP: %r" % stack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if removing the exception makes sense or not. But if we decide to change the code, I would prefer to keep the information: maybe replace raise ValueError()
with print()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that exception is raised after printing all output. You do not lose any information. You can catch and ignore this exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so we're not worried about this then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can catch and ignore this exception.
It's not easy when using pickletools CLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using CLI you get some output. Whether it a Python traceback or a single line, -- it does not matter much, since such case is exceptional. The CLI output is not formalized, anything is fine.
We could add a mechanism for outputting non-critical errors, but since this particular error is raised after finishing all output, it would not make much difference.
This check in In effect, |
|
Yup, I agree that no code here is 100% reliable. At one time there was some faint hope that the pickle format could be made 100% "secure", but
in the docs now. Which isn't really the same thing, but related. One way in which |
Removed the check to see if there's more than one item on the stack when the
STOP
opcode is reached, as this isn't enforced by pickle.