comparison Include/Python.h @ 63092:c96a722be1db 2.7

Issue #9036: Throughout the code base, Py_CHARMASK is used on 8-bit wide signed/unsigned chars or on integers directly derived from those. In all cases, it could be replaced by a simple cast to (unsigned char). Reasons for the change: a) Make the comment more explicit. b) If char is unsigned, the cast is optimized away. c) If char is unsigned, gcc emits spurious "array subscript has type 'char'" warnings.
author Stefan Krah <stefan@bytereef.org>
date Mon, 19 Jul 2010 13:14:01 +0000
parents d11fbc796499
children b36cb4602e21
comparison
equal deleted inserted replaced
63076:4bf03377584d 63092:c96a722be1db
148 148
149 /* PyArg_NoArgs should not be necessary. 149 /* PyArg_NoArgs should not be necessary.
150 Set ml_flags in the PyMethodDef to METH_NOARGS. */ 150 Set ml_flags in the PyMethodDef to METH_NOARGS. */
151 #define PyArg_NoArgs(v) PyArg_Parse(v, "") 151 #define PyArg_NoArgs(v) PyArg_Parse(v, "")
152 152
153 /* Convert a possibly signed character to a nonnegative int */ 153 /* Argument must be a char or an int in [-128, 127] or [0, 255]. */
154 /* XXX This assumes characters are 8 bits wide */
155 #ifdef __CHAR_UNSIGNED__
156 #define Py_CHARMASK(c) (c)
157 #else
158 #define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) 154 #define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
159 #endif
160 155
161 #include "pyfpe.h" 156 #include "pyfpe.h"
162 157
163 /* These definitions must match corresponding definitions in graminit.h. 158 /* These definitions must match corresponding definitions in graminit.h.
164 There's code in compile.c that checks that they are the same. */ 159 There's code in compile.c that checks that they are the same. */