summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2013-04-19 13:54:11 -0400
committerBenjamin Peterson <benjamin@python.org>2013-04-19 13:54:11 -0400
commit4895c1c7bb958d40f645f3a9106cf22d093f004e (patch)
tree9855ea980aec7db496cac09147fd3cc0344203ee
parentb3f712df8c118d6f264dd11f0aad6a528ebb3696 (diff)
downloadsix-4895c1c7bb958d40f645f3a9106cf22d093f004e.tar.gz
allow multiple base classes to be given to with_metaclass (fixes #23)
-rw-r--r--CHANGES2
-rw-r--r--documentation/index.rst6
-rw-r--r--six.py4
-rw-r--r--test_six.py7
4 files changed, 14 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index ae9b9b8..257184b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,8 @@ This file lists the changes in each six version.
Development version
-------------------
+- Issue #23: Allow multiple base classes to be passed to with_metaclass.
+
- Issue #24: Add six.moves.range alias. This exactly the same as the current
xrange alias.
diff --git a/documentation/index.rst b/documentation/index.rst
index 52dc2e2..a1513b5 100644
--- a/documentation/index.rst
+++ b/documentation/index.rst
@@ -250,10 +250,10 @@ Python 2 and 3.
traceback can be specified with the *exc_traceback* parameter.
-.. function:: with_metaclass(metaclass, base=object)
+.. function:: with_metaclass(metaclass, *bases)
- Create a new class with base class *base* and metaclass *metaclass*. This is
- designed to be used in class declarations like this: ::
+ Create a new class with base classes *bases* and metaclass *metaclass*. This
+ is designed to be used in class declarations like this: ::
from six import with_metaclass
diff --git a/six.py b/six.py
index b5b28ec..a315053 100644
--- a/six.py
+++ b/six.py
@@ -400,6 +400,6 @@ else:
_add_doc(reraise, """Reraise an exception.""")
-def with_metaclass(meta, base=object):
+def with_metaclass(meta, *bases):
"""Create a base class with a metaclass."""
- return meta("NewBase", (base,), {})
+ return meta("NewBase", bases, {})
diff --git a/test_six.py b/test_six.py
index 58a3a19..d1957ab 100644
--- a/test_six.py
+++ b/test_six.py
@@ -456,3 +456,10 @@ def test_with_metaclass():
pass
assert type(X) is Meta
assert issubclass(X, Base)
+ class Base2(object):
+ pass
+ class X(six.with_metaclass(Meta, Base, Base2)):
+ pass
+ assert type(X) is Meta
+ assert issubclass(X, Base)
+ assert issubclass(X, Base2)