Kaydet (Commit) d751105a authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Backport 2.103:

Made conversion failure error messages consistent between types.
üst c52a36f6
...@@ -903,7 +903,7 @@ PyNumber_Int(PyObject *o) ...@@ -903,7 +903,7 @@ PyNumber_Int(PyObject *o)
if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len))
return int_from_string((char*)buffer, buffer_len); return int_from_string((char*)buffer, buffer_len);
return type_error("object can't be converted to int"); return type_error("int() argument must be a string or a number");
} }
/* Add a check for embedded NULL-bytes in the argument. */ /* Add a check for embedded NULL-bytes in the argument. */
...@@ -960,7 +960,7 @@ PyNumber_Long(PyObject *o) ...@@ -960,7 +960,7 @@ PyNumber_Long(PyObject *o)
if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len))
return long_from_string(buffer, buffer_len); return long_from_string(buffer, buffer_len);
return type_error("object can't be converted to long"); return type_error("long() argument must be a string or a number");
} }
PyObject * PyObject *
......
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