[Python-Dev] The C API and wide unicode support

Martin v. Loewis martin@v.loewis.de
10 Jul 2002 22:39:55 +0200


Guido van Rossum <guido@python.org> writes:

> Really?  If I am only using the published APIs and not peeking
> directly inside the Unicode object, why should I care about its
> internal lay-out?

The safeguard is to tell apart module that use Unicode objects from
modules which don't. If a module uses Unicode objects, it might be
using PyUnicode_AS_UNICODE. Unfortunately, this does not result in a
symbol reference, so using a module that only uses
PyUnicode_AS_UNICODE would break if it was compiled for the wrong
width of Py_UNICODE.

Mangling all Unicode functions is the best safeguard we could find to
protect against this case. It is still possible to cheat that, but it
is unlikely that somebody breaks the safeguard by accident.

Likewise, it is unlikely that a single platform has builds for two
different Py_UNICODE sizes simultaneously, so the safeguard does not
add additional burden, either.

Regards,
Martin