Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Exception picklable #169

Merged
merged 1 commit into from
Nov 2, 2020
Merged

Conversation

azat
Copy link
Contributor

@azat azat commented Oct 26, 2020

There is a bug in pickle 1, due to which it cannot dump Exception
subclasses with different super() args:

Simple reproducer:

In [29]: import clickhouse_driver.errors as err

In [30]: pickle.loads(pickle.dumps(err.ServerException(message='foo', code=1, nested=Exception('foo'))))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-30-6d4a4869bbeb> in <module>
----> 1 pickle.loads(pickle.dumps(err.ServerException(message='foo', code=1, nested=Exception('foo'))))

TypeError: __init__() missing 2 required positional arguments: 'message' and 'code'

There is a bug in pickle [1], due to which it cannot dump Exception
subclasses with different super() args:

Simple reproducer:

    In [29]: import clickhouse_driver.errors as err

    In [30]: pickle.loads(pickle.dumps(err.ServerException(message='foo', code=1, nested=Exception('foo'))))
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-30-6d4a4869bbeb> in <module>
    ----> 1 pickle.loads(pickle.dumps(err.ServerException(message='foo', code=1, nested=Exception('foo'))))

    TypeError: __init__() missing 2 required positional arguments: 'message' and 'code'

  [1]: https://bugs.python.org/issue37287
@xzkostyan xzkostyan merged commit ab7dde0 into mymarilyn:master Nov 2, 2020
xzkostyan added a commit that referenced this pull request Nov 2, 2020
xzkostyan added a commit that referenced this pull request Nov 3, 2020
xzkostyan added a commit that referenced this pull request Nov 3, 2020
xzkostyan added a commit that referenced this pull request Nov 3, 2020
@azat azat deleted the Exception-picke-fix branch November 25, 2020 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants