[Python-checkins] bpo-9566: Fix compiler warnings in pyexpat.c (GH-10654)

Victor Stinner webhook-mailer at python.org
Thu Nov 22 07:21:49 EST 2018


https://github.com/python/cpython/commit/28f468cb19e3097079b7ce7850e6048de99022fa
commit: 28f468cb19e3097079b7ce7850e6048de99022fa
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018年11月22日T13:21:43+01:00
summary:
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
files:
M Modules/pyexpat.c
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index 10d5aedf1cdb..9384081f9ffc 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;


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /