From 9d6ebb4c34e3af48508575abb6d7798b39e02563 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 6 Aug 2009 18:49:41 +0000 Subject: [PATCH] implicitly coerce strings to InternalName pointers if needed --- dtool/src/interrogatedb/py_panda.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index c539cec127..c909a6b741 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -73,6 +73,15 @@ attempt_coercion(PyObject *self, Dtool_PyTypedObject *classdef, // Attempt coercion: try to create a temporary instance of the // required class using the supplied parameter. PyObject *obj = PyObject_Call((PyObject *)classdef, self, NULL); + if (obj == NULL) { + // That didn't work; try to call a static "make" method instead. + PyObject *make = PyObject_GetAttrString((PyObject *)classdef, "make"); + if (make != NULL) { + PyErr_Clear(); + obj = PyObject_Call(make, self, NULL); + Py_DECREF(make); + } + } if (obj != NULL) { // Well, whaddaya know? The supplied parameter(s) suited // the object's constructor. Now we have a temporary object