Skip to content

[BUG] The "TelegramException" (and children) can't be unpickled #2105

@Delgan

Description

@Delgan

Steps to reproduce

Hi. I encountered a small issue with an user because it does not seem possible to pickle TelegramException exceptions and their descendants.

import pickle
from telegram.error import TelegramException

error = TelegramException("Foobar")
pickled = pickle.dumps(error)      # OK
unpikcled = pickle.loads(pickled)  # NOK
# TypeError: __init__() missing 1 required positional argument: 'message'

This is actually not new, many Python users have encountered this kind of problem by implementing custom exceptions:

Expected behaviour

The exception should be deserialized without issue.

Actual behaviour

A TypeError is raised.

Configuration

Operating System: Arch Linux
Version of Python, python-telegram-bot & dependencies:

python-telegram-bot 12.8 (0.5.3-0-gf31e971)
certifi 2020.06.20
Python 3.8.5 (default, Sep  5 2020, 10:50:12)  [GCC 10.2.0]

Logs

Not relevant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions