]> granicus.if.org Git - python/commitdiff
Issue #25210: Change error message of do_richcompare()
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 14 Oct 2015 16:25:31 +0000 (18:25 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 14 Oct 2015 16:25:31 +0000 (18:25 +0200)
Don't add parenthesis to type names. Add also quotes around the type names.

Before:

  TypeError: unorderable types: int() < NoneType()

After:

  TypeError: '<' not supported between instances of 'int' and 'NoneType'

Doc/howto/argparse.rst
Doc/library/enum.rst
Doc/library/pathlib.rst
Objects/object.c

index 510d1d49dbd5f62ea0c0485e319f31ba7ce6b687..9c111b4bdf533873bc021b34325c907308a89d70 100644 (file)
@@ -547,7 +547,8 @@ And this is what it gives:
    Traceback (most recent call last):
      File "prog.py", line 11, in <module>
        if args.verbosity >= 2:
-   TypeError: unorderable types: NoneType() >= int()
+   TypeError: '>=' not supported between instances of 'NoneType' and 'int'
+
 
 * First output went well, and fixes the bug we had before.
   That is, we want any value >= 2 to be as verbose as possible.
index 18519f033b93615d80fff214a3c3a8951914d93e..0fbbf5af79fc4eae773b47957fa1f746db618d05 100644 (file)
@@ -257,7 +257,7 @@ members are not integers (but see `IntEnum`_ below)::
     >>> Color.red < Color.blue
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
-    TypeError: unorderable types: Color() < Color()
+    TypeError: '<' not supported between instances of 'Color' and 'Color'
 
 Equality comparisons are defined though::
 
index 2f0654440d08519fd375bdba822dc8384431ec34..ff5196de86002fbcf81ef75963ae013a5d1d91f0 100644 (file)
@@ -195,7 +195,7 @@ Paths of a different flavour compare unequal and cannot be ordered::
    >>> PureWindowsPath('foo') < PurePosixPath('foo')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
-   TypeError: unorderable types: PureWindowsPath() < PurePosixPath()
+   TypeError: '<' not supported between instances of 'PureWindowsPath' and 'PurePosixPath'
 
 
 Operators
index 6fc4df16397aac74ce02b440425c844e7130ab3c..e1718eafcdbf77f1dc3f7d8cc8b37257008643e7 100644 (file)
@@ -686,11 +686,10 @@ do_richcompare(PyObject *v, PyObject *w, int op)
         res = (v != w) ? Py_True : Py_False;
         break;
     default:
-        /* XXX Special-case None so it doesn't show as NoneType() */
         PyErr_Format(PyExc_TypeError,
-                     "unorderable types: %.100s() %s %.100s()",
-                     v->ob_type->tp_name,
+                     "'%s' not supported between instances of '%.100s' and '%.100s'",
                      opstrings[op],
+                     v->ob_type->tp_name,
                      w->ob_type->tp_name);
         return NULL;
     }