[Python-ideas] Yield-from: Mysterious doctest failures
Steven D'Aprano
steve at pearwood.info
Sat Feb 21 08:55:01 CET 2009
Greg Ewing wrote:
> I'm getting this from tests/test_generators.py. As far as
> I can see, the SyntaxError messages are identical. Does
> anyone know what doctest is complaining about here?
>
> **********************************************************************
> File
> "/Local/Projects/D/Python-YieldFrom/Python-2.6.1/Lib/test/test_generators.py",
> line ?, in test.test_generators.__test__.coroutine
> Failed example:
> def f(): x = yield = y
> Expected:
> Traceback (most recent call last):
> ...
> SyntaxError: assignment to yield expression not possible (<doctest
> test.test_generators.__test__.coroutine[23]>, line 1)
> Got:
> Traceback (most recent call last):
> File
> "/Local/Projects/D/Python-YieldFrom/Python-2.6.1/Lib/doctest.py", line
> 1231, in __run
> compileflags, 1) in test.globs
> File "<doctest test.test_generators.__test__.coroutine[22]>", line 1
> SyntaxError: assignment to yield expression not possible (<doctest
> test.test_generators.__test__.coroutine[22]>, line 1)
> ast: yield_expr: an = 0x10d9ed8
> **********************************************************************
The index in the coroutines are different: 23 expected, 22 got.
Also, unless it's an artifact of either your or my mail client, there's
a spurious space *before* the SyntaxError exception. With spaces
replaced by # for visibility:
Expected:
####Traceback (most recent call last):
######...
####SyntaxError: assignment to yield expression not possible (<doctest
test.test_generators.__test__.coroutine[23]>, line 1)
Got:
####Traceback (most recent call last):
######spam spam spam spam
#####SyntaxError: assignment to yield expression not possible (<doctest
test.test_generators.__test__.coroutine[22]>, line 1)
Assuming this is genuine, I have no idea how a SyntaxError exception
ends up putting a space before the exception name!
--
Steven
More information about the Python-ideas
mailing list