Issue1461
Created on 2009-09-07.10:56:47 by hpk, last changed 2009-09-07.21:48:32 by zyasoft.
msg5108 (view) |
Author: holger krekel (hpk) |
Date: 2009-09-07.10:56:46 |
|
Hey Frank,
while trying to make py.test work with jython i noticed that unlike
cpython and pypy, jython does not lookup the AssertionError from the
builtins. Here is an example session with jython-2.5.0
>>> import __builtin__
>>> __builtin__.AssertionError = MyAE
>>> assert 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
>>> raise AssertionError
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
__main__.MyAE
>>>
With CPython (2.5/6 and 3.x) and pypy the custom error is raised in all
cases. Could you fix that for 2.5.1?
best,
holger
|
msg5109 (view) |
Author: Frank Wierzbicki (fwierzbicki) |
Date: 2009-09-07.12:40:33 |
|
It may be too late for 2.5.1, but we are going to have many more point
releases compared to jython past, you shouldn't have to wait *too* long
for 2.5.2. I'll make sure this gets fixed on trunk reasonably soon.
|
msg5113 (view) |
Author: Jim Baker (zyasoft) |
Date: 2009-09-07.17:58:46 |
|
The relevant problem is in org.python.compiler.CodeCompiler#visitAssert:
code.getstatic("org/python/core/Py", "AssertionError",
"Lorg/python/core/PyObject;");
We can't use this optimization to the standard builtin AssertionError,
instead it should be using getattr. Notably in CPython, this is possible
to do:
>>> import __builtin__
>>> del __builtin__.AssertionError
>>> assert 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: global name 'AssertionError' is not defined
|
msg5116 (view) |
Author: Jim Baker (zyasoft) |
Date: 2009-09-07.21:48:32 |
|
Fixed in r6763
New test in test_exceptions_jy.AssertionTestCase
|
|
Date |
User |
Action |
Args |
2009-09-07 21:48:32 | zyasoft | set | status: open -> closed resolution: fixed messages:
+ msg5116 title: assert statement should lookup AssertionError from builtins -> assert statement should lookup AssertionError using getglobal |
2009-09-07 17:58:47 | zyasoft | set | nosy:
+ zyasoft messages:
+ msg5113 |
2009-09-07 12:40:34 | fwierzbicki | set | messages:
+ msg5109 |
2009-09-07 10:56:47 | hpk | create | |
|