diff Include/Python.h @ 63089:d35782ac21f8

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 12:36:57 +0000
parents 4fd3ab5fa71d
children c16803bbd790
line wrap: on
line diff
--- a/Include/Python.h	Mon Jul 19 11:28:05 2010 +0000
+++ b/Include/Python.h	Mon Jul 19 12:36:57 2010 +0000
@@ -134,13 +134,8 @@
 }
 #endif
 
-/* 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"