-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
🐛 bug
Copy link
Description
Steps to Reproduce
- Set up virtualenv using
python3 -m venvon a 64-bit machine. - Initialize an
applicationobject usingtelegram.ext.ApplicationBuilder:
from telegram.ext import ApplicationBuilder
def main() -> None:
application = ApplicationBuilder().token("TOKEN").build()
if __name__ == "__main__":
main()- Run the bot in virtualenv and it will give a warning messgae like
PTBUserWarning: `Application` instances should be built via the `ApplicationBuilder`.
Expected behaviour
The warning message shouldn't be given since ApplicationBuilder is being used.
Actual behaviour
$ python test.py
../venv/lib64/python3.11/site-packages/telegram/ext/_applicationbuilder.py:292:
PTBUserWarning: `Application` instances should be built via the `ApplicationBuilder`.
] = DefaultValue.get_value( # pylint: disable=not-callableOperating System
Fedora Linux 37 (Server Edition)
Version of Python, python-telegram-bot & dependencies
python-telegram-bot 20.0
Bot API 6.4
Python 3.11.1 (main, Dec 7 2022, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]Relevant log output
No response
Additional Context
I believe this is caused by comparing a resolved path with an unresolved path here.
In my case, it finds ../venv/lib/python3.11/site-packages/telegram/ext/_applicationbuilder.py not equal to ../venv/lib64/python3.11/site-packages/telegram/ext/_applicationbuilder.py, the directory lib64 being a symlink to lib.
A quick (maybe not final) fix is to modify stack.py so that was_called_by always resolves paths from frame:
while frame.f_back:
frame = frame.f_back
if Path(frame.f_code.co_filename).resolve() == caller:
return TrueI have tested it and the warning no longer appears.
Metadata
Metadata
Assignees
Labels
No labels