Skip to content

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

Open
@kdheepak

Description

@kdheepak
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions