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.

classification
Title: inspect.dir_static
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: Claudiu.Popa, Trundle, daniel.urban, eric.araujo, michael.foord
Priority: low Keywords: patch

Created on 2011-04-05 11:08 by michael.foord, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
issue11770.patch Trundle, 2011-04-09 02:01 review
Messages (6)
msg133017 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011-04-05 11:08
A version of dir that returns all the members that can be seen by getattr_static.
msg133320 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-04-08 15:49
Would it respect __dir__?
msg133322 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011-04-08 15:51
No. It would return all members accessible to getattr_static (which is completely unrelated to what __dir__ may or may not return). Also calling __dir__ would mean code execution, and the point of these functions is to avoid this where possible.
msg133372 - (view) Author: Andreas Stührk (Trundle) * Date: 2011-04-09 02:01
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.
msg133382 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011-04-09 11:43
Thanks for the patch Andreas. On a quick read through it looks good. I'll do a proper review shortly.
msg133434 - (view) Author: Andreas Stührk (Trundle) * Date: 2011-04-09 23:19
See issue #11813 for the module problem.
History
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55979
2014-01-29 06:44:33Claudiu.Popasetnosy: + Claudiu.Popa
2014-01-28 23:03:39yselivanovsetversions: + Python 3.5, - Python 3.4
2012-09-30 10:21:09tomwardillsetversions: + Python 3.4, - Python 3.3
2011-07-15 18:56:23pitrousettype: behavior -> enhancement
stage: needs patch -> patch review
2011-04-09 23:19:22Trundlesetmessages: + msg133434
2011-04-09 11:43:12michael.foordsetmessages: + msg133382
2011-04-09 02:01:30Trundlesetfiles: + issue11770.patch
keywords: + patch
messages: + msg133372
2011-04-08 16:09:55daniel.urbansetnosy: + daniel.urban
2011-04-08 15:51:07michael.foordsetmessages: + msg133322
2011-04-08 15:49:10eric.araujosetnosy: + eric.araujo
messages: + msg133320
2011-04-08 00:17:15Trundlesetnosy: + Trundle
2011-04-05 11:08:55michael.foordcreate