[issue18156] Add an 'attr' attribute to AttributeError

2013-06-07 Thread Brett Cannon
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

[issue18156] Add an 'attr' attribute to AttributeError

2013-06-07 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +eric.araujo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyth

[issue18156] Add an 'attr' attribute to AttributeError

2013-06-07 Thread Alex Gaynor
Alex Gaynor added the comment: +1 on this, but it's worth noting that that fix is not 100% correct (though it's obviously better than most existing equivilants), it's potentially wrong with custom __getattr__, __getattribute__, descriptors. -- nosy: +alex _

[issue18156] Add an 'attr' attribute to AttributeError

2013-06-07 Thread Benjamin Peterson
Benjamin Peterson added the comment: Such custom implementations should be updated to support this wonderful new attr. :) -- nosy: +benjamin.peterson ___ Python tracker ___

[issue18156] Add an 'attr' attribute to AttributeError

2013-06-07 Thread Brett Cannon
Brett Cannon added the comment: And standardizing on an attribute name, of course. =) -- ___ Python tracker ___ ___ Python-bugs-list m

[issue18156] Add an 'attr' attribute to AttributeError

2013-06-07 Thread Brett Cannon
Brett Cannon added the comment: What Benjamin said. Adding something like this is mostly about a nicer constructor (``AttributeError(attr='meth')``) and automatically creating the message for the exception (although that would require another argument like 'object' or something to be able to

[issue18156] Add an 'attr' attribute to AttributeError

2013-06-08 Thread Ezio Melotti
Changes by Ezio Melotti : -- keywords: +easy nosy: +ezio.melotti ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue18156] Add an 'attr' attribute to AttributeError

2013-07-06 Thread Dražen Lučanin
Dražen Lučanin added the comment: I've been working on this at the EuroPython sprint today and it seems the change requires editing >20 files that call PyExc_AttributeError. This means it would be quite a big and dangerous change, so for now I just attach the optional argument addition - witho

[issue18156] Add an 'attr' attribute to AttributeError

2013-07-06 Thread Andrea Griffini
Andrea Griffini added the comment: Even porting to the new wonderful 'attr' field is not going to make the code correct... (the exception could be bubbling up from code down ten frames about a different unrelated attribute that happens to have the same name in a different object). BTW cpython

[issue18156] Add an 'attr' attribute to AttributeError

2013-07-06 Thread Brett Cannon
Brett Cannon added the comment: Dražen: didn't do a deep review, but a cursory look suggests the patch is fine. As for having to change a ton of files to start using the attribute, that's part of the effect of changing something as basic as an exception. If you would rather break it up into se

[issue18156] Add an 'attr' attribute to AttributeError

2013-07-07 Thread Dražen Lučanin
Dražen Lučanin added the comment: OK, thanks for the feedback. I signed the CLA. I'll then wait with the remaining work, until a final decision has been made. We have a rough idea of how it could be implemented if it comes to this - adding a wrapper function in Python/errors.c: PyErr_SetA