[Python-checkins] r88120 - python/branches/py3k/Doc/whatsnew/3.2.rst
raymond.hettinger
python-checkins at python.org
Thu Jan 20 05:12:37 CET 2011
Author: raymond.hettinger
Date: Thu Jan 20 05:12:37 2011
New Revision: 88120
Log:
Add hasattr() example.
Modified:
python/branches/py3k/Doc/whatsnew/3.2.rst
Modified: python/branches/py3k/Doc/whatsnew/3.2.rst
==============================================================================
--- python/branches/py3k/Doc/whatsnew/3.2.rst (original)
+++ python/branches/py3k/Doc/whatsnew/3.2.rst Thu Jan 20 05:12:37 2011
@@ -456,7 +456,18 @@
would otherwise be absent from the class dictionary. Formerly, *hasattr*
would catch any exception, possibly masking genuine errors. Now, *hasattr*
has been tightened to only catch :exc:`AttributeError` and let other
- exceptions pass through.
+ exceptions pass through::
+
+ >>> class A:
+ @property
+ def f(self):
+ return 1 // 0
+
+ >>> a = A()
+ >>> hasattr(a, 'f')
+ Traceback (most recent call last):
+ ...
+ ZeroDivisionError: integer division or modulo by zero
(Discovered by Yury Selivanov and fixed by Benjamin Peterson; :issue:`9666`.)
More information about the Python-checkins
mailing list