summaryrefslogtreecommitdiffstats
path: root/Lib/warnings.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2008-09-05 18:33:51 (GMT)
committerBrett Cannon <bcannon@gmail.com>2008-09-05 18:33:51 (GMT)
commit32476fc5a8c1e4bdfab04ab09b254a3c833e5785 (patch)
tree1ddd84d1817eec0dad96aae8ba8408db353b131a /Lib/warnings.py
parent6024834ed9887b47cfa798f20e99d5c941b97f24 (diff)
downloadcpython-32476fc5a8c1e4bdfab04ab09b254a3c833e5785.zip
cpython-32476fc5a8c1e4bdfab04ab09b254a3c833e5785.tar.gz
cpython-32476fc5a8c1e4bdfab04ab09b254a3c833e5785.tar.bz2
Deprecate bsddb for removal in Python 3.0.
Closes issue 3776. Review by Nick Coghlan.
Diffstat (limited to 'Lib/warnings.py')
-rw-r--r--Lib/warnings.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py
index b699c43..9ec04be 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -314,7 +314,14 @@ class WarningsRecorder(list):
self.append(WarningMessage(*args, **kwargs))
def __getattr__(self, attr):
- return getattr(self[-1], attr)
+ """Return attributes from the last caught warning, or raise
+ AttributeError."""
+ try:
+ return getattr(self[-1], attr)
+ except IndexError:
+ raise AttributeError("no recorded warning to read "
+ "{0!r} attribute from".format(attr))
+
def reset(self):
del self[:]