This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author msuchy@redhat.com
Recipients msuchy@redhat.com
Date 2021-10-07.13:57:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1633615069.33.0.311671101448.issue45406@roundup.psfhosted.org>
In-reply-to
Content
When you exec inspect.getouterframes() in directory, which no longer exists, then you get traceback, because the code traverse to os.getcwd() which fails.

Reproducer:

$ mkdir /tmp/bar
$ cd /tmp/bar
$ rmdir /tmp/bar
$ python3
Python 3.10.0rc2 (default, Sep  8 2021, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> inspect.getouterframes(inspect.currentframe())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.10/inspect.py", line 1653, in getouterframes
    frameinfo = (frame,) + getframeinfo(frame, context)
  File "/usr/lib64/python3.10/inspect.py", line 1623, in getframeinfo
    filename = getsourcefile(frame) or getfile(frame)
  File "/usr/lib64/python3.10/inspect.py", line 829, in getsourcefile
    module = getmodule(object, filename)
  File "/usr/lib64/python3.10/inspect.py", line 861, in getmodule
    file = getabsfile(object, _filename)
  File "/usr/lib64/python3.10/inspect.py", line 845, in getabsfile
    return os.path.normcase(os.path.abspath(_filename))
  File "/usr/lib64/python3.10/posixpath.py", line 383, in abspath
    cwd = os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
History
Date User Action Args
2021-10-07 13:57:49msuchy@redhat.comsetrecipients: + msuchy@redhat.com
2021-10-07 13:57:49msuchy@redhat.comsetmessageid: <1633615069.33.0.311671101448.issue45406@roundup.psfhosted.org>
2021-10-07 13:57:49msuchy@redhat.comlinkissue45406 messages
2021-10-07 13:57:49msuchy@redhat.comcreate