[pypy-svn] r78729 - pypy/branch/fast-forward/lib-python/modified-2.7.0/test
afa at codespeak.net
afa at codespeak.net
Fri Nov 5 13:00:31 CET 2010
Author: afa
Date: Fri Nov 5 13:00:30 2010
New Revision: 78729
Modified:
pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_generators.py
Log:
CPython is inconsistent in some exceptions:
- some SyntaxError are displayed differently in doctests (in traceback.py)
This was fixed in CPython 3.0 with r56853.
- An error message in Python/ast.c "assignment to yield expression not possible" is not
consistent with "can't assign to yield expression" generated in other cases.
CPython should be fixed.
- The error message in Object/genobject.c: "exceptions must be classes, or instances, not %s"
is not consistent with the same one in Python/ceval.c:
"exceptions must be old-style classes or derived from BaseException, not %s"
CPython should be fixed.
Modified: pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_generators.py
==============================================================================
--- pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_generators.py (original)
+++ pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_generators.py Fri Nov 5 13:00:30 2010
@@ -733,14 +733,16 @@
... yield 1
Traceback (most recent call last):
..
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[0]>, line 3)
+ File "<doctest test.test_generators.__test__.syntax[0]>", line 3
+SyntaxError: 'return' with argument inside generator
>>> def f():
... yield 1
... return 22
Traceback (most recent call last):
..
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[1]>, line 3)
+ File "<doctest test.test_generators.__test__.syntax[1]>", line 3
+SyntaxError: 'return' with argument inside generator
"return None" is not the same as "return" in a generator:
@@ -749,7 +751,8 @@
... return None
Traceback (most recent call last):
..
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[2]>, line 3)
+ File "<doctest test.test_generators.__test__.syntax[2]>", line 3
+SyntaxError: 'return' with argument inside generator
These are fine:
@@ -878,7 +881,9 @@
... if 0:
... yield 2 # because it's a generator (line 10)
Traceback (most recent call last):
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[24]>, line 10)
+ ...
+ File "<doctest test.test_generators.__test__.syntax[24]>", line 10
+SyntaxError: 'return' with argument inside generator
This one caused a crash (see SF bug 567538):
@@ -1574,13 +1579,14 @@
>>> def f(): return lambda x=(yield): 1
Traceback (most recent call last):
...
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.coroutine[22]>, line 1)
+ File "<doctest test.test_generators.__test__.coroutine[22]>", line 1
+SyntaxError: 'return' with argument inside generator
>>> def f(): x = yield = y
Traceback (most recent call last):
...
File "<doctest test.test_generators.__test__.coroutine[23]>", line 1
-SyntaxError: assignment to yield expression not possible
+SyntaxError: can't assign to yield expression
>>> def f(): (yield bar) = y
Traceback (most recent call last):
@@ -1669,7 +1675,7 @@
>>> f().throw("abc") # throw on just-opened generator
Traceback (most recent call last):
...
-TypeError: exceptions must be classes, or instances, not str
+TypeError: exceptions must be old-style classes or derived from BaseException, not str
Now let's try closing a generator:
More information about the Pypy-commit
mailing list