Skip to content
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

Add support for BININT and LONG1 opcodes #13

Merged
merged 2 commits into from Jan 11, 2022
Merged

Add support for BININT and LONG1 opcodes #13

merged 2 commits into from Jan 11, 2022

Conversation

suhacker1
Copy link
Collaborator

This PR fixes #11 and #12.

Prior to this PR, the following code snippet raises NotImplementedError: TODO: Add support for Opcode BININT.

import pickle 
import pickletools
from fickling.pickle import Pickled
F = -3
yes = pickletools.dis(pickle.dumps(F))
fickled_payload = Pickled.load(pickle.dumps(F))
safety = fickled_payload.is_likely_safe
print(safety)

This other code snippet similarly raises NotImplementedError: TODO: Add support for Opcode LONG1.

import pickle 
import pickletools
from fickling.pickle import Pickled
F = 2**123 
yes = pickletools.dis(pickle.dumps(F))
fickled_payload = Pickled.load(pickle.dumps(F))
safety = fickled_payload.is_likely_safe
print(safety)

With this PR, these are the new outputs.

0: \x80 PROTO      3
    2: J    BININT     -3
    7: .    STOP
highest protocol among opcodes = 2
True
0: \x80 PROTO      3
    2: \x8a LONG1      10633823966279326983230456482242756608
   20: .    STOP
highest protocol among opcodes = 2
True

@ESultanik ESultanik self-requested a review January 11, 2022 13:45
@ESultanik ESultanik merged commit 3f6a21f into master Jan 11, 2022
@ESultanik ESultanik deleted the new_ops branch January 11, 2022 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NotImplementedError: TODO: Add support for Opcode LONG1
2 participants