[Python-checkins] bpo-26219: Fix compiler warning in _PyCode_InitOpcache() (GH-13809)

Victor Stinner webhook-mailer at python.org
Tue Jun 4 11:08:38 EDT 2019


https://github.com/python/cpython/commit/ea9f168957f7236aae2185f65e0dc608a9a7a37b
commit: ea9f168957f7236aae2185f65e0dc608a9a7a37b
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2019-06-04T17:08:24+02:00
summary:

bpo-26219: Fix compiler warning in _PyCode_InitOpcache() (GH-13809)

Fix this MSVC warning:

    objects\codeobject.c(264): warning C4244: '=':
    conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data

files:
M Objects/codeobject.c

diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 0d9e5d16e768..63ce4793597a 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -261,7 +261,8 @@ _PyCode_InitOpcache(PyCodeObject *co)
 
         // TODO: LOAD_METHOD, LOAD_ATTR
         if (opcode == LOAD_GLOBAL) {
-            co->co_opcache_map[i] = ++opts;
+            opts++;
+            co->co_opcache_map[i] = (unsigned char)opts;
             if (opts > 254) {
                 break;
             }



More information about the Python-checkins mailing list