]> granicus.if.org Git - python/commitdiff
Fix comparing complex to non-complex numbers.
authorGuido van Rossum <guido@python.org>
Mon, 21 Aug 2006 18:27:07 +0000 (18:27 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 21 Aug 2006 18:27:07 +0000 (18:27 +0000)
BROKEN
Objects/complexobject.c

diff --git a/BROKEN b/BROKEN
index 3468e43086e30c76dc8c09a6afa47c7173c365ec..6d1b4fe6159936403648ae5f0a30ba7c22166a1f 100644 (file)
--- a/BROKEN
+++ b/BROKEN
@@ -110,31 +110,3 @@ Traceback (most recent call last):
   File "../Lib/test/test_set.py", line 291, in test_remove
     self.assert_(self.thetype(self.word) in s)
 AssertionError
-
-////////////////////////////////////////////////////////////////////////
-test_compare
-////////////////////////////////////////////////////////////////////////
-test test_compare failed -- Traceback (most recent call last):
-  File "/Users/nnorwitz/build/python/py3k.2/Lib/test/test_compare.py", line 28, in test_comparisons
-    self.assertEqual(a, b)
-AssertionError: 2 != (2+0j)
-
-////////////////////////////////////////////////////////////////////////
-test_complex
-////////////////////////////////////////////////////////////////////////
-======================================================================
-FAIL: test_pow (test.test_complex.ComplexTest)
-----------------------------------------------------------------------
-Traceback (most recent call last):
-  File "/Users/nnorwitz/build/python/py3k.2/Lib/test/test_complex.py", line 130, in test_pow
-    self.assertEqual(a ** 0j, 1)
-AssertionError: (1+0j) != 1
-
-======================================================================
-FAIL: test_richcompare (test.test_complex.ComplexTest)
-----------------------------------------------------------------------
-Traceback (most recent call last):
-  File "/Users/nnorwitz/build/python/py3k.2/Lib/test/test_complex.py", line 96, in test_richcompare
-    self.assertRaises(OverflowError, complex.__eq__, 1+1j, 1L<<10000)
-AssertionError: OverflowError not raised
-
index e081256d81bcd45d67fd9b46b68909d4db37febc..2713e3eeec18f03de2d9f57962330a12faf0c425 100644 (file)
@@ -576,19 +576,13 @@ complex_nonzero(PyComplexObject *v)
 static PyObject *
 complex_richcompare(PyObject *v, PyObject *w, int op)
 {
-       Py_complex i, j;
        PyObject *res;
-
-       /* Make sure both arguments are complex. */
-       if (!(PyComplex_Check(v) && PyComplex_Check(w))) {
-               Py_INCREF(Py_NotImplemented);
-               return Py_NotImplemented;
-       }
-
-       i = ((PyComplexObject *)v)->cval;
-       j = ((PyComplexObject *)w)->cval;
+       Py_complex i, j;
+        TO_COMPLEX(v, i);
+        TO_COMPLEX(w, j);
 
        if (op != Py_EQ && op != Py_NE) {
+               /* XXX Should eventually return NotImplemented */
                PyErr_SetString(PyExc_TypeError,
                        "no ordering relation is defined for complex numbers");
                return NULL;