mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Close SF bug 563740. complex() now finds __complex__() in new style classes.
Made conversion failure error messages consistent between types. Added related unittests.
This commit is contained in:
parent
56f46f8d8c
commit
478d47a168
3 changed files with 36 additions and 28 deletions
|
|
@ -903,7 +903,7 @@ PyNumber_Int(PyObject *o)
|
|||
if (!PyObject_AsCharBuffer(o, &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. */
|
||||
|
|
@ -960,7 +960,7 @@ PyNumber_Long(PyObject *o)
|
|||
if (!PyObject_AsCharBuffer(o, &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 *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue