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.getattr_static doesn't get module attributes
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: Trundle, eric.araujo, michael.foord, python-dev
Priority: high Keywords: patch

Created on 2011-04-09 22:44 by Trundle, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
getattr_static_modules.patch Trundle, 2011-04-09 22:44 review
Messages (3)
msg133432 - (view) Author: Andreas Stührk (Trundle) * Date: 2011-04-09 22:44
My patch for issue #11133 introduced a regression: it is no longer possible to get attributes of modules. That is because modules use "tp_dictoffset" (at C level). The instance __dict__ is exposed to Python code using a types.MemberDescriptorType. My patch for issue #11133 currently assumes that accessing the instance __dict__ can trigger code execution, but that is impossible: The access itself can't trigger code execution (it just returns a PyObject in the C struct). Theoretically, it could return any Python object, but that doesn't matter, as the code that uses the object only calls dict methods directly, hence a TypeError is the worst thing that can happen (although it shouldn't ever happen in practise).

Attached is a patch that adds a test and fixes the issue.
msg149803 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011-12-18 21:25
I'd like to commit this patch. What's your real name Trundle, for the NEWS entry?
msg149804 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-12-18 22:07
New changeset 56731ccf2e86 by Michael Foord in branch '3.2':
Fix inspect.getattr_static to work on modules (again).
http://hg.python.org/cpython/rev/56731ccf2e86
History
Date User Action Args
2022-04-11 14:57:16adminsetgithub: 56022
2011-12-18 22:07:17python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg149804

resolution: fixed
stage: patch review -> resolved
2011-12-18 21:25:52michael.foordsetassignee: michael.foord
messages: + msg149803
2011-10-09 21:53:49ezio.melottisetpriority: normal -> high
2011-07-15 18:55:32pitrousetstage: patch review
2011-04-11 15:17:40eric.araujosetnosy: + eric.araujo
2011-04-09 22:44:16Trundlecreate