summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-22 12:21:43 (GMT)
committerGitHub <noreply@github.com>2018-11-22 12:21:43 (GMT)
commit28f468cb19e3097079b7ce7850e6048de99022fa (patch)
tree0bda352ec8b1777c3790882e315c97eb939119de /Modules
parentcdbcb773f5db24e23fa90e644ec620d54bd08127 (diff)
downloadcpython-28f468cb19e3097079b7ce7850e6048de99022fa.zip
cpython-28f468cb19e3097079b7ce7850e6048de99022fa.tar.gz
cpython-28f468cb19e3097079b7ce7850e6048de99022fa.tar.bz2
bpo-9566: Fix compiler warnings in pyexpat.c (GH-10654)
Explicit cast a pointer difference (intptr_t) to int to fix two warnings on 64-bit Windows: Modules\pyexpat.c(1181): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data Modules\pyexpat.c(1192): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
Diffstat (limited to 'Modules')
-rw-r--r--Modules/pyexpat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index 10d5aed..9384081 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1178,7 +1178,8 @@ xmlparse_dealloc(xmlparseobject *self)
static PyObject *
xmlparse_handler_getter(xmlparseobject *self, struct HandlerInfo *hi)
{
- int handlernum = hi - handler_info;
+ assert((hi - handler_info) < (Py_ssize_t)Py_ARRAY_LENGTH(handler_info));
+ int handlernum = (int)(hi - handler_info);
PyObject *result = self->handlers[handlernum];
if (result == NULL)
result = Py_None;
@@ -1189,7 +1190,8 @@ xmlparse_handler_getter(xmlparseobject *self, struct HandlerInfo *hi)
static int
xmlparse_handler_setter(xmlparseobject *self, PyObject *v, struct HandlerInfo *hi)
{
- int handlernum = hi - handler_info;
+ assert((hi - handler_info) < (Py_ssize_t)Py_ARRAY_LENGTH(handler_info));
+ int handlernum = (int)(hi - handler_info);
if (v == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Cannot delete attribute");
return -1;