-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Steps to reproduce
-
run a bot using python-telegram-bot <13 (in my case, 12.8) and store some
uuid.UUIDinstances in an user'suser_data, and configure the bot to serialize temp data to a pickle file usingPicklePersistence -
use the
PicklePersistencemigration script linked in the wiki against your pickle file generated by ptb <13
Expected behaviour
The pickle file migration is successfull
Actual behaviour
Running the script raises an exception. Here's the full traceback:
Traceback (most recent call last):
File "C:/Users/redacted/PycharmProjects/sticker-thief/convert_pp_13.1.py", line 92, in <module>
persistence.get_user_data()
File "C:\Users\redacted\PycharmProjects\sticker-thief\venv\lib\site-packages\telegram\ext\basepersistence.py", line 136, in get_user_data_insert_bot
return instance.insert_bot(get_user_data())
File "C:\Users\redacted\PycharmProjects\sticker-thief\venv\lib\site-packages\telegram\ext\basepersistence.py", line 310, in insert_bot
return self._insert_bot(obj, {})
File "C:\Users\redacted\PycharmProjects\sticker-thief\venv\lib\site-packages\telegram\ext\basepersistence.py", line 364, in _insert_bot
new_obj[self._insert_bot(k, memo)] = self._insert_bot(val, memo)
File "C:\Users\redacted\PycharmProjects\sticker-thief\venv\lib\site-packages\telegram\ext\basepersistence.py", line 364, in _insert_bot
new_obj[self._insert_bot(k, memo)] = self._insert_bot(val, memo)
File "C:\Users\redacted\PycharmProjects\sticker-thief\venv\lib\site-packages\telegram\ext\basepersistence.py", line 364, in _insert_bot
new_obj[self._insert_bot(k, memo)] = self._insert_bot(val, memo)
File "C:\Users\redacted\PycharmProjects\sticker-thief\venv\lib\site-packages\telegram\ext\basepersistence.py", line 369, in _insert_bot
setattr(new_obj, attr_name, self._insert_bot(attr, memo))
File "C:\Users\redacted\AppData\Local\Programs\Python\Python36-32\lib\uuid.py", line 224, in __setattr__
raise TypeError('UUID objects are immutable')
TypeError: UUID objects are immutable
The exception is raised because UUID object don't want the user to use __setattr__ (the exception is raised by uuid.UUID().__setattr__()), which is what the migration script explicitly uses at line 75 - but the exception is actually raised first, when the script uses PicklePersistence().get_user_data() (which calls BasePersistence.insert_bot(), which will try to recursively inject a new attribute to every object that has a __dict__ attribute (link to code), such as UUID instances)
Related thread in the group chat: https://t.me/pythontelegrambotgroup/487577
Configuration
Operating System: Widnows 10
Version of Python, python-telegram-bot & dependencies:
$ python -m telegram
python-telegram-bot 13.6
Bot API 5.2
certifi 2019.09.11
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)]
Logs
Insert logs here (if necessary)