[New-bugs-announce] [issue18156] Add an 'attr' attribute to AttributeError

Brett Cannon report at bugs.python.org
Fri Jun 7 17:31:50 CEST 2013


New submission from Brett Cannon:

Much like ImportError now has 'name' and 'path', AttributeError should get an 'attr' attribute that can only be set through a keyword argument or after creating an instance. That would make the common ``try/except AttributeError`` uses much more robust by not accidentally swallowing an AttributeError that has nothing to do with the attribute in question::

 try:
   cls.meth()
 except AttributeError as exc:
   if exc.attr != 'meth':
     raise

----------
components: Interpreter Core
messages: 190754
nosy: brett.cannon
priority: normal
severity: normal
stage: test needed
status: open
title: Add an 'attr' attribute to AttributeError
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18156>
_______________________________________


More information about the New-bugs-announce mailing list