pyvsc icon indicating copy to clipboard operation
pyvsc copied to clipboard

PicklingError when trying to pickle a VSC randobj

Open smccans opened this issue 1 year ago • 2 comments

Is it possible to pickle a class that has the @vsc.randobj decorator? I get a PicklingError when trying to do something like this code below. Using the dill module instead of pickle results in the same error.

import vsc
import pickle

@vsc.randobj
class Sample():
    pass

obj = Sample()
string = pickle.dumps(obj)

Running that results in this error:

Traceback (most recent call last):
  File "test_vsc.py", line 10, in <module>
    string = pickle.dumps(obj)
_pickle.PicklingError: Can't pickle <class 'vsc.rand_obj.Sample'>: attribute lookup Sample on vsc.rand_obj failed

smccans avatar May 23 '23 19:05 smccans