diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-05-05 21:05:01 +0000 |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-05-05 21:05:01 +0000 |
commit | 8747e284c6ca13ef34713e4d9feffb041dcd1683 (patch) | |
tree | 476d0a97c7247821569abfd0f6d3e701dd488fd3 /Include/abstract.h | |
parent | 9079fb4bb03899198bb794f0038436a5004484cb (diff) | |
download | cpython-8747e284c6ca13ef34713e4d9feffb041dcd1683.tar.gz |
Reimplement PySequence_Contains() and instance_contains(), so they work
safely together and don't duplicate logic (the common logic was factored
out into new private API function _PySequence_IterContains()).
Visible change:
some_complex_number in some_instance
no longer blows up if some_instance has __getitem__ but neither
__contains__ nor __iter__. test_iter changed to ensure that remains true.
Diffstat (limited to 'Include/abstract.h')
-rw-r--r-- | Include/abstract.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Include/abstract.h b/Include/abstract.h index d5f4a9978d..9082edb0b8 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -932,7 +932,17 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ expression: o.count(value). */ - DL_IMPORT(int) PySequence_Contains(PyObject *o, PyObject *value); + DL_IMPORT(int) PySequence_Contains(PyObject *seq, PyObject *ob); + /* + Return -1 if error; 1 if ob in seq; 0 if ob not in seq. + Use __contains__ if possible, else _PySequence_IterContains(). + */ + + DL_IMPORT(int) _PySequence_IterContains(PyObject *seq, PyObject *ob); + /* + Return -1 if error; 1 if ob in seq; 0 if ob not in seq. + Always uses the iteration protocol, and only Py_EQ comparisons. + */ /* For DLL-level backwards compatibility */ #undef PySequence_In |