The following minimal example uses a dummy decorator, that justs prints some message when an object of the decorated class is constructed.

```
import pickle

def decorate(message):
    def call_decorator(func):
        def wrapper(*args, **kwargs):
            print(message)
            return func(*args, **kwargs)

        return wrapper

    return call_decorator

@decorate('hi')
class Foo:
    pass

foo = Foo()
dump = pickle.dumps(foo) # Fails already here.
foo = pickle.loads(dump)

```

Using it however makes `pickle` raise the following exception:

```
_pickle.PicklingError: Can't pickle <class '__main__.Foo'>: it's not the same object as __main__.Foo

```

Is there anything I can do to fix this?