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

[WIP] Support for __getattr__ and __setattr__ #147

Open
alanjds opened this issue Aug 18, 2018 · 2 comments
Open

[WIP] Support for __getattr__ and __setattr__ #147

alanjds opened this issue Aug 18, 2018 · 2 comments

Comments

@alanjds
Copy link
Owner

alanjds commented Aug 18, 2018

Needed for #146.

And could allow cleaner generic integration of hybrid modules, composed of Golang+Python files.

@alanjds
Copy link
Owner Author

alanjds commented Aug 18, 2018

Comment by alanjds
Sunday Jun 18, 2017 at 16:03 GMT


From the CPython docs, it seems that some logic from grumpy object.__getattribute__ should migrate to __builtins__.getattr:

>>> class Meta(type):
...    def __getattribute__(*args):
...       print "Metaclass getattribute invoked"
...       return type.__getattribute__(*args)
...
>>> class C(object):
...     __metaclass__ = Meta
...     def __len__(self):
...         return 10
...     def __getattribute__(*args):
...         print "Class getattribute invoked"
...         return object.__getattribute__(*args)
...
>>> c = C()
>>> c.__len__()                 # Explicit lookup via instance
Class getattribute invoked
10
>>> type(c).__len__(c)          # Explicit lookup via type
Metaclass getattribute invoked
10
>>> len(c)                      # Implicit lookup
10

@alanjds
Copy link
Owner Author

alanjds commented Aug 18, 2018

Comment by alanjds
Sunday Jun 18, 2017 at 22:57 GMT


@trotterdylan I guess this is good for now.

But I do think that getting Python tests count on coverage is so better on the long run that is worth to do this instead of working on Golang coverage to get this merged faster.

As said on this comment, can you elaborate on how do you think this could be done?

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

No branches or pull requests

1 participant