classification
Title: Traceback reporting can fail if IO cannot be imported
Type: behavior Stage: patch review
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, eric.snow, kristjan.jonsson, pitrou, python-dev
Priority: normal Keywords: patch

Created on 2012-07-16 10:28 by kristjan.jonsson, last changed 2012-08-10 19:23 by eric.snow. This issue is now closed.

Files
File name Uploaded Description Edit
traceback.patch kristjan.jonsson, 2012-07-16 10:28 review
Messages (5)
msg165585 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2012-07-16 10:28
Reporting an error early in the python startup, before importing is properly initialized, can be tricky.
For example, here:

if (PyImport_ImportFrozenModule("_frozen_importlib") <= 0) {
  Py_FatalError("Py_Initialize: can't import _frozen_importlib");

The problem is, that _Py_DisplaySourceLine will set an exception because it cannot import the io module.  And this will terminate the traceback output.

The attached patch aims to rectify it by ignoring errors from this api in traceback.c
msg165692 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-07-17 08:58
The patch looks simple enough, but you should use spaces, not tabs.
msg165698 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2012-07-17 10:33
Certainly.  But the submission filter would have caught that.
The question is:  Is it acceptible to simply ignore errors from this api when printing tracebacks?  There are other errors that can be returned as well.
The trouble is, any errors in the traceback reporting will be ignored anyway, since there is no way to report them :)
msg165699 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-07-17 10:38
> The trouble is, any errors in the traceback reporting will be ignored
> anyway, since there is no way to report them :)

Which is a good reason to ignore them, isn't it? ;)
msg165878 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-07-19 21:02
New changeset 54524897fafc by Kristján Valur Jónsson in branch 'default':
Issue #15365:  Make traceback reporting ignore any errors when printing out
http://hg.python.org/cpython/rev/54524897fafc
History
Date User Action Args
2012-08-10 19:23:38eric.snowsetnosy: + eric.snow
2012-08-10 13:57:03kristjan.jonssonsetstatus: open -> closed
2012-07-19 21:03:00python-devsetnosy: + python-dev
messages: + msg165878
2012-07-17 10:38:27pitrousetmessages: + msg165699
2012-07-17 10:33:42kristjan.jonssonsetmessages: + msg165698
2012-07-17 08:58:45pitrousetnosy: + amaury.forgeotdarc, pitrou

messages: + msg165692
stage: patch review
2012-07-16 10:28:14kristjan.jonssoncreate