Commit f9214693 authored by Benjamin Peterson's avatar Benjamin Peterson

Merged revisions 73774 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73774 | benjamin.peterson | 2009-07-02 12:06:17 -0500 (Thu, 02 Jul 2009) | 1 line

  only order comparisons are removed in py3k #6119
........
parent 585ad8ae
...@@ -22,6 +22,9 @@ class TestPy3KWarnings(unittest.TestCase): ...@@ -22,6 +22,9 @@ class TestPy3KWarnings(unittest.TestCase):
def assertWarning(self, _, warning, expected_message): def assertWarning(self, _, warning, expected_message):
self.assertEqual(str(warning.message), expected_message) self.assertEqual(str(warning.message), expected_message)
def assertNoWarning(self, _, recorder):
self.assertEqual(len(recorder.warnings), 0)
def test_backquote(self): def test_backquote(self):
expected = 'backquote not supported in 3.x; use repr()' expected = 'backquote not supported in 3.x; use repr()'
with check_warnings() as w: with check_warnings() as w:
...@@ -132,7 +135,7 @@ class TestPy3KWarnings(unittest.TestCase): ...@@ -132,7 +135,7 @@ class TestPy3KWarnings(unittest.TestCase):
def test_builtin_function_or_method_comparisons(self): def test_builtin_function_or_method_comparisons(self):
expected = ('builtin_function_or_method ' expected = ('builtin_function_or_method '
'inequality comparisons not supported in 3.x') 'order comparisons not supported in 3.x')
func = eval func = eval
meth = {}.get meth = {}.get
with check_warnings() as w: with check_warnings() as w:
...@@ -143,6 +146,12 @@ class TestPy3KWarnings(unittest.TestCase): ...@@ -143,6 +146,12 @@ class TestPy3KWarnings(unittest.TestCase):
self.assertWarning(meth <= func, w, expected) self.assertWarning(meth <= func, w, expected)
w.reset() w.reset()
self.assertWarning(meth >= func, w, expected) self.assertWarning(meth >= func, w, expected)
w.reset()
self.assertNoWarning(meth == func, w)
self.assertNoWarning(meth != func, w)
lam = lambda x: x
self.assertNoWarning(lam == func, w)
self.assertNoWarning(lam != func, w)
def test_sort_cmp_arg(self): def test_sort_cmp_arg(self):
expected = "the cmp argument is not supported in 3.x" expected = "the cmp argument is not supported in 3.x"
......
...@@ -15,6 +15,9 @@ Core and Builtins ...@@ -15,6 +15,9 @@ Core and Builtins
- Issue #4547: When debugging a very large function, it was not always - Issue #4547: When debugging a very large function, it was not always
possible to update the lineno attribute of the current frame. possible to update the lineno attribute of the current frame.
- Issue #6119: Fixed a incorrect Py3k warning about order comparisons of builtin
functions and methods.
- Issue #5330: C functions called with keyword arguments were not reported by - Issue #5330: C functions called with keyword arguments were not reported by
the various profiling modules (profile, cProfile). Patch by Hagen F�rstenau. the various profiling modules (profile, cProfile). Patch by Hagen F�rstenau.
......
...@@ -230,12 +230,9 @@ meth_richcompare(PyObject *self, PyObject *other, int op) ...@@ -230,12 +230,9 @@ meth_richcompare(PyObject *self, PyObject *other, int op)
PyObject *res; PyObject *res;
int eq; int eq;
if ((op != Py_EQ && op != Py_NE) || if (op != Py_EQ && op != Py_NE) {
!PyCFunction_Check(self) || /* Py3K warning if comparison isn't == or !=. */
!PyCFunction_Check(other)) if (PyErr_WarnPy3k("builtin_function_or_method order "
{
/* Py3K warning if types are not equal and comparison isn't == or != */
if (PyErr_WarnPy3k("builtin_function_or_method inequality "
"comparisons not supported in 3.x", 1) < 0) { "comparisons not supported in 3.x", 1) < 0) {
return NULL; return NULL;
} }
...@@ -243,6 +240,10 @@ meth_richcompare(PyObject *self, PyObject *other, int op) ...@@ -243,6 +240,10 @@ meth_richcompare(PyObject *self, PyObject *other, int op)
Py_INCREF(Py_NotImplemented); Py_INCREF(Py_NotImplemented);
return Py_NotImplemented; return Py_NotImplemented;
} }
else if (!PyCFunction_Check(self) || !PyCFunction_Check(other)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
a = (PyCFunctionObject *)self; a = (PyCFunctionObject *)self;
b = (PyCFunctionObject *)other; b = (PyCFunctionObject *)other;
eq = a->m_self == b->m_self; eq = a->m_self == b->m_self;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment