TrustedPickle not working?

132 views Asked by At

On the UsingPickle article on Python Wiki it suggests using TrustedPickle in order to give more protection to Pickle files through looking for authorised signatures and keys.

I downloaded TrustedPickle 0.01 and installed it as instructed by putting the TrustedPickle.py script iin C:\Python33\Lib\site-packages.

However, following the steps in order to use TrustedPickle, the module doesn't work.

I've opened the script and tried running it and it comes up with invalid syntax and it pointing to Line 142 and Column 22. Can someone look at the script and see what's wrong? This script is too far out of my depth to solve myself.

You can download the script here: http://sourceforge.net/projects/trustedpickle/files/trustedpickle/0.01/

I've tried 0.02 and that doesn't work either.

1

There are 1 answers

9
jonrsharpe On

The line in question is:

x1, Key, y1, y2 = 0L, 1L, 1L, 0L

The trailing L (for "long") is invalid syntax in Python 3; it is unnecessary, as Python 3's int now covers both int and long from Python 2.x.

In short, it appears that the library does not support Python 3.x. The following modifications to trusted_pickle.py:

  • remove all trailing Ls from numbers;
  • remove import sets and replace all sets.Set( with set(;
  • replace all long( with int(;
  • replace import md5 with import hashlib and replace md5.md5(String) with hashlib.md5(String.encode()); and
  • replace raw_input( with input(;

allow the library to import in Python 3.x. However, I have not tested that it actually works with these changes.