Skip to content

Commit 8a20f8b

Browse files
committed
Simplify code by taking advantage of high-level object() facilities
[SVN r15053]
1 parent e1099e9 commit 8a20f8b

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/object/class.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <boost/python/object_protocol.hpp>
1414
#include <boost/detail/binary_search.hpp>
1515
#include <boost/python/self.hpp>
16+
#include <boost/python/dict.hpp>
1617
#include <boost/bind.hpp>
1718
#include <functional>
1819
#include <vector>
@@ -275,17 +276,9 @@ namespace objects
275276
if (module_name)
276277
module_name += '.';
277278

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-
285279
// 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));
289282

290283
if (scope().ptr() != Py_None)
291284
scope().attr(name) = result;

0 commit comments

Comments
 (0)