Kaydet (Commit) b0061c8e authored tarafından Georg Brandl's avatar Georg Brandl

Remove "non-mapping" and "non-sequence" from TypeErrors raised by

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.
üst f3321b5e
...@@ -1114,7 +1114,7 @@ PySequence_Size(PyObject *s) ...@@ -1114,7 +1114,7 @@ PySequence_Size(PyObject *s)
if (m && m->sq_length) if (m && m->sq_length)
return m->sq_length(s); 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; return -1;
} }
...@@ -1705,7 +1705,7 @@ PyMapping_Size(PyObject *o) ...@@ -1705,7 +1705,7 @@ PyMapping_Size(PyObject *o)
if (m && m->mp_length) if (m && m->mp_length)
return m->mp_length(o); 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; return -1;
} }
......
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