Bit by Unicode

Date June 21, 2006 by Isaac

I was pretty proud of my latest Python script, which was designed to test a CORBA object. However, when I tried to run the script it gave me some obfuscated errors and died. So, for the last couple days I've been trying to figure out why my script was dying. It turns out that PyFIT (and as I later learned FIT in general) passes Unicode encoded strings to the Python fixture. This is fine for most of the tests I've done, however, my new test used one of these strings in the call to the CORBA naming service. That was a no no! I haven't tracked down whether it's omniORB or the TAO naming service that didn't like the Unicode, but I suspect it's the naming service itself.

Once I converted my strings to ASCII everything worked. Here's the magic incantation:

str = str.encode('ascii', 'replace')

Now you know, and knowing if half the battle.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>