prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [BUG] telegram.ext._utils.stack.was_called_by gives incorrect result on 64-bit machine
  ### Steps to Reproduce
  
  1. Set up virtualenv using `python3 -m venv` on a 64-bit machine.
  2. Initialize an `application` object using `telegram.ext.ApplicationBuilder`:
  ``` python
  from telegram.ext import ApplicationBuilder
  def main() -> None:
      application = ApplicationBuilder().token("TOKEN").build()
  
  if __name__ == "__main__":
      main()
  ```
  4. 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
  
  ``` bash
  $ 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-callable
  ```
  
  
  
  ### Operating System
  
  Fedora Linux 37 (Server Edition)
  
  ### Version of Python, python-telegram-bot & dependencies
  
  ```shell
  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](https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/ext/_application.py#L273). 
  
  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](https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/ext/_utils/stack.py) so that `was_called_by` always resolves paths from frame:
  ``` python
      while frame.f_back:
          frame = frame.f_back
          if Path(frame.f_code.co_filename).resolve() == caller:
              return True
  ```
  I have tested it and the warning no longer appears.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `telegram/ext/_utils/stack.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 #
  3 # A library that provides a Python interface to the Telegram Bot API
  4 # Copyright (C) 2015-2023
  5 # Leandro Toledo de Souza <devs@python-telegram-bot.org>
  6 #
  7 # This program is free software: you can redistribute it and/or modify
  8 # it under the terms of the GNU Lesser Public License as published by
  9 # the Free Software Foundation, either version 3 of the License, or
  10 # (at your option) any later version.
  11 #
  12 # This program is distributed in the hope that it will be useful,
  13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15 # GNU Lesser Public License for more details.
  16 #
  17 # You should have received a copy of the GNU Lesser Public License
  18 # along with this program.  If not, see [http://www.gnu.org/licenses/].
  19 """This module contains helper functions related to inspecting the program stack.
  20 
  21 .. versionadded:: 20.0
  22 
  23 Warning:
  24     Contents of this module are intended to be used internally by the library and *not* by the
  25     user. Changes to this module are not considered breaking changes and may not be documented in
  26     the changelog.
  27 """
  28 from pathlib import Path
  29 from types import FrameType
  30 from typing import Optional
  31 
  32 
  33 def was_called_by(frame: Optional[FrameType], caller: Path) -> bool:
  34     """Checks if the passed frame was called by the specified file.
  35 
  36     Example:
  37         .. code:: pycon
  38 
  39             >>> was_called_by(inspect.currentframe(), Path(__file__))
  40             True
  41 
  42     Arguments:
  43         frame (:obj:`FrameType`): The frame - usually the return value of
  44             ``inspect.currentframe()``. If :obj:`None` is passed, the return value will be
  45             :obj:`False`.
  46         caller (:obj:`pathlib.Path`): File that should be the caller.
  47 
  48     Returns:
  49         :obj:`bool`: Whether the frame was called by the specified file.
  50     """
  51     if frame is None:
  52         return False
  53 
  54     # https://stackoverflow.com/a/57712700/10606962
  55     if Path(frame.f_code.co_filename) == caller:
  56         return True
  57     while frame.f_back:
  58         frame = frame.f_back
  59         if Path(frame.f_code.co_filename) == caller:
  60             return True
  61     return False
  62
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/telegram/ext/_utils/stack.py b/telegram/ext/_utils/stack.py
  --- a/telegram/ext/_utils/stack.py
  +++ b/telegram/ext/_utils/stack.py
  @@ -25,10 +25,13 @@
       user. Changes to this module are not considered breaking changes and may not be documented in
       the changelog.
   """
  +import logging
   from pathlib import Path
   from types import FrameType
   from typing import Optional
   
  +_logger = logging.getLogger(__name__)
  +
   
   def was_called_by(frame: Optional[FrameType], caller: Path) -> bool:
       """Checks if the passed frame was called by the specified file.
  @@ -51,11 +54,22 @@
       if frame is None:
           return False
   
  +    try:
  +        return _was_called_by(frame, caller)
  +    except Exception as exc:
  +        _logger.debug(
  +            "Failed to check if frame was called by `caller`. Assuming that it was not.",
  +            exc_info=exc,
  +        )
  +        return False
  +
  +
  +def _was_called_by(frame: FrameType, caller: Path) -> bool:
       # https://stackoverflow.com/a/57712700/10606962
  -    if Path(frame.f_code.co_filename) == caller:
  +    if Path(frame.f_code.co_filename).resolve() == caller:
           return True
       while frame.f_back:
           frame = frame.f_back
  -        if Path(frame.f_code.co_filename) == caller:
  +        if Path(frame.f_code.co_filename).resolve() == caller:
               return True
       return False
  
