Does Python 3.x support Unicode-named attributes?

J

John Nagle

Does Python 3.x support Unicode-named attributes?

There are several modules which operate on HTML and try to
hammer HTML/XML into Python object attributes. I've had
BeautifulSoup and "urllib" blow up at various times when
running on non-English HTML/XML.

Got this error today:

urllib.py:1197: UnicodeWarning: Unicode equal comparison failed to convert both
arguments to Unicode - interpreting
them as being unequal
res = map(safe_map.__getitem__, s)

John Nagle
 
M

Martin v. Löwis

Does Python 3.x support Unicode-named attributes?

Most certainly, yes. All identifiers (and thus all attribute
names) are Unicode strings in Python 3.x.
There are several modules which operate on HTML and try to
hammer HTML/XML into Python object attributes. I've had
BeautifulSoup and "urllib" blow up at various times when
running on non-English HTML/XML.

Got this error today:

urllib.py:1197: UnicodeWarning: Unicode equal comparison failed to
convert both arguments to Unicode - interpreting
them as being unequal
res = map(safe_map.__getitem__, s)

Perhaps the library you were using modified __dict__ directly,
thus getting non-string attribute names into the dict? Or perhaps
s is not a Unicode string?

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top