|
13 | 13 | #include <boost/python/object_protocol.hpp> |
14 | 14 | #include <boost/detail/binary_search.hpp> |
15 | 15 | #include <boost/python/self.hpp> |
| 16 | +#include <boost/python/dict.hpp> |
16 | 17 | #include <boost/bind.hpp> |
17 | 18 | #include <functional> |
18 | 19 | #include <vector> |
@@ -275,17 +276,9 @@ namespace objects |
275 | 276 | if (module_name) |
276 | 277 | module_name += '.'; |
277 | 278 |
|
278 | | - // Build the (name, bases, dict) tuple for creating the new class |
279 | | - handle<> args(PyTuple_New(3)); |
280 | | - PyTuple_SET_ITEM(args.get(), 0, incref((module_name + name).ptr())); |
281 | | - PyTuple_SET_ITEM(args.get(), 1, bases.release()); |
282 | | - handle<> d(PyDict_New()); |
283 | | - PyTuple_SET_ITEM(args.get(), 2, d.release()); |
284 | | - |
285 | 279 | // Call the class metatype to create a new class |
286 | | - PyObject* c = PyObject_CallObject(upcast<PyObject>(class_metatype().get()), args.get()); |
287 | | - assert(PyType_IsSubtype(c->ob_type, &PyType_Type)); |
288 | | - object result = object(python::detail::new_reference(c)); |
| 280 | + object result = object(class_metatype())(module_name + name, bases, dict()); |
| 281 | + assert(PyType_IsSubtype(result.ptr()->ob_type, &PyType_Type)); |
289 | 282 |
|
290 | 283 | if (scope().ptr() != Py_None) |
291 | 284 | scope().attr(name) = result; |
|
0 commit comments