Author vstinner
Recipients ezio.melotti, michael.foord, pitrou, serhiy.storchaka, vstinner
Date 2015-04-01.11:47:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> 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").
Date User Action Args
2015-04-01 11:47:52vstinnersetrecipients: + vstinner, pitrou, ezio.melotti, michael.foord, serhiy.storchaka
2015-04-01 11:47:52vstinnersetmessageid: <>
2015-04-01 11:47:52vstinnerlinkissue23838 messages
2015-04-01 11:47:52vstinnercreate