Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

[WIP] Support for __getattr__ and __setattr__ #303

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

alanjds
Copy link
Contributor

@alanjds alanjds commented Apr 28, 2017

Needed for #302.

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

@alanjds
Copy link
Contributor Author

alanjds commented Jun 18, 2017

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
Contributor Author

alanjds commented Jun 18, 2017

@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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant