From f04be3fc1b2cb85a54a74d291c5250c53ca34661 Mon Sep 17 00:00:00 2001 From: Bruno da Silva de Oliveira Date: Wed, 26 Mar 2003 15:25:38 +0000 Subject: [PATCH] - No more "needs policy" warnings for functions that return PyObject* [SVN r18096] --- pyste/src/exporterutils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyste/src/exporterutils.py b/pyste/src/exporterutils.py index d5c5304f..774bd7cb 100644 --- a/pyste/src/exporterutils.py +++ b/pyste/src/exporterutils.py @@ -40,12 +40,15 @@ def HandlePolicy(function, policy): def IsString(type): 'Return True if the Type instance can be considered a string' return type.const and type.name == 'char' and isinstance(type, PointerType) + + def IsPyObject(type): + return type.FullName() == '_object *' # internal name of PyObject result = function.result # basic test if the result type demands a policy needs_policy = isinstance(result, (ReferenceType, PointerType)) # if the function returns const char*, a policy is not needed - if IsString(result): + if IsString(result) or IsPyObject(result): needs_policy = False # if returns a const T&, set the default policy if policy is None and result.const and isinstance(result, ReferenceType):