Addressing feedback from pull request
This commit is contained in:
parent
c8f19f0afc
commit
b3767ae59f
1 changed files with 5 additions and 6 deletions
|
|
@ -54,15 +54,14 @@ else:
|
||||||
|
|
||||||
|
|
||||||
def with_metaclass(meta, *bases):
|
def with_metaclass(meta, *bases):
|
||||||
|
"""Create a base class with a metaclass."""
|
||||||
# This requires a bit of explanation: the basic idea is to make a
|
# This requires a bit of explanation: the basic idea is to make a
|
||||||
# dummy metaclass for one level of class instantiation that replaces
|
# dummy metaclass for one level of class instantiation that replaces
|
||||||
# itself with the actual metaclass.
|
# itself with the actual metaclass.
|
||||||
#
|
class metaclass(type):
|
||||||
# This has the advantage over six.with_metaclass in that it does not
|
def __new__(cls, name, this_bases, d):
|
||||||
# introduce dummy classes into the final MRO.
|
return meta(name, bases, d)
|
||||||
constructor = lambda c, name, b, dct: meta(name, bases, dct)
|
return type.__new__(metaclass, 'temporary_class', (), {})
|
||||||
metaclass = type('with_metaclass', (type,), {'__new__': constructor})
|
|
||||||
return type.__new__(metaclass, 'temporary_class', (object,), {})
|
|
||||||
|
|
||||||
|
|
||||||
# Certain versions of pypy have a bug where clearing the exception stack
|
# Certain versions of pypy have a bug where clearing the exception stack
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue