A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-August/103192.html below:

[Python-Dev] 'hasattr' is broken by design

[Python-Dev] 'hasattr' is broken by design [Python-Dev] 'hasattr' is broken by designMichael Foord fuzzyman at voidspace.org.uk
Mon Aug 23 22:08:50 CEST 2010
  On 23/08/2010 22:59, Benjamin Peterson wrote:
> [snip...]
>> IMO, this is a much better solution, more in line with known use cases
>> for hasattr().   If the proposed change when through, it would fail to
>> address the common use case and cause people to start writing their
>> own versions of hasattr() that just scan but do not run code.
> Can you provide an example? I've never seen code which explicitly
> scans MRO and dicts to avoid triggering code. (Besides
> collections.Callable; that's a special case.)
>

The example I linked to in my previous email did exactly that - the use 
case was for finding and displaying docstrings on members in an 
interactive object viewer. We needed to be able to examine objects 
without triggering code execution in them.

To me hasattr *looks* like a passive introspection function, and the 
fact that it can trigger arbitrary code execution is unfortunate - 
especially because a full workaround is pretty arcane.

Michael


>


-- 
http://www.ironpythoninaction.com/

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4