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

ABCMeta and @abstractmethod suppose to work? #199

Open
S-YOU opened this issue Jan 23, 2017 · 2 comments
Open

ABCMeta and @abstractmethod suppose to work? #199

S-YOU opened this issue Jan 23, 2017 · 2 comments

Comments

@S-YOU
Copy link
Contributor

S-YOU commented Jan 23, 2017

I don't get OrderedDict working, because I am getting error on

self.__update(*args, **kwds)
TypeError: unbound method update() must be called with MutableMapping instance as first argument (got list instance instead)

self.__update is assigned to MutableMapping.update at class level.

It is not possible to get instance of MutableMapping, because there is abstractmethods on it.

TypeError: Can't instantiate abstract class MutableMapping with abstract methods __delitem__, __getitem__, __iter__, __len__, __setitem__

Is there a way to work-around those?

@trotterdylan
Copy link
Contributor

I'm surprised that works in CPython. Here's something similar that fails:

>>> class A(object):
...  def foo(self):
...   pass
...
>>> class B(object):
...  bar = A.foo
...
>>> B().bar()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unbound method foo() must be called with A instance as first argument (got nothing instead)

I'm not exactly sure what's going on. Will need to do some more investigation.

@S-YOU
Copy link
Contributor Author

S-YOU commented Jan 24, 2017

May be MutableMapping.register(dict) does something monkey patching.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants