0.2.0 • Published 6 years ago

unpickle v0.2.0

Weekly downloads
44
License
MIT
Repository
github
Last release
6 years ago

Unpickle Python data in Node.js

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.

Installation

Use npm (or yarn):

npm install unpickle

Usage

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)
}

Testing

git clone https://github.com/IlyaSemenov/node-unpickle.git
cd node-unpickle
yarn
npm test

How to inspect pickle in Python

s = b"\x80\x04\x95....."
import pickle; import pickletools; print(pickle.loads(s)); pickletools.dis(s)

Contributing

PRs and general feedback are welcome.

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago