This library allows to unpickle data pickled with Python 3.5 (up to pickle prococol 4).
WARNING: Not all pickle opcodes are supported. The library was created from scratch and I only added opcodes that I encountered in my test data.
Use npm (or yarn):
npm install unpickle
const data = unpickle(<Buffer>)
The following example unpickles Django session from Redis:
import unpickle from 'unpickle'
async function getDjangoSession (sessionId) {
const data = await redis.getAsync('django.contrib.sessions.cache' + sessionId)
return unpickle(data)
}
git clone https://github.com/IlyaSemenov/node-unpickle.git
cd node-unpickle
yarn
npm test
s = b"\x80\x04\x95....."
import pickle; import pickletools; print(pickle.loads(s)); pickletools.dis(s)
PRs and general feedback are welcome.