mirror of
https://github.com/python/cpython.git
synced 2026-01-04 14:32:21 +00:00
Added ResObj_OptNew, like ResObj_New but returns None when passed NULL.
This commit is contained in:
parent
caf7505edc
commit
9f37c6d91c
1 changed files with 13 additions and 0 deletions
|
|
@ -30,6 +30,19 @@ class ResMethod(ResMixIn, MethodGenerator): pass
|
|||
"""
|
||||
|
||||
finalstuff = finalstuff + """
|
||||
|
||||
/* Alternative version of ResObj_New, which returns None for null argument */
|
||||
PyObject *ResObj_OptNew(itself)
|
||||
Handle itself;
|
||||
{
|
||||
ResourceObject *it;
|
||||
if (itself == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
return ResObj_New(itself);
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
initstuff = initstuff + """
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue