Skip to content

newsuper not working with metaclasses - RuntimeError: super() called outside a method #267

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

Open
kdheepak opened this issue Jan 26, 2017 · 0 comments

Comments

@kdheepak
Copy link

kdheepak commented Jan 26, 2017

In [1]: from builtins import super
   ...:
   ...: class Meta(type):
   ...:     def __init__(cls, name, bases, clsdict):
   ...:         super().__init__(name, bases, clsdict)
   ...:
   ...: class Base(object):
   ...:     __metaclass__ = Meta
   ...:
   ...:     pass
   ...:
   ...:
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-4-9186c0cb3819> in <module>()
      5         super().__init__(name, bases, clsdict)
      6
----> 7 class Base(object):
      8     __metaclass__ = Meta
      9

<ipython-input-2-300b574b1003> in __init__(cls, name, bases, clsdict)
      3 class Meta(type):
      4     def __init__(cls, name, bases, clsdict):
----> 5         super().__init__(name, bases, clsdict)
      6
      7 class Base(object):

/Users/$USER/miniconda2/lib/python2.7/site-packages/future/builtins/newsuper.pyc in newsuper(typ, type_or_obj, framedepth)
     98             break    #  Found! Break out of the search loop.
     99         else:
--> 100             raise RuntimeError('super() called outside a method')
    101
    102     #  Dispatch to builtin super().

RuntimeError: super() called outside a method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants