diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-10-14 16:25:31 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-10-14 16:25:31 (GMT) |
commit | 91108f049ffb35b4b9f0353a41d9c6097b37046d (patch) | |
tree | cfa8d97b646af5c3544f43bed2bc4ca46c85392e | |
parent | dbb98c1443fa312964cda8b851c7bca9323588de (diff) | |
download | cpython-91108f049ffb35b4b9f0353a41d9c6097b37046d.zip cpython-91108f049ffb35b4b9f0353a41d9c6097b37046d.tar.gz cpython-91108f049ffb35b4b9f0353a41d9c6097b37046d.tar.bz2 |
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'
-rw-r--r-- | Doc/howto/argparse.rst | 3 | ||||
-rw-r--r-- | Doc/library/enum.rst | 2 | ||||
-rw-r--r-- | Doc/library/pathlib.rst | 2 | ||||
-rw-r--r-- | Objects/object.c | 5 |
4 files changed, 6 insertions, 6 deletions
diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst index 510d1d4..9c111b4 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 <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. diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst index 18519f0..0fbbf5a 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 "<stdin>", line 1, in <module> - 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 2f06544..ff5196d 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 "<stdin>", line 1, in <module> - 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 6fc4df1..e1718ea 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; } |