From 5a8bd5afdaaeb84849a8f37e23e6c454bf3f66b2 Mon Sep 17 00:00:00 2001 From: Duy-Nguyen Ta Date: Mon, 6 Mar 2017 01:18:19 -0500 Subject: [PATCH] [cython] bypass a problem with no default constructor Add this to support cyCreateFromShared, which needs to call the default Python constructor to construct the Python object before reassigning the internal shared ptr to the c++ object. --- wrap/Class.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wrap/Class.cpp b/wrap/Class.cpp index cd7dd4ca6..7aa4cd72a 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -832,9 +832,11 @@ void Class::emit_cython_pyx(FileWriter& pyxFile, const std::vector& allCl << pyxClassName() << "_" << i << "(*args, **kwargs):\n pass\n"; } - if (constructor.nrOverloads()>0) + if (constructor.nrOverloads()>0) { + pyxFile.oss << " elif len(args)+len(kwargs)==0:\n return\n"; pyxFile.oss << " else:\n raise TypeError('" << pyxClassName() << " construction failed!')\n"; + } pyxInitParentObj(pyxFile, " self", "self." + shared_pxd_obj_in_pyx(), allClasses); pyxFile.oss << "\n";