[Python-Dev] PEP 344 (was: with_traceback) (original) (raw)

Collin Winter collinw at gmail.com
Sat Mar 3 00:45:20 CET 2007


On 2/26/07, Andrew Dalke <dalke at dalkescientific.com> wrote:

My concern when I saw Guido's keynote was the worry that people do/might write code like this

NOENDOFRECORD = ParserError("Cannot find end of record") def parserecord(inputfile): ... raise NOENDOFRECORD ...

That is, create instances at the top of the module, to be used later. This code assume that the NOENDOFRECORD exception instance is never modified. If the traceback is added to its traceback attribute then I see two problems if I were to write code like the above: - the traceback stays around "forever" - the code is no longer thread-safe.

While there are now quite a few threads discussing the problems related to the proposed traceback attribute (thread-safety being the primary one, from what I can tease out), I haven't seen anyone address the rest of PEP 344: the cause and context attributes.

Do those who oppose traceback also oppose cause and context? Should PEP 344 be rejected on these grounds, or should we just learn not to pre-instance exceptions if we're interested in these attributes?

Collin Winter



More information about the Python-Dev mailing list