-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
missing feature in inspect module: getmembers_static #74718
Comments
The inspect module contains a getattr_static() function, for accessing an arbitrary attribute on a Python object without risking descriptor or __getattr__ code execution. This is useful for introspection tools that don't want to trigger any side effects. The inspect module also contains a getmembers() function, which returns a mapping of names to values for all the object's members. This function could also be very useful to introspection tools, except that internally it uses normal getattr, thus reintroduces the risk of arbitrary code execution. It would be useful to have an equivalent to getmembers() that is descriptor-safe. This could be done either by introducing a new getmembers_static(), or possibly by adding a |
+1 to a new getmembers_static(), I don't see why this couldn't be implemented. |
+1 from me too. bpo-35108 could help from this implementation where properties execute code that might cause runtime exception. Initially I tried using getattr_static inside getmembers at msg329254 but I think a separate function or an option to use getattr_static only in getmembers is more clean. Bumping the version to 3.8. Thanks! |
interested in this too - came here to see if I can implement, but found that a patch is already available (GH-20911), and applies cleanly on latest main branch (see my PR comments) would be great if it gets merged! |
Please update the documentation also. see: https://docs.python.org/3.11/library/inspect.html?highlight=inspect#inspect.getmembers |
inspect.getmembers_static
#29874Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: