node-jpickle
node-jpickle copied to clipboard
Unhandled opcode '128'
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.
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:
[...]
fix in #13
@foxt you should reopen this as its not merged yet!
@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.