This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author abarry
Recipients abarry, r.david.murray, rhettinger, xiang.zhang, ztane
Date 2016-08-22.01:12:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1471828379.42.0.827107783892.issue27823@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks for your comments Xiang. Yes, it's not equal to #27794, but it's one of the multiple ways to fix it, so I made a new issue about it.

The rationale between a bare `raise AttributeError` being changed is the idea that it carries no information, other than the fact there was an attribute error (it doesn't even mean the attribute doesn't exist, as it may). Also note that this only affects bare AttributeErrors inside of the magic methods dedicated to attribute lookup (and the descriptor machinery). In a regular function (or even just doing `foo.__getattribute__(bar)`), `raise AttributeError` does nothing special.

The argument "If you do want a good message, why not passing the message when raising?" is one I hear a lot when there's a suggestion to add a more convenient way to do something that can already be done. I've seen a lot of code (including code in the core Python distribution, both in Python and C) which lazily does `raise AttributeError(name)`. It's only half the information, and these uninformative error messages are left completely untouched by my patch. The patch will help reduce boilerplate in some code. I'm personally one of those people who go ahead and actually use the built-in error message in my own code, but if I can reduce the boilerplate needed while maintaining the same level of information and usefulness for debugging, I'll be happy.

On the other hand, the argument that Python hides away some magic is a valid concern. Python already has some magic in various places; the point is to determine whether this kind of magic is acceptable for Python and its users. I honestly don't know; I don't think the magic is too strong, but at the same time it's likely to surprise newcomers. We'll see what others think :)
History
Date User Action Args
2016-08-22 01:12:59abarrysetrecipients: + abarry, rhettinger, r.david.murray, ztane, xiang.zhang
2016-08-22 01:12:59abarrysetmessageid: <1471828379.42.0.827107783892.issue27823@psf.upfronthosting.co.za>
2016-08-22 01:12:59abarrylinkissue27823 messages
2016-08-22 01:12:57abarrycreate