<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Tang&apos;s DW</title>
  <link>https://tangaroa.dreamwidth.org/</link>
  <description>Tang&apos;s DW - Dreamwidth Studios</description>
  <lastBuildDate>Sun, 23 Mar 2014 13:44:38 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>tangaroa</lj:journal>
  <lj:journaltype>personal</lj:journaltype>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/69279.html</guid>
  <pubDate>Sun, 23 Mar 2014 13:44:38 GMT</pubDate>
  <title>Obscure bug of the nonce</title>
  <link>https://tangaroa.dreamwidth.org/69279.html</link>
  <description>Python easy_install on Windows sometimes fails with a UnicodeDecodeError:

&lt;blockquote&gt;
UnicodeDecodeError: &apos;ascii&apos; codec can&apos;t decode byte 0xc3 in position 6034: ordinal not in range(128)
&lt;/blockquote&gt;

&lt;a href=&quot;http://stackoverflow.com/questions/19536068/mitmproxy-installation-by-the-python-setuptools-easy-install-got-error-decoding&quot;&gt;The solution is to comment out the &lt;code&gt;config = config.decode(&apos;ascii&apos;)&lt;/code&gt; line in Lib/site-packages/setuptools/easy_install.py&lt;/a&gt;.

&lt;hr /&gt;

&lt;p&gt;Here&apos;s an even more fun one: 

&lt;blockquote&gt;&lt;pre&gt;
  File &quot;geopts.py&quot;, line 128, in xp2str
    s = etree.tostring(resultset[0], method=&quot;text&quot;)
  File &quot;lxml.etree.pyx&quot;, line 3165, in lxml.etree.tostring (src\lxml\lxml.etree.
c:69399)

exceptions.TypeError: Type &apos;_ElementStringResult&apos; cannot be serialized.
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;This says that the XML library&apos;s own tostring() function cannot convert one of its own string types to a string. What&apos;s especially brilliant about this is that &lt;a href=&quot;http://lxml.de/2.1/api/lxml.etree._ElementStringResult-class.html&quot;&gt;_ElementStringResult inherits from the native string class&lt;/a&gt;. 

&lt;p&gt;Here is a hacky attempt to manage the problem:

&lt;blockquote&gt;&lt;pre&gt;
r = resultset[0]
if isinstance(r, etree._ElementStringResult):
    s = r
else:
    s = etree.tostring(r, method=&quot;text&quot;)

&lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=69279&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/69279.html</comments>
  <category>computers</category>
  <category>debugging</category>
  <category>i18n</category>
  <category>xml</category>
  <category>programming</category>
  <category>python</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