verification_info: {"golden_diff": "diff --git a/telegram/ext/_utils/stack.py b/telegram/ext/_utils/stack.py\n--- a/telegram/ext/_utils/stack.py\n+++ b/telegram/ext/_utils/stack.py\n@@ -25,10 +25,13 @@\n     user. Changes to this module are not considered breaking changes and may not be documented in\n     the changelog.\n \"\"\"\n+import logging\n from pathlib import Path\n from types import FrameType\n from typing import Optional\n \n+_logger = logging.getLogger(__name__)\n+\n \n def was_called_by(frame: Optional[FrameType], caller: Path) -> bool:\n     \"\"\"Checks if the passed frame was called by the specified file.\n@@ -51,11 +54,22 @@\n     if frame is None:\n         return False\n \n+    try:\n+        return _was_called_by(frame, caller)\n+    except Exception as exc:\n+        _logger.debug(\n+            \"Failed to check if frame was called by `caller`. Assuming that it was not.\",\n+            exc_info=exc,\n+        )\n+        return False\n+\n+\n+def _was_called_by(frame: FrameType, caller: Path) -> bool:\n     # https://stackoverflow.com/a/57712700/10606962\n-    if Path(frame.f_code.co_filename) == caller:\n+    if Path(frame.f_code.co_filename).resolve() == caller:\n         return True\n     while frame.f_back:\n         frame = frame.f_back\n-        if Path(frame.f_code.co_filename) == caller:\n+        if Path(frame.f_code.co_filename).resolve() == caller:\n             return True\n     return False\n", "issue": "[BUG] telegram.ext._utils.stack.was_called_by gives incorrect result on 64-bit machine\n### Steps to Reproduce\n\n1. Set up virtualenv using `python3 -m venv` on a 64-bit machine.\r\n2. Initialize an `application` object using `telegram.ext.ApplicationBuilder`:\r\n``` python\r\nfrom telegram.ext import ApplicationBuilder\r\ndef main() -> None:\r\n    application = ApplicationBuilder().token(\"TOKEN\").build()\r\n\r\nif __name__ == \"__main__\":\r\n    main()\r\n```\r\n4. Run the bot in virtualenv and it will give a warning messgae like ```PTBUserWarning: `Application` instances should be built via the `ApplicationBuilder`.```\r\n\n\n### Expected behaviour\n\nThe warning message shouldn't be given since `ApplicationBuilder` is being used.\n\n### Actual behaviour\n\n``` bash\r\n$ python test.py \r\n../venv/lib64/python3.11/site-packages/telegram/ext/_applicationbuilder.py:292: \r\nPTBUserWarning: `Application` instances should be built via the `ApplicationBuilder`.\r\n  ] = DefaultValue.get_value(  # pylint: disable=not-callable\r\n```\r\n\r\n\n\n### Operating System\n\nFedora Linux 37 (Server Edition)\n\n### Version of Python, python-telegram-bot & dependencies\n\n```shell\npython-telegram-bot 20.0\r\nBot API 6.4\r\nPython 3.11.1 (main, Dec  7 2022, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]\n```\n\n\n### Relevant log output\n\n_No response_\n\n### Additional Context\n\nI believe this is caused by comparing a resolved path with an unresolved path [here](https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/ext/_application.py#L273). \r\n\r\nIn 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`.\r\n\r\nA quick (maybe not final) fix is to modify [stack.py](https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/ext/_utils/stack.py) so that `was_called_by` always resolves paths from frame:\r\n``` python\r\n    while frame.f_back:\r\n        frame = frame.f_back\r\n        if Path(frame.f_code.co_filename).resolve() == caller:\r\n            return True\r\n```\r\nI have tested it and the warning no longer appears.\n", "before_files": [{"content": "#!/usr/bin/env python\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2023\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\"This module contains helper functions related to inspecting the program stack.\n\n.. versionadded:: 20.0\n\nWarning:\n    Contents of this module are intended to be used internally by the library and *not* by the\n    user. Changes to this module are not considered breaking changes and may not be documented in\n    the changelog.\n\"\"\"\nfrom pathlib import Path\nfrom types import FrameType\nfrom typing import Optional\n\n\ndef was_called_by(frame: Optional[FrameType], caller: Path) -> bool:\n    \"\"\"Checks if the passed frame was called by the specified file.\n\n    Example:\n        .. code:: pycon\n\n            >>> was_called_by(inspect.currentframe(), Path(__file__))\n            True\n\n    Arguments:\n        frame (:obj:`FrameType`): The frame - usually the return value of\n            ``inspect.currentframe()``. If :obj:`None` is passed, the return value will be\n            :obj:`False`.\n        caller (:obj:`pathlib.Path`): File that should be the caller.\n\n    Returns:\n        :obj:`bool`: Whether the frame was called by the specified file.\n    \"\"\"\n    if frame is None:\n        return False\n\n    # https://stackoverflow.com/a/57712700/10606962\n    if Path(frame.f_code.co_filename) == caller:\n        return True\n    while frame.f_back:\n        frame = frame.f_back\n        if Path(frame.f_code.co_filename) == caller:\n            return True\n    return False\n", "path": "telegram/ext/_utils/stack.py"}], "after_files": [{"content": "#!/usr/bin/env python\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2023\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\"This module contains helper functions related to inspecting the program stack.\n\n.. versionadded:: 20.0\n\nWarning:\n    Contents of this module are intended to be used internally by the library and *not* by the\n    user. Changes to this module are not considered breaking changes and may not be documented in\n    the changelog.\n\"\"\"\nimport logging\nfrom pathlib import Path\nfrom types import FrameType\nfrom typing import Optional\n\n_logger = logging.getLogger(__name__)\n\n\ndef was_called_by(frame: Optional[FrameType], caller: Path) -> bool:\n    \"\"\"Checks if the passed frame was called by the specified file.\n\n    Example:\n        .. code:: pycon\n\n            >>> was_called_by(inspect.currentframe(), Path(__file__))\n            True\n\n    Arguments:\n        frame (:obj:`FrameType`): The frame - usually the return value of\n            ``inspect.currentframe()``. If :obj:`None` is passed, the return value will be\n            :obj:`False`.\n        caller (:obj:`pathlib.Path`): File that should be the caller.\n\n    Returns:\n        :obj:`bool`: Whether the frame was called by the specified file.\n    \"\"\"\n    if frame is None:\n        return False\n\n    try:\n        return _was_called_by(frame, caller)\n    except Exception as exc:\n        _logger.debug(\n            \"Failed to check if frame was called by `caller`. Assuming that it was not.\",\n            exc_info=exc,\n        )\n        return False\n\n\ndef _was_called_by(frame: FrameType, caller: Path) -> bool:\n    # https://stackoverflow.com/a/57712700/10606962\n    if Path(frame.f_code.co_filename).resolve() == caller:\n        return True\n    while frame.f_back:\n        frame = frame.f_back\n        if Path(frame.f_code.co_filename).resolve() == caller:\n            return True\n    return False\n", "path": "telegram/ext/_utils/stack.py"}]}