]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 82966 via svnmerge from
authorStefan Krah <stefan@bytereef.org>
Mon, 19 Jul 2010 13:00:48 +0000 (13:00 +0000)
committerStefan Krah <stefan@bytereef.org>
Mon, 19 Jul 2010 13:00:48 +0000 (13:00 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r82966 | stefan.krah | 2010-07-19 14:36:57 +0200 (Mon, 19 Jul 2010) | 13 lines

  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.
........

Include/Python.h

index 5c6e1f2c2259ed8b8bdb5dbcc9f9dda545bd863a..0d8a5f575343c150ede0b7b406ee5b105297853e 100644 (file)
 /* _Py_Mangle is defined in compile.c */
 PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
 
-/* Convert a possibly signed character to a nonnegative int */
-/* XXX This assumes characters are 8 bits wide */
-#ifdef __CHAR_UNSIGNED__
-#define Py_CHARMASK(c)         (c)
-#else
+/* Argument must be a char or an int in [-128, 127] or [0, 255]. */
 #define Py_CHARMASK(c)         ((unsigned char)((c) & 0xff))
-#endif
 
 #include "pyfpe.h"