mirror of
https://github.com/boostorg/python.git
synced 2026-01-28 07:22:31 +00:00
- No more "needs policy" warnings for functions that return PyObject*
[SVN r18096]
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user