Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError on PyPy #102

Open
ram-bv opened this issue Apr 6, 2020 · 4 comments
Open

FileNotFoundError on PyPy #102

ram-bv opened this issue Apr 6, 2020 · 4 comments

Comments

@ram-bv
Copy link

ram-bv commented Apr 6, 2020

I got this error running on pypy3.6-v7.3.0-linux64:

Error calling sys.excepthook:
Traceback (most recent call last):
  File "<builtin>/app_main.py", line 146, in display_exception
  File "/floof/pypy3.6-v7.3.0-linux64/site-packages/better_exceptions/__init__.py", line 53, in excepthook
    formatted = format_exception(exc, value, tb)
  File "/floof/pypy3.6-v7.3.0-linux64/site-packages/better_exceptions/__init__.py", line 49, in format_exception
    return formatter.format_exception(exc, value, tb)
  File "/floof/pypy3.6-v7.3.0-linux64/site-packages/better_exceptions/formatter.py", line 314, in format_exception
    return u''.join(formatted for formatted in self._format_exception(value, tb))
  File "/floof/pypy3.6-v7.3.0-linux64/site-packages/better_exceptions/formatter.py", line 314, in <genexpr>
    return u''.join(formatted for formatted in self._format_exception(value, tb))
  File "/floof/pypy3.6-v7.3.0-linux64/site-packages/better_exceptions/formatter.py", line 303, in _format_exception
    formatted, colored_source = self.format_traceback(exc_traceback)
  File "/floof/pypy3.6-v7.3.0-linux64/site-packages/better_exceptions/formatter.py", line 266, in format_traceback
    formatted, colored = self.format_traceback_frame(tb)
  File "/floof/pypy3.6-v7.3.0-linux64/site-packages/better_exceptions/formatter.py", line 226, in format_traceback_frame
    filename, lineno, function, source, color_source, relevant_values = self.get_traceback_information(tb)
  File "/floof/pypy3.6-v7.3.0-linux64/site-packages/better_exceptions/formatter.py", line 198, in get_traceback_information
    frame_info = inspect.getframeinfo(tb)
  File "/floof/pypy3.6-v7.3.0-linux64/lib-python/3/inspect.py", line 1458, in getframeinfo
    filename = getsourcefile(frame) or getfile(frame)
  File "/floof/pypy3.6-v7.3.0-linux64/lib-python/3/inspect.py", line 700, in getsourcefile
    if getattr(getmodule(object, filename), '__loader__', None) is not None:
  File "/floof/pypy3.6-v7.3.0-linux64/lib-python/3/inspect.py", line 729, in getmodule
    file = getabsfile(object, _filename)
  File "/floof/pypy3.6-v7.3.0-linux64/lib-python/3/inspect.py", line 713, in getabsfile
    return os.path.normcase(os.path.abspath(_filename))
  File "/floof/pypy3.6-v7.3.0-linux64/lib-python/3/posixpath.py", line 383, in abspath
    cwd = os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory

This is frustrating because I can't know what's the directory it's not finding. Can better-exceptions deal with such problems with graceful degradation? If a certain frame has a missing task, it's better to mark it as missing than crash.

@alexmojaki
Copy link

I know it looks weird but I ran into this too recently, os.getcwd() itself needs to open some file under the hood, I don't know why. Check if it works on its own?

@ram-bv
Copy link
Author

ram-bv commented Apr 6, 2020

Damn Alex, are you stalking me? ;)

This is my work account, by the way.

I confirmed os.getcwd() works on its own. It's curious that it would fail when called inside abspath. In any case I'd recommend that even if PyPy or the standard library have bugs in that code, that better-exception should degrade gracefully when they happen.

@Qix-
Copy link
Owner

Qix- commented Apr 6, 2020

We can wrap it, though it's a matter of what to do in lieu of the existing logic if an exception is raised.

@ram-bv
Copy link
Author

ram-bv commented Apr 7, 2020

I'd show something like SOURCE UNAVAILABLE for those frames, anything besides failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants