[New-bugs-announce] [issue15365] Traceback reporting can fail if IO cannot be imported

Kristján Valur Jónsson report at bugs.python.org
Mon Jul 16 12:28:15 CEST 2012

New submission from Kristján Valur Jónsson <kristjan at ccpgames.com>:

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

components: Interpreter Core
files: traceback.patch
keywords: patch
messages: 165585
nosy: kristjan.jonsson
priority: normal
severity: normal
status: open
title: Traceback reporting can fail if IO cannot be imported
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file26393/traceback.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list