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

Unhandled opcode '128' #9

Open
foxt opened this issue Mar 20, 2021 · 4 comments
Open

Unhandled opcode '128' #9

foxt opened this issue Mar 20, 2021 · 4 comments

Comments

@foxt
Copy link

foxt commented Mar 20, 2021

Hi, I'm trying to decode Pickle'd objects in JS.

Running the following code works

pickle.loads(open("test2.bin","rb").read(),encoding='latin1')

However this does not

var f = Pickle.loads(AUint8Array)

I get ` Unhandled opcode '128' (the file starts with 80 02 7D 71 01 28 58 17 00 00 00)

Any help would be appreciated.

@foxt
Copy link
Author

foxt commented Mar 20, 2021

Fixed by replacing the switch (opcode) with switch (String.fromCharCode(opcode))

This could be a weird WebJS/NodeJS incompatibility.

[...]
        var opindex = i
          , opcode = pickle[i++];
        //console.log('opcode ' + opindex + ' ' + opcode);
        switch (String.fromCharCode(opcode)) {
            // protocol 2
            case PROTO:
[...]

@foxt
Copy link
Author

foxt commented Dec 21, 2021

fix in #13

@foxt foxt closed this as completed Dec 21, 2021
@boltex
Copy link

boltex commented Nov 17, 2023

@foxt you should reopen this as its not merged yet!

@foxt foxt reopened this Nov 17, 2023
@boltex
Copy link

boltex commented Nov 18, 2023

@foxt oops, I thought you were on to something but I did this in my code and I understood why the existing codebase is ok. :

val = pickle.loads(String.fromCharCode(...inflated));

(inflated is the content I had retrived from some source, which was not exactly like pickle.loads required)

Your well intentioned pull request is not relevant anymore. (Sorry i distracted you with this earlier today) I also thought it was, but after reading about how to convert binary data to the proper format that pickle.loads requires made me realize It was ok all along and i was the one who misunderstood the codebase of jpickle.

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

No branches or pull requests

2 participants