grumpyhome / grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Apache License 2.0
420 stars 18 forks source link

Behavior difference of super with CPython #32

Open alanjds opened 6 years ago

alanjds commented 6 years ago

google/grumpy#217 opened by @S-YOU on 26 Jan 2017

For the given code:

class A(tuple):
  def __init__(self, arg=None):
    print super(A, self)
    print super(A, self).__init__
    super(A, self).__init__(arg)

print A([1,2,3])
--- CPython Grumpy
super(A, self) <super: <class 'A'>, <A object>> <super object at 0xc4203b8d80>
super(A, self).__init__ <method-wrapper '__init__' of A object at 0x1024d1110> <bound method super.__init__ of <super object at 0xc4203b8e10>>
super(A, self).__init__(arg) (1, 2, 3) TypeError: '__init__' requires 2 arguments
alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 27, 2017 at 18:18 GMT


Thanks for reporting this! I took a quick look at this but wasn't able to figure out the exact problem. I suspect it'll be a pretty simple fix once it's clear exactly what's happening.