2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-27 07:02:15 +00:00

Automatic class def_init(), abstract class __init__ errors

Fixed line endings
Suppressed warnings


[SVN r14828]
This commit is contained in:
Dave Abrahams
2002-08-14 06:26:33 +00:00
parent c5ee39f54b
commit 6e06ff048d
31 changed files with 1045 additions and 115 deletions

View File

@@ -323,6 +323,26 @@ namespace objects
throw_error_already_set();
}
namespace
{
extern "C" PyObject* no_init(PyObject*, PyObject*)
{
::PyErr_SetString(::PyExc_RuntimeError, "This class cannot be instantiated from Python");
return NULL;
}
static ::PyMethodDef no_init_def = {
"__init__", no_init, METH_VARARGS,
"Raises an exception\n"
"This class cannot be instantiated from Python\n"
};
}
void class_base::def_no_init()
{
handle<> f(::PyCFunction_New(&no_init_def, 0));
this->setattr("__init__", object(f));
}
void class_base::enable_pickling(bool getstate_manages_dict)
{
setattr("__reduce__", object(make_instance_reduce_function()));