summaryrefslogtreecommitdiffstats
path: root/Modules/mmapmodule.c
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-03-12 22:37:05 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-03-12 22:37:05 (GMT)
commit004251059b9c5e48d47cb30b94bcb92cb44d3adf (patch)
treec61cee2b14c069cf40ce39910980d338687f4bc7 /Modules/mmapmodule.c
parentb7c9150b68516878175e5373983189d6deea470c (diff)
downloadcpython-004251059b9c5e48d47cb30b94bcb92cb44d3adf.zip
cpython-004251059b9c5e48d47cb30b94bcb92cb44d3adf.tar.gz
cpython-004251059b9c5e48d47cb30b94bcb92cb44d3adf.tar.bz2
bpo-29730: replace some calls to PyNumber_Check and improve some error messages (#650)
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r--Modules/mmapmodule.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 7a94464..7c15d37 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -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;
}