[issue3098] sys.sizeof test fails with wide unicode

Marc-Andre Lemburg report at bugs.python.org
Mon Jun 16 11:57:20 CEST 2008


Marc-Andre Lemburg <mal at egenix.com> added the comment:

On 2008-06-13 22:32, Antoine Pitrou wrote:
> Antoine Pitrou <pitrou at free.fr> added the comment:
> 
> Le vendredi 13 juin 2008 à 20:18 +0000, Marc-Andre Lemburg a écrit :
>> AFAIK, only Crays have this problem, but apart from that: I'd consider
>> it a bug if sizeof(Py_UCS4) != 4.
> 
> Perhaps a #error can be added to that effect?
> Something like (untested):
> 
> #if SIZEOF_INT == 4 
> typedef unsigned int Py_UCS4; 
> #elif SIZEOF_LONG == 4
> typedef unsigned long Py_UCS4; 
> #else
> #error Could not find a 4-byte integer type for Py_UCS4, aborting
> #endif

Sounds good !

> (of course we could also try harder to find an appropriate type, but I'm
> no specialist in C integer variations)

Python should really try to use uint32_t as fallback solution for
UCS4 where available (and uint16_t for UCS2).

We'd have to add an AC_TYPE_INT32_T and AC_TYPE_INT16_T check to
configure:

http://www.gnu.org/software/autoconf/manual/html_node/Particular-Types.html#Particular-Types

and could then use

typedef uint32_t Py_UCS4

and

typedef uint16_t Py_UCS2

Note that the code for supporting UCS2/UCS4 is not really all that
clean. It was a quick sprint between Martin and Fredrik and appears
to be only half-done... e.g. there currently is no Py_UCS2.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3098>
_______________________________________


More information about the Python-bugs-list mailing list