[Python-Dev] 'hasattr' is broken by design (original) (raw)
Glyph Lefkowitz glyph at twistedmatrix.com
Tue Aug 24 20:11:34 CEST 2010
- Previous message: [Python-Dev] 'hasattr' is broken by design
- Next message: [Python-Dev] 'hasattr' is broken by design
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Aug 24, 2010, at 8:31 AM, Benjamin Peterson wrote:
2010/8/24 Hrvoje Niksic <hrvoje.niksic at avl.com>:
The lengthhint lookup expects either no exception or AttributeError, and will propagate others. I'm not sure if this is a bug. On the one hand, throwing anything except AttributeError from getattr is bad style (which is why we fixed the bug by deriving our business exception from AttributeError), but the lengthhint check is supposed to be an internal optimization completely invisible to the caller of list(). lengthhint is internal and undocumented, so it can do whatever it wants.
As it happens though, list() is quite public. Saying "X is internal and undocumented, so it can do whatever it wants" is never really realistic, especially in response to someone saying "we already saw this problem in production, without calling / referring to / knowing about this private API".
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20100824/1a37a8dc/attachment.html>
- Previous message: [Python-Dev] 'hasattr' is broken by design
- Next message: [Python-Dev] 'hasattr' is broken by design
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]