Skip to content

Commit

Permalink
bpo-9566: Fix compiler warnings in pyexpat.c (GH-10654)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vstinner committed Nov 22, 2018
1 parent cdbcb77 commit 28f468c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Modules/pyexpat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 28f468c

Please sign in to comment.