[pypy-issue] Issue #2501: [Pypy] Multiple Inheritance Bug: typeError: __init__() takes exactly 1 argument (2 given) (pypy/pypy)

KSHMK issues-reply at bitbucket.org
Fri Mar 17 09:13:46 EDT 2017


New issue 2501: [Pypy] Multiple Inheritance Bug: typeError: __init__() takes exactly 1 argument (2 given)
https://bitbucket.org/pypy/pypy/issues/2501/pypy-multiple-inheritance-bug-typeerror

KSHMK:

I found an error while installing and running to use pwntools.

Pwntools inherits threading.local and stack implemented classes to implement a stack for each thread.

However, when inheriting and executing __init__ "__init__() takes exactly 1 argument (2 given)". This error did not occur in Cpython.

```
#!python

import threading
class B(object):
    def __init__(self, K):
        self._current = K
        self.__stack = []

    def push(self):
        print "push"

class A(threading.local, B):
    pass

K = A({"asdf":"asdf"})
K.push()
print K._current
```
I have simplified the source of the error.

If you change the order of inheritance


```
#!python

import threading
class B(object):
    def __init__(self, K):
        self._current = K
        self.__stack = []

    def push(self):
        print "push"

class A(B,threading.local):
    pass

K = A({"asdf":"asdf"})
K.push()
print K._current
```

No Error. Why?




More information about the pypy-issue mailing list