[issue9036] Simplify Py_CHARMASK
Stefan Krah
report at bugs.python.org
Sun Jun 20 15:12:08 CEST 2010
New submission from Stefan Krah <stefan-usenet at bytereef.org>:
This feature request is extracted from issue 9020, where Py_CHARMASK(c)
was used on EOF, producing different results depending on whether __CHAR_UNSIGNED__ is defined or not.
The preferred fix for issue 9020 is to check for EOF before using
Py_CHARMASK, so this is only loosely related.
I've looked through the source tree to determine how Py_CHARMASK
is meant to be used. It seems that it is only used in situations
where one would actually want to cast a char to an unsigned char,
like isspace((unsigned char)c).
Simplifications:
1) Python.h already enforces that an unsigned char is 8 bit wide. Thus,
((unsigned char)((c) & 0xff)) and ((unsigned char)(c)) should produce
the same results.
2) There is no reason not to do the cast when __CHAR_UNSIGNED__ is
defined (it will be a no-op).
----------
components: Interpreter Core
files: py_charmask.patch
keywords: needs review, patch
messages: 108234
nosy: eric.smith, loewis, pitrou, skrah
priority: normal
severity: normal
stage: patch review
status: open
title: Simplify Py_CHARMASK
type: feature request
versions: Python 2.7, Python 3.1, Python 3.2
Added file: http://bugs.python.org/file17724/py_charmask.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9036>
_______________________________________
More information about the Python-bugs-list
mailing list