[Patches] [ python-Patches-668500 ] doctest handles comments incorrectly

SourceForge.net noreply at sourceforge.net
Mon Feb 16 19:41:11 EST 2004


Patches item #668500, was opened at 2003-01-15 09:39
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=668500&group_id=5470

Category: Library (Lib)
Group: Python 2.2.x
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Alexander Schmolck (aschmolck)
>Assigned to: Nobody/Anonymous (nobody)
Summary: doctest handles comments incorrectly

Initial Comment:
> >    import doctest, test
> >    def aTest():
> >        r""">>> # A comment
> >            ... print 'This is incorrectly ignored
by doctest'
> >            This output here really doesn't matter
either... (but SHOULD)
> >            >>>
> >            """

the patch fixes that and passes the original doctest
tests. (test_doctest and doctest.py itself)


----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2004-02-16 19:41

Message:
Logged In: YES 
user_id=31435

It's intentional that doctest looks for PS1 to identify lines that 
begin Python statements, and I'm opposed to changing that.  
The docs could be clearer on this point.  I don't care that the 
Python command-line shell is braindead in starting a line 
following a comment with PS2.  The IDLE shell, and the 
PythonWin shell, are not insane in this respect, and I don't 
want doctest to be in the business of guessing intent across 
the union of all stupid things all Python shells do.  As the docs 
say, "In most cases a copy-and-paste of an interactive
console session works fine".  "most" < "all", because of goofy 
exceptions like this one.  doctest has its own rules for 
distinguishing among intial lines, continuation lines, and output 
lines, and I want to keep them as simple as they are.

In your specific example, change the doctest to use PS1 
instead of PS2 on the 'print' line, and it should work fine.

While I'm rejecting this patch, I'd be happy to see a patch to 
make the Python command-line shell smarter in this case.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2003-01-15 21:45

Message:
Logged In: YES 
user_id=31435

Alexander, you need to check the "Check to Upload and 
Attach a File" box when trying to attach a file.  This is a 
SourceForge annoyance we have no control over.  Please 
try again!

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-15 20:56

Message:
Logged In: YES 
user_id=80475

The file attachment didn't make it.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=668500&group_id=5470



More information about the Patches mailing list