New submission from Xore <[EMAIL PROTECTED]>:

http://www.python.org/doc/2.5.2/lib/built-in-funcs.html#l2h-35

"(This is implemented by calling getattr(object, name) and seeing
whether it raises an exception or not.)"

If a property exists but it's retrieval throws some error, hasattr will
interpret this as the property not existing, since it only checks for
the existence of an error, not an AttributeError

<code>
class test:
    @property
    def prop(self):
        # do stuff
        raise ZeroDivisionError # an example

foobar = test()

assert hasattr(foobar, "prop")
</code>

----------
messages: 74187
nosy: Xore
severity: normal
status: open
title: hasattr boundary case failure
type: behavior
versions: Python 2.5

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4020>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to