cloudpipe / cloudpipe/cloudpickle

Chained exception lost in round trip

Open
#248 15 comments 2 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
Python
Stars
1.9k
Forks
195
Avg merge
1d 10h
Merged PRs (30d)
1

Description

It seems that a round trip through cloudpickle results in chained exceptions being dropped. Here's an example below.

```python
In [1]: import cloudpickle

In [2]: cloudpickle.__version__
Out[2]: '0.7.0'

In [3]: def raise_twice():
...: try:
...: raise RuntimeError("Oops 1")
...: except Exception as ex:
...: raise RuntimeError("Oops 2") from ex
...:

In [4]: try:
...: raise_twice()
...: except Exception as e:
...: ex = e
...:

In [5]: raise ex
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
in raise_twice()
2 try:
----> 3 raise RuntimeError("Oops 1")
4 except Exception as ex:

RuntimeError: Oops 1

The above exception was the direct cause of the following exception:

RuntimeError Traceback (most recent call last)
in
----> 1 raise ex

in
1 try:
----> 2 raise_twice()
3 except Exception as e:
4 ex = e
5

in raise_twice()
3 raise RuntimeError("Oops 1")
4 except Exception as ex:
----> 5 raise RuntimeError("Oops 2") from ex
6

RuntimeError: Oops 2

In [6]: raise cloudpickle.loads(cloudpickle.dumps(ex))
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
in
----> 1 raise cloudpickle.loads(cloudpickle.dumps(ex))

RuntimeError: Oops 2
```


xref: https://github.com/dask/dask/issues/4384

cc @stuarteberg

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.