|
From: Randy J. Y. <ry...@we...> - 2001-08-29 20:48:52
|
Howdy,
There appears to be a slight difference in the exception handling
between CPython and Jython.
Before I dig into CPython's code I want to see if this is a known problem.
Here is my test case:
-----------------------------------
class Foo:
def __getattr__(self, key):
print 'getting %s' % key
raise KeyError, key
foo = Foo()
if not foo: print 'no foo'
-------------------------------------
CPython has the following output:
=========================
getting __nonzero__
getting __len__
=========================
Where Jython does this:
=========================
WE: getting __nonzero__
Traceback (innermost last):
File "tc.py", line 7, in ?
File "tc.py", line 4, in __getattr__
KeyError: __nonzero__
==========================
Since _getattr__ always raises an error, it seems the CPython is doing
something magical under the hood.
Has anyone seen anything similar?
Thanks,
Randy Jay Yarger (ry...@we...)
Phabric Development (www.phabric.org) @ Web Elite (www.webelite.com)
|