From 91108f049ffb35b4b9f0353a41d9c6097b37046d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 14 Oct 2015 18:25:31 +0200 Subject: [PATCH] Issue #25210: Change error message of do_richcompare() 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 | 3 ++- Doc/library/enum.rst | 2 +- Doc/library/pathlib.rst | 2 +- Objects/object.c | 5 ++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst index 510d1d49db..9c111b4bdf 100644 --- a/Doc/howto/argparse.rst +++ b/Doc/howto/argparse.rst @@ -547,7 +547,8 @@ And this is what it gives: Traceback (most recent call last): File "prog.py", line 11, in 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. diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst index 18519f033b..0fbbf5af79 100644 --- a/Doc/library/enum.rst +++ b/Doc/library/enum.rst @@ -257,7 +257,7 @@ members are not integers (but see `IntEnum`_ below):: >>> Color.red < Color.blue Traceback (most recent call last): File "", line 1, in - TypeError: unorderable types: Color() < Color() + TypeError: '<' not supported between instances of 'Color' and 'Color' Equality comparisons are defined though:: diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index 2f0654440d..ff5196de86 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -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 "", line 1, in - TypeError: unorderable types: PureWindowsPath() < PurePosixPath() + TypeError: '<' not supported between instances of 'PureWindowsPath' and 'PurePosixPath' Operators diff --git a/Objects/object.c b/Objects/object.c index 6fc4df1639..e1718eafcd 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -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; } -- 2.40.0