[issue9036] Simplify Py_CHARMASK
Antoine Pitrou
report at bugs.python.org
Thu Jun 24 18:28:00 CEST 2010
Antoine Pitrou <pitrou at free.fr> added the comment:
> Ok, let's say we use ((unsigned char)((c) & 0xff)) also for
> __CHAR_UNSIGNED__.
>
> What should the comment say about the intended argument?
That it's either in [-128; 127] or in [0; 255] ?
> Index: Objects/unicodeobject.c
> ===================================================================
> --- Objects/unicodeobject.c (revision 82192)
> +++ Objects/unicodeobject.c (working copy)
> @@ -8417,6 +8417,7 @@
> else if (c >= '0' && c <= '9') {
> prec = c - '0';
> while (--fmtcnt >= 0) {
> + /* XXX: c and *fmt are Py_UNICODE */
> c = Py_CHARMASK(*fmt++);
This is a funny bug:
>>> u"%.1\u1032f" % (1./3)
u'0.333333333333'
> Index: Modules/_json.c
> ===================================================================
> --- Modules/_json.c (revision 82192)
> +++ Modules/_json.c (working copy)
> @@ -603,6 +603,7 @@
> }
> }
> else {
> + /* XXX: c is Py_UNICODE */
> char c_char = Py_CHARMASK(c);
This block can only be entered if c <= 0x7f (`has_unicode` is false), so it's not a problem.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9036>
_______________________________________
More information about the Python-bugs-list
mailing list