Skip to content

Instantly share code, notes, and snippets.

@lucasb-eyer
Created April 4, 2016 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasb-eyer/377c6de3bc0c882516f33e228722104d to your computer and use it in GitHub Desktop.
Save lucasb-eyer/377c6de3bc0c882516f33e228722104d to your computer and use it in GitHub Desktop.
class Dummy():
def __init__(self, *a, **kw):
pass
def __setstate__(self, *a, **kw):
pass
def __getstate__(self, *a, **kw):
pass
class RestrictedUnpickler(pickle.Unpickler):
def find_class(self, module, name):
print(module, name)
if module.startswith("DeepFried2") or module.startswith("theano"):
return Dummy
return pickle.Unpickler.find_class(self, module, name)
RestrictedUnpickler(open('/tmp/lucfootmp.pkl', 'rb')).load()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment