mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
bpo-29730: replace some calls to PyNumber_Check and improve some error messages (#650)
This commit is contained in:
parent
b7c9150b68
commit
004251059b
5 changed files with 39 additions and 25 deletions
|
|
@ -247,14 +247,15 @@ mmap_convert_ssize_t(PyObject *obj, void *result) {
|
|||
if (obj == Py_None) {
|
||||
limit = -1;
|
||||
}
|
||||
else if (PyNumber_Check(obj)) {
|
||||
else if (PyIndex_Check(obj)) {
|
||||
limit = PyNumber_AsSsize_t(obj, PyExc_OverflowError);
|
||||
if (limit == -1 && PyErr_Occurred())
|
||||
if (limit == -1 && PyErr_Occurred()) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"integer argument expected, got '%.200s'",
|
||||
"argument should be integer or None, not '%.200s'",
|
||||
Py_TYPE(obj)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue