diff --git a/webapp/graphite/util.py b/webapp/graphite/util.py index 0b5727a9d..4c980cf79 100644 --- a/webapp/graphite/util.py +++ b/webapp/graphite/util.py @@ -187,6 +187,8 @@ def load(cls, file): pickle_obj.find_global = cls.find_class return pickle_obj.load() + unpickle = SafeUnpickler + else: class SafeUnpickler(pickle.Unpickler): PICKLE_SAFE = { @@ -206,15 +208,14 @@ def find_class(self, module, name): raise pickle.UnpicklingError('Attempting to unpickle unsafe class %s' % name) return getattr(mod, name) - @classmethod - def loads(cls, pickle_string): - return cls(StringIO(pickle_string)).load() - - @classmethod - def load(cls, file): - return cls(file).load() + class unpickle(object): + @staticmethod + def loads(pickle_string): + return SafeUnpickler(StringIO(pickle_string)).load() -unpickle = SafeUnpickler + @staticmethod + def load(file): + return SafeUnpickler(file).load() class Timer(object):