diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-06-17 21:25:35 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-06-17 21:25:35 (GMT) |
commit | 2ba198d2fbd8d4dd33d2c40af012d622eb03c18f (patch) | |
tree | 863cc1709d50fb8ea12a05281f5db766be4c4efe /Modules/_heapqmodule.c | |
parent | 35c8658a74d9b51c6c4755514b02fe3f9d6bb6b8 (diff) | |
download | cpython-2ba198d2fbd8d4dd33d2c40af012d622eb03c18f.zip cpython-2ba198d2fbd8d4dd33d2c40af012d622eb03c18f.tar.gz cpython-2ba198d2fbd8d4dd33d2c40af012d622eb03c18f.tar.bz2 |
Remove 2.6 compatibility code:
now heapqueue items must implement the "<" operator.
The compatibility code could not work: all 3.0 objects have a __lt__ method
(which returns NotImplemented)
Twisted will have to adapt its DelayedCall class.
Diffstat (limited to 'Modules/_heapqmodule.c')
-rw-r--r-- | Modules/_heapqmodule.c | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c index 4cf6c95..7921823 100644 --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -8,28 +8,10 @@ annotated by François Pinard, and converted to C by Raymond Hettinger. #include "Python.h" -/* Older implementations of heapq used Py_LE for comparisons. Now, it uses - Py_LT so it will match min(), sorted(), and bisect(). Unfortunately, some - client code (Twisted for example) relied on Py_LE, so this little function - restores compatability by trying both. -*/ static int cmp_lt(PyObject *x, PyObject *y) { - int cmp; - static PyObject *lt = NULL; - - if (lt == NULL) { - lt = PyUnicode_FromString("__lt__"); - if (lt == NULL) - return -1; - } - if (PyObject_HasAttr(x, lt)) - return PyObject_RichCompareBool(x, y, Py_LT); - cmp = PyObject_RichCompareBool(y, x, Py_LE); - if (cmp != -1) - cmp = 1 - cmp; - return cmp; + return PyObject_RichCompareBool(x, y, Py_LT); } static int |