Issue1172785
Created on 2005-03-29 20:50 by jguyer, last changed 2005-06-26 22:24 by georg.brandl. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg24821 - (view) | Author: Jonathan E. Guyer (jguyer) | Date: 2005-03-29 20:50 | |
doctest.script_from_examples() can sometimes return results that
cannot be passed to exec. The docstring for script_from_examples()
itself is an example:
guyer% python2.4
Python 2.4 (#1, Mar 10 2005, 18:08:38)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1671)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> text = '''
... Here are examples of simple math.
... Python has super accurate integer addition
... >>> 2 + 2
... 5
...
... And very friendly error messages:
...
... >>> 1/0
... To Infinity
... And
... Beyond
...
... You can use logic if you want:
...
... >>> if 0:
... ... blay
... ... blah
... ...
...
... Ho hum
... '''
>>> exec doctest.script_from_examples(text)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<string>", line 21
# Ho hum
^
SyntaxError: invalid syntax
The issue seems to be the lack of trailing '\n', which is documented
as required by compile(), although not for exec.
We never saw a problem with this in Python 2.3's doctest, probably
because comment lines, such as "Ho hum", were stripped out and
apparently adequate '\n' were appended.
Python 2.4 on Mac OS X 10.3.8
|
|||
| msg24822 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2005-06-26 22:24 | |
Logged In: YES user_id=1188172 Thanks for the report, this is fixed as of Lib/doctest.py r1.123, r1.120.2.2. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2005-03-29 20:50:53 | jguyer | create | |
