[Python-checkins] cpython: pyexpat uses the new Unicode API

martin at v.loewis.de martin at v.loewis.de
Sun Jul 29 23:24:51 CEST 2012


> Why is this PyUnicode_READY necessary?
> Can tp_getattro pass unfinished unicode objects?

There is no guarantee that it does pass READY strings.
Giving such guarantee would be fairly error-prone,
since people would now have to remember in what places
they need to READY.

So the guideline really is that you need to READY always
whenever you access the internal representation.

> I hope we don't have to update all extension modules?

Of course not. Existing code will continue to work fine,
with some really minor limitations (see the PEP for details).
In fact, pyexpat worked just fine before Victor changed it
(and continues to do so after the change, with potentially
reduced memory consumption).

Such code will not use the new API to access the flexible
representation. If somebody changes the module to do so,
they will have to add PyUnicode_READY calls.

As Victor changed pyexpat to use the new API, he also
added the READY calls (which are necessary precisely to
continue supporting the old API, so they can go in
Python 4).

Regards,
Martin




More information about the Python-checkins mailing list