[Python-Dev] Minidom and Unicode

Paul Prescod paul@prescod.net
Mon, 03 Jul 2000 11:15:46 -0500

"M.-A. Lemburg" wrote:
> ...
> IMHO, all auto-conversions should use the default encoding. The
> main point here is not to confuse the user with even more magic
> happening under the hood.

I don't see anything confusing about having unicode-escape be the
appropriate escape used for repr. Maybe we need to differentiate between
lossless and lossy encodings. If the default encoding is lossless then
repr could use it. Otherwise it could use unicode-escape.

Anyhow, why would it be wrong for Fredrick to hard-code an encoding in
repr but right for me to hard-code one in minidom? Users should not need
to comb through the hundreds of modules in the library figuring out what
kind of Unicode handling they should expect. It should be as centralized
as possible.

> If the programmer knows that he'll have to deal with Unicode
> then he should make sure that the proper encoding is used
> and document it that way, e.g. use unicode-escape for Minidom's
> __repr__ methods.

One of the major goals of our current Unicode auto-conversion
"compromise" is that modules like xmllib and minidom should work with
Unicode out of the box without any special enhancements. According to
Guido, that's the primary reason we have Unicode auto-conversions at


I'm going to fight very hard to make basic Unicode support in Python
modules "just work" without a bunch of internationalization knowledge
from the programmer. __repr__ is pretty basic.

> > the reason for this patch was to avoid forcing everyone to deal with
> > this in their own code, by providing some kind of fallback behaviour.
> That's what your patch does; I don't see a reason to change it :-)

If you're still proposing that I should deal with it in a particular
module's domain-specific code then the patch isn't done yet!

 Paul Prescod - Not encumbered by corporate consensus
The calculus and the rich body of mathematical analysis to which it 
gave rise made modern science possible, but it was the algorithm that 
made the modern world possible.
	- The Advent of the Algorithm (pending), by David Berlinski