[portland] detecting implicit encoding conversion

Christopher Hiller chiller at decipherinc.com
Thu Feb 25 01:49:09 CET 2010


I'm having a difficult time with this particular problem.  I have a codebase
where I would like to find all occurrences of implicit decodes.  It's
difficult to do this with grep, and I was wondering if there was another way
by means of decorators or monkeypatching or compiler/parse tree analysis or
something.  An example:

foo = u'bar' + 'baz'

This implicitly decodes "baz" using the system default encoding.  In my case
this encoding is ASCII.

However -- and this is where problems can arise -- what if you had this:

foo = u'bar' + 'büz'

...which results in a SyntaxError if your default encoding is ASCII.

Any ideas?  I'm having problems googling for solutions because I'm not
entirely sure what to google for.

christopher hiller
sr software engineer
34 nw 1st ave, ste 305
portland or 97209
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/portland/attachments/20100224/393da5d2/attachment.html>

More information about the Portland mailing list