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__ #89

Open
alanjds opened this issue Oct 6, 2018 · 2 comments
Open

[WIP] Support for __getattr__ and __setattr__ #89

alanjds opened this issue Oct 6, 2018 · 2 comments
Labels
imported PR Pull Request imported from google/grumpy

Comments

@alanjds
Copy link

alanjds commented Oct 6, 2018

google#303 opened on Apr 28, 2017 by @alanjds

Needed for #70.

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

@alanjds
Copy link
Author

alanjds commented Oct 6, 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
Author

alanjds commented Oct 6, 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?

@alanjds alanjds added the imported PR Pull Request imported from google/grumpy label Oct 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported PR Pull Request imported from google/grumpy
Projects
None yet
Development

No branches or pull requests

1 participant