diff options
author | Raymond Hettinger <python@rcn.com> | 2003-01-18 23:22:20 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-01-18 23:22:20 (GMT) |
commit | 9543b340066e85bb920a0655edf33e11050d7b08 (patch) | |
tree | d111331abed4d1df42473b5a0bdf3890b7574e7d /Modules | |
parent | 18acea7c8ea44fe1e655d64fe4f04fc9710f9ea7 (diff) | |
download | cpython-9543b340066e85bb920a0655edf33e11050d7b08.zip cpython-9543b340066e85bb920a0655edf33e11050d7b08.tar.gz cpython-9543b340066e85bb920a0655edf33e11050d7b08.tar.bz2 |
SF patch #670423: Add missing identity tests to operator.c
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/operator.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Modules/operator.c b/Modules/operator.c index 5371b95..7638fb8 100644 --- a/Modules/operator.c +++ b/Modules/operator.c @@ -108,6 +108,28 @@ op_pow(PyObject *s, PyObject *a) } static PyObject* +is_(PyObject *s, PyObject *a) +{ + PyObject *a1, *a2, *result = NULL; + if (PyArg_UnpackTuple(a,"is_", 2, 2, &a1, &a2)) { + result = (a1 == a2) ? Py_True : Py_False; + Py_INCREF(result); + } + return result; +} + +static PyObject* +is_not(PyObject *s, PyObject *a) +{ + PyObject *a1, *a2, *result = NULL; + if (PyArg_UnpackTuple(a,"is_not", 2, 2, &a1, &a2)) { + result = (a1 != a2) ? Py_True : Py_False; + Py_INCREF(result); + } + return result; +} + +static PyObject* op_getslice(PyObject *s, PyObject *a) { PyObject *a1; @@ -182,6 +204,8 @@ spam1(countOf, spam1o(isMappingType, "isMappingType(a) -- Return True if a has a mapping type, False otherwise.") +spam1(is_, "is_(a, b) -- Same as a is b.") +spam1(is_not, "is_not(a, b) -- Same as a is not b.") spam2(add,__add__, "add(a, b) -- Same as a + b.") spam2(sub,__sub__, "sub(a, b) -- Same as a - b.") spam2(mul,__mul__, "mul(a, b) -- Same as a * b.") |