mirror of https://github.com/python/cpython
Add PyObject_Not().
This commit is contained in:
parent
6b529ae0c0
commit
c3d3f9692d
|
@ -382,6 +382,18 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Implemented elsewhere:
|
||||||
|
|
||||||
|
int PyObject_Not(PyObject *o);
|
||||||
|
|
||||||
|
Returns 0 if the object, o, is considered to be true, and
|
||||||
|
1 otherwise. This is equivalent to the Python expression:
|
||||||
|
not o
|
||||||
|
|
||||||
|
This function always succeeds.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
PyObject *PyObject_Type Py_PROTO((PyObject *o));
|
PyObject *PyObject_Type Py_PROTO((PyObject *o));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -271,6 +271,7 @@ extern int PyObject_SetAttr Py_PROTO((PyObject *, PyObject *, PyObject *));
|
||||||
extern int PyObject_HasAttr Py_PROTO((PyObject *, PyObject *));
|
extern int PyObject_HasAttr Py_PROTO((PyObject *, PyObject *));
|
||||||
extern long PyObject_Hash Py_PROTO((PyObject *));
|
extern long PyObject_Hash Py_PROTO((PyObject *));
|
||||||
extern int PyObject_IsTrue Py_PROTO((PyObject *));
|
extern int PyObject_IsTrue Py_PROTO((PyObject *));
|
||||||
|
extern int PyObject_Not Py_PROTO((PyObject *));
|
||||||
extern int PyCallable_Check Py_PROTO((PyObject *));
|
extern int PyCallable_Check Py_PROTO((PyObject *));
|
||||||
extern int PyNumber_Coerce Py_PROTO((PyObject **, PyObject **));
|
extern int PyNumber_Coerce Py_PROTO((PyObject **, PyObject **));
|
||||||
extern int PyNumber_CoerceEx Py_PROTO((PyObject **, PyObject **));
|
extern int PyNumber_CoerceEx Py_PROTO((PyObject **, PyObject **));
|
||||||
|
|
|
@ -470,6 +470,20 @@ PyObject_IsTrue(v)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* equivalent of 'not v'
|
||||||
|
Return -1 if an error occurred */
|
||||||
|
|
||||||
|
int
|
||||||
|
PyObject_Not(v)
|
||||||
|
PyObject *v;
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
res = PyObject_IsTrue(v);
|
||||||
|
if (res < 0)
|
||||||
|
return res;
|
||||||
|
return res == 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Coerce two numeric types to the "larger" one.
|
/* Coerce two numeric types to the "larger" one.
|
||||||
Increment the reference count on each argument.
|
Increment the reference count on each argument.
|
||||||
Return -1 and raise an exception if no coercion is possible
|
Return -1 and raise an exception if no coercion is possible
|
||||||
|
|
Loading…
Reference in New Issue