Commit 94fd26c
committed
Fix exception when unpickling operator objects
Discovered when debugging a deadlock when evaluating a roll in a process pool
executor. The use of the negate (-) operator was enough to trigger the bug.
Pickle is used to de/serialize data when communicating with worker processes,
but it was unable to reconstruct the operator object because of missing
arguments to `__new__`. Overriding the `__getnewargs__` method to return
the necessary arguments solved the problem, since the default is assumed to
be an empty tuple.
reprex:
```py
r = dice.roll('-d20', raw=True)
d = pickle.dumps(r)
pickle.loads(d)
```1 parent ab40709 commit 94fd26c
1 file changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
396 | 399 | | |
397 | 400 | | |
398 | 401 | | |
| |||
0 commit comments