[Python-checkins] r46101 - in python/trunk: Doc/api/exceptions.tex Misc/NEWS Python/errors.c
georg.brandl
python-checkins at python.org
Tue May 23 13:17:21 CEST 2006
Author: georg.brandl
Date: Tue May 23 13:17:21 2006
New Revision: 46101
Modified:
python/trunk/Doc/api/exceptions.tex
python/trunk/Misc/NEWS
python/trunk/Python/errors.c
Log:
PyErr_NewException now accepts a tuple of base classes as its
"base" parameter.
Modified: python/trunk/Doc/api/exceptions.tex
==============================================================================
--- python/trunk/Doc/api/exceptions.tex (original)
+++ python/trunk/Doc/api/exceptions.tex Tue May 23 13:17:21 2006
@@ -341,7 +341,8 @@
The \member{__module__} attribute of the new class is set to the
first part (up to the last dot) of the \var{name} argument, and the
class name is set to the last part (after the last dot). The
- \var{base} argument can be used to specify an alternate base class.
+ \var{base} argument can be used to specify alternate base classes;
+ it can either be only one class or a tuple of classes.
The \var{dict} argument can be used to specify a dictionary of class
variables and methods.
\end{cfuncdesc}
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Tue May 23 13:17:21 2006
@@ -12,6 +12,9 @@
Core and builtins
-----------------
+- PyErr_NewException now accepts a tuple of base classes as its
+ "base" parameter.
+
- Patch #876206: function call speedup by retaining allocated frame
objects.
Modified: python/trunk/Python/errors.c
==============================================================================
--- python/trunk/Python/errors.c (original)
+++ python/trunk/Python/errors.c Tue May 23 13:17:21 2006
@@ -527,6 +527,7 @@
}
+
PyObject *
PyErr_NewException(char *name, PyObject *base, PyObject *dict)
{
@@ -559,9 +560,15 @@
classname = PyString_FromString(dot+1);
if (classname == NULL)
goto failure;
- bases = PyTuple_Pack(1, base);
- if (bases == NULL)
- goto failure;
+ if (PyTuple_Check(base)) {
+ bases = base;
+ /* INCREF as we create a new ref in the else branch */
+ Py_INCREF(bases);
+ } else {
+ bases = PyTuple_Pack(1, base);
+ if (bases == NULL)
+ goto failure;
+ }
result = PyClass_New(bases, dict, classname);
failure:
Py_XDECREF(bases);
More information about the Python-checkins
mailing list