STINNER Victor added the comment: > Proposed patch clears the cache and repeats an attempt to read source file, > and returns empty result if the second attempt fails (as when the source file > can't be read).
IMO it's a bad idea. You should not retry an operation on MemoryError but only do you best to limit errors. I don't think that it's correct to return an empty list for getlines() on MemoryError. So you maybe chose the wrong module: you should handle MemoryError in the traceback module, not in the linecache module. It's just fine to return an empty string for FrameSummary.line. It's common to not being able to display a line: because the .py was removed (only the .pyc is available), invalid line number, invalid filename ("<string>" or "<stdin>"), etc. If you are motivated to make the traceback module more reliable, you should maybe also enhance _Py_DisplaySourceLine() in Python/traceback.c. You can probably ignore almost all errors in _Py_DisplaySourceLine() ("except (Exception, MemoryError): pass"). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23838> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com