-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
Steps to reproduce
-
On a PreChecoutQueryHandler, get the PreCheckoutQuery object update.pre_checkout_query
-
Try to answer it, bot has not been set:
File "/home/folarte/sexychat/nor File "/home/folarte/sexychat/normalstate.py", line 998, in on_pcoq
pcoq.answer(ok=True)
File "/home/folarte/venv-sxc/local/lib/python3.6/site-packages/telegram/payment/precheckoutquery.py", line 115, in answer
return self.bot.answer_pre_checkout_query(self.id, *args, **kwargs)
AttributeError: 'NoneType' object has no attribute 'answer_pre_checkout_query'
malstate.py", line 998, in on_pcoq
pcoq.answer(ok=True)
File "/home/folarte/venv-sxc/local/lib/python3.6/site-packages/telegram/payment/precheckoutquery.py", line 115, in answer
return self.bot.answer_pre_checkout_query(self.id, *args, **kwargs)
AttributeError: 'NoneType' object has no attribute 'answer_pre_checkout_query'
Expected behaviour
pcoq.bot should contain the bot object.
Actual behaviour
bot object is not set. Thi is due to the de_json function being:
@classmethod
def de_json(cls, data, bot):
if not data:
return None
data = super(PreCheckoutQuery, cls).de_json(data, bot)
data['from_user'] = User.de_json(data.pop('from'), bot)
data['order_info'] = OrderInfo.de_json(data.get('order_info'), bot)
return cls(**data)
When the last call should pass the bot to the constructor, as done in the callbackquery object:
return cls(bot=bot, **data)
When editing the line to these, it works fine.
Do not know GIT, can try to do it, but it is a trivial fix, probably a typo.
Configuration
Amazon Linux, aws instance.
$ python -m telegram
python-telegram-bot 9.0.0
certifi 2017.11.05
future 0.16.0
Python 3.6.2 (default, Nov 2 2017, 19:34:31) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]