Bug in htmlentitydefs.py with Python 3.0?
Fredrik Lundh
fredrik at pythonware.com
Thu Dec 27 10:21:48 EST 2007
Martin v. Löwis wrote:
>> entity_map = htmlentitydefs.entitydefs.copy()
>> for name, entity in entity_map.items():
>> if len(entity) != 1:
>> entity_map[name] = unichr(int(entity[2:-1]))
>>
>> (entitydefs is pretty unusable as it is, but it was added to Python
>> before Python got Unicode strings, and changing it would break ancient
>> code...)
>
> I would not write it this way, but as
>
> for name,codepoint in htmlentitydefs.name2codepoint:
> entity_map[name] = unichr(codepoint)
has dictionary iteration changed in 3.0? if not, your code doesn't
quite work. and even if you fix that, it doesn't work for all Python
versions that ET works for...
</F>
More information about the Python-list
mailing list