mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
PyErr_NewException now accepts a tuple of base classes as its
"base" parameter.
This commit is contained in:
parent
da89b99533
commit
658d513328
3 changed files with 15 additions and 4 deletions
|
@ -341,7 +341,8 @@ for each thread.
|
||||||
The \member{__module__} attribute of the new class is set to the
|
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
|
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
|
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
|
The \var{dict} argument can be used to specify a dictionary of class
|
||||||
variables and methods.
|
variables and methods.
|
||||||
\end{cfuncdesc}
|
\end{cfuncdesc}
|
||||||
|
|
|
@ -12,6 +12,9 @@ What's New in Python 2.5 alpha 3?
|
||||||
Core and builtins
|
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
|
- Patch #876206: function call speedup by retaining allocated frame
|
||||||
objects.
|
objects.
|
||||||
|
|
||||||
|
|
|
@ -527,6 +527,7 @@ PyErr_Format(PyObject *exception, const char *format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyErr_NewException(char *name, PyObject *base, PyObject *dict)
|
PyErr_NewException(char *name, PyObject *base, PyObject *dict)
|
||||||
{
|
{
|
||||||
|
@ -559,9 +560,15 @@ PyErr_NewException(char *name, PyObject *base, PyObject *dict)
|
||||||
classname = PyString_FromString(dot+1);
|
classname = PyString_FromString(dot+1);
|
||||||
if (classname == NULL)
|
if (classname == NULL)
|
||||||
goto failure;
|
goto failure;
|
||||||
bases = PyTuple_Pack(1, base);
|
if (PyTuple_Check(base)) {
|
||||||
if (bases == NULL)
|
bases = base;
|
||||||
goto failure;
|
/* 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);
|
result = PyClass_New(bases, dict, classname);
|
||||||
failure:
|
failure:
|
||||||
Py_XDECREF(bases);
|
Py_XDECREF(bases);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue