STINNER Victor <victor.stin...@gmail.com> added the comment:

>> +#if SIZEOF_LONG <= SIZEOF_VOID_P
>> +    if (!((size_t) p & LONG_PTR_MASK)) {
>>
>> I wrote "q", not "p". You have to check p and q alignement to be able
>> to dereference p and q pointers.
>
> Initial q (destination) is always pointer-aligned, because PyASCIIObject is
> pointer-aligned. If PyASCIIObject not aligned, then on this platform alignment
> does not matter.

q is not the address of the Unicode string, but the address of the
data following the Unicode structure in memory. Strings created by
PyUnicode_New() are composed on one unique memory block: {structure,
data}. It's safer to check that q is aligned to sizeof(long). In
Python 3.2, it was different because the string data was always a
separated memory block (as "not ready" strings in Python 3.3).

We may change PyASCIIObject later to pack fields (to reduce memory consumption).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14419>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to