classification
Title: doctest EXCEPTION_RE can't handle preceding output
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: tim.peters Nosy List: jafo, nouri, tim.peters
Priority: normal Keywords: patch

Created on 2007-10-22 20:19 by nouri, last changed 2008-03-18 00:04 by jafo. This issue is now closed.

Files
File name Uploaded Description Edit
doctest-bug.py nouri, 2007-10-22 20:19
Messages (2)
msg56655 - (view) Author: Daniel Nouri (nouri) Date: 2007-10-22 20:19
doctest.DocTestParser._EXCEPTION_RE does not allow for output before the
actual traceback.

Attached is a simple test that demonstrates the problem.  This patch
fixes it:

--- /usr/lib/python2.5/doctest.py 2007-10-22 21:45:21.000000000 +0200
+++ /home/daniel/tmp/doctest.py       2007-10-22 22:19:12.000000000 +0200
@@ -513,7 +513,7 @@
     _EXCEPTION_RE = re.compile(r"""
         # Grab the traceback header.  Different versions of Python have
         # said different things on the first traceback line.
-        ^(?P<hdr> Traceback\ \(
+        .*^(?P<hdr> Traceback\ \(
             (?: most\ recent\ call\ last
             |   innermost\ last
             ) \) :


    _EXCEPTION_RE = re.compile(r"""
        # Grab the traceback header.  Different versions of Python have
        # said different things on the first traceback line.
        ^(?P<hdr> Traceback\ \(
            (?: most\ recent\ call\ last
            |   innermost\ last
            ) \) :
        )
        \s* $                # toss trailing whitespace on the header.
        (?P<stack> .*?)      # don't blink: absorb stuff until...
        ^ (?P<msg> \w+ .*)   #     a line *starts* with alphanum.
        """, re.VERBOSE | re.MULTILINE | re.DOTALL)
msg63810 - (view) Author: Sean Reifschneider (jafo) * (Python committer) Date: 2008-03-18 00:04
The existing tests include a test explicitly for the existing behavior,
including the statement: "An example may not generate output before it
raises an exception".  In order to be able to accept this change, there
is going to have to be discussion in python-dev or here about changing
the behavior.
History
Date User Action Args
2008-03-18 00:04:19jafosetstatus: open -> closed
nosy: + jafo
resolution: rejected
messages: + msg63810
priority: normal
2007-10-23 19:39:58gvanrossumsetassignee: tim.peters
nosy: + tim.peters
2007-10-22 20:31:01loewissetkeywords: + patch
2007-10-22 20:19:06nouricreate