]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Remove "non-mapping" and "non-sequence" from TypeErrors raised by
authorGeorg Brandl <georg@python.org>
Tue, 8 Aug 2006 11:56:21 +0000 (11:56 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 8 Aug 2006 11:56:21 +0000 (11:56 +0000)
PyMapping_Size and PySequence_Size.

Because len() tries first sequence, then mapping size, it will always
raise a "non-mapping object has no len" error which is confusing.

Objects/abstract.c

index 638e41787d07acd39e8cd365c4ef4a9dc6c7d634..bad9f965415eeced89713d3691d8bb4e306a81b6 100644 (file)
@@ -1114,7 +1114,7 @@ PySequence_Size(PyObject *s)
        if (m && m->sq_length)
                return m->sq_length(s);
 
-       type_error("non-sequence object of type '%.200s' has no len()", s);
+       type_error("object of type '%.200s' has no len()", s);
        return -1;
 }
 
@@ -1705,7 +1705,7 @@ PyMapping_Size(PyObject *o)
        if (m && m->mp_length)
                return m->mp_length(o);
 
-       type_error("non-mapping object of type '%.200s' has no len()", o);
+       type_error("object of type '%.200s' has no len()", o);
        return -1;
 }