summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-06-29 11:20:14 -0700
committerBenjamin Peterson <benjamin@python.org>2014-06-29 11:20:14 -0700
commitd9f5ffe912c5bcf86088c3af9a85fbef7841f53f (patch)
treefa2bf1e0eea7a18907f84fa8e31f391ef8a3f48c
parentb2cb78a8a0a2da037e56d981e22450089240e6e4 (diff)
downloadsix-d9f5ffe912c5bcf86088c3af9a85fbef7841f53f.tar.gz
simplify with_metaclass implementation
-rw-r--r--six.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/six.py b/six.py
index d42ac04..781b9af 100644
--- a/six.py
+++ b/six.py
@@ -698,20 +698,13 @@ else:
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
- # dummy metaclass for one level of class instantiation that replaces
- # itself with the actual metaclass. Because of internal type checks
- # we also need to make sure that we downgrade the custom metaclass
- # for one level to something closer to type (that's why __call__ and
- # __init__ comes back from type etc.).
+ # This requires a bit of explanation: the basic idea is to make a dummy
+ # metaclass for one level of class instantiation that replaces itself with
+ # the actual metaclass.
class metaclass(meta):
- __call__ = type.__call__
- __init__ = type.__init__
def __new__(cls, name, this_bases, d):
- if this_bases is None:
- return type.__new__(cls, name, (), d)
return meta(name, bases, d)
- return metaclass('temporary_class', None, {})
+ return type.__new__(metaclass, 'temporary_class', (), {})
def add_metaclass(metaclass):