Skip to content
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

Shell: do not access properties on startup #69

Merged
merged 1 commit into from Jun 9, 2021

Conversation

VinDuv
Copy link
Contributor

@VinDuv VinDuv commented Jun 5, 2021

  • Use the object’s class to find methods to import into the shell namespace rather than the object itself, to avoid invoking properties on the object.
  • Prevent importing of members whose name starts with _ (private methods and Python magic methods).

This removes the following items from the shell namespace (as checked by dir()):

__class__
__delattr__
__dir__
__eq__
__format__
__ge__
__getattribute__
__gt__
__hash__
__init__
__init_subclass__
__le__
__lt__
__ne__
__new__
__reduce__
__reduce_ex__
__repr__
__setattr__
__sizeof__
__str__
__subclasshook__
_request

If I’m not mistaken, they are not actually useful.

Change the way the shell finds methods to add to the locals on startup: the
methods are queried on the object’s class, rather than the object itself. This
allows detecting if an object’s member is a property and ignore it, rather than
accessing the property.

Attributes whose name starts by ‘_’ are also now ignored, which avoids
importing private methods or Python magic methods in the shell namespace.

Fixes spurious accesses to ProxyUtils’s SIMD properties (b, h, etc) on shell
startup, which caused a ProxyCommandError if m1n1 is not recent enough.

Signed-off-by: Vincent Duvert <vincent@duvert.net>
@marcan marcan merged commit 1a95a9f into AsahiLinux:main Jun 9, 2021
@VinDuv VinDuv deleted the shell-use-class branch November 1, 2021 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants