Skip to content

pre_checkout_query does not store bot. #937

@folarte

Description

@folarte

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)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy