[New-bugs-announce] [issue19206] Support disabling file I/O when doing traceback formatting

Itamar Turner-Trauring report at bugs.python.org
Wed Oct 9 15:17:03 CEST 2013

New submission from Itamar Turner-Trauring:

In certain situations it is best to avoid doing file I/O. For example, a program that runs in an event loop may wish to avoid any potentially blocking operations; reading from a file usually is fast, but can sometimes take arbitrary long. Another example (my specific use case) is a logging library - you don't want to block for an arbitrary amount of time when creating log messages in an application thread (a separate thread would do the writing).

Unfortunately, the traceback.py module reads from files to load the source lines for the traceback (using linecache.py). This means if you want to format a traceback without file I/O you have to either recreate some logic from the standard library, monkey-patch globally, or do a terrible hack you don't want to know about.

It would be better if the there was some way to ask the traceback.py module's functions to not do file I/O. The actual change would be fairly minor I suspect since the formatting functions already support getting None back from linecache.

components: Library (Lib)
messages: 199294
nosy: itamarst
priority: normal
severity: normal
status: open
title: Support disabling file I/O when doing traceback formatting
type: enhancement

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list