Skip to content

Commit

Permalink
fix: protect threading.Lock in AsObjects when serializing (#1200)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski committed Apr 25, 2024
1 parent a9e4263 commit dc69e3d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/uproot/interpretation/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ def __repr__(self):
def __eq__(self, other):
return isinstance(other, AsObjects) and self._model == other._model

def __getstate__(self):
return {
k: (
uproot.model._LockPlaceholder()
if isinstance(v, uproot.model._LockPlaceholder.lock_type)
else v
)
for k, v in self.__dict__.items()
}

def __setstate__(self, state):
instance_data = {
k: threading.Lock() if isinstance(v, uproot.model._LockPlaceholder) else v
for k, v in state.items()
}
self.__dict__.update(instance_data)

@property
def numpy_dtype(self):
return numpy.dtype(object)
Expand Down

0 comments on commit dc69e3d

Please sign in to comment.