[issue11770] inspect.dir_static

Andreas Stührk report at bugs.python.org
Sat Apr 9 04:01:30 CEST 2011


Andreas Stührk <andy-python at hammerhartes.de> added the comment:

A first patch, misses any documentation changes. While working on it, I realised that modules technically shadow the __dict__ attribute (because modules use tp_dictoffset, hence module have a __dict__ member that points to the instance dict). I updated `_shadowed_dict()` so that it now disregards member descriptors as shadowing (as they will never trigger any code execution), but theoretically, the members can be any object (not just dicts), so I have to think a bit more about that case (as a custom object still can trigger code execution).

Also, `dir_static()` behaves slightly different from `dir()` (e.g. `dir()` raises a `TypeError` if the module's "__dict__" attribute isn't a dictionary, which is kind of impossible for `dir_static` as it doesn't even try to acccess `__dict__` if it is shadowed), but IMHO such edge-cases are expected to behave differently for a static version and hence we don't care at all about that.

----------
keywords: +patch
Added file: http://bugs.python.org/file21591/issue11770.patch

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


More information about the Python-bugs-list mailing list