Yield-from: Mysterious doctest failures

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 ********************************************************************** -- Greg

Greg Ewing wrote:
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

Steven D'Aprano wrote:
Greg Ewing wrote:
SyntaxError: assignment to yield expression not possible (<doctest test.test_generators.__test__.coroutine[23]>, line 1)
SyntaxError: assignment to yield expression not possible (<doctest test.test_generators.__test__.coroutine[22]>, line 1)
The index in the coroutines are different: 23 expected, 22 got.
Okay, got it now. I had removed some tests concerning return with value in generators, and that changed the numbering of the tests.
Also, unless it's an artifact of either your or my mail client, there's a spurious space *before* the SyntaxError exception.
It's not an artifact -- I noticed that too, and I'm just as mystified. I haven't touched anything anywhere near whatever produces those messages! It doesn't seem to stop the tests from passing, though, so I'm happy now. Thanks, Greg

Greg Ewing wrote:
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

Steven D'Aprano wrote:
Greg Ewing wrote:
SyntaxError: assignment to yield expression not possible (<doctest test.test_generators.__test__.coroutine[23]>, line 1)
SyntaxError: assignment to yield expression not possible (<doctest test.test_generators.__test__.coroutine[22]>, line 1)
The index in the coroutines are different: 23 expected, 22 got.
Okay, got it now. I had removed some tests concerning return with value in generators, and that changed the numbering of the tests.
Also, unless it's an artifact of either your or my mail client, there's a spurious space *before* the SyntaxError exception.
It's not an artifact -- I noticed that too, and I'm just as mystified. I haven't touched anything anywhere near whatever produces those messages! It doesn't seem to stop the tests from passing, though, so I'm happy now. Thanks, Greg
participants (2)
-
Greg Ewing
-
Steven D'Aprano