<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 11: MediaInfo.__unicode__ can throw UnicodeDecodeError</title><link>https://sourceforge.net/p/mmpython/bugs/11/</link><description>Recent changes to 11: MediaInfo.__unicode__ can throw UnicodeDecodeError</description><atom:link href="https://sourceforge.net/p/mmpython/bugs/11/feed.rss" rel="self"/><language>en</language><lastBuildDate>Tue, 01 Feb 2005 01:23:22 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/mmpython/bugs/11/feed.rss" rel="self" type="application/rss+xml"/><item><title>MediaInfo.__unicode__ can throw UnicodeDecodeError</title><link>https://sourceforge.net/p/mmpython/bugs/11/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;When the MediaInfo class's __unicode__ method is called&lt;br /&gt;
(e.g., when passed to unicode()), an uncaught exception&lt;br /&gt;
can occur when one of MediaInfo's attributes is encoded&lt;br /&gt;
as latin_1 and contains an ordinal character higher&lt;br /&gt;
than 128.  Specifically, on line 156 of mediainfo.py,&lt;br /&gt;
unicode(self[b]) apparently throws the exception before&lt;br /&gt;
being fed via string substitution into the string on&lt;br /&gt;
the previous line.&lt;/p&gt;
&lt;p&gt;To reproduce, one can run mminfo (or run the parse()&lt;br /&gt;
function) on "donnie_hi.mov", a trailer for "The Sims&lt;br /&gt;
2".  This file should be available through the website&lt;br /&gt;
&lt;a href="http://thesims2.ea.com/" rel="nofollow"&gt;http://thesims2.ea.com/&lt;/a&gt; or via a Google search for&lt;br /&gt;
"donnie_hi.zip".&lt;/p&gt;
&lt;p&gt;Extracted, the example amounts to:&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; unicode("'\xa9 2004 Electronic Arts Inc. All rights&lt;br /&gt;
reserved.'")&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
File "&amp;lt;stdin&amp;gt;", line 1, in ?&lt;br /&gt;
UnicodeDecodeError: 'ascii' codec can't decode byte&lt;br /&gt;
0xa9 in position 1: ordinal not in range(128)&lt;/p&gt;
&lt;p&gt;A complete traceback via pdb follows:&lt;/p&gt;
&lt;p&gt;korpios@nemesis ~ $ python -m pdb ~/bin/mminfo&lt;br /&gt;
donnie_hi.mov&lt;br /&gt;
&amp;gt; /home/korpios/bin/mminfo(43)?()&lt;br /&gt;
-&amp;gt; import sys&lt;br /&gt;
(Pdb) c&lt;br /&gt;
mmpython media info&lt;/p&gt;
&lt;p&gt;filename : donnie_hi.mov&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
File "/usr/lib/python2.4/pdb.py", line 1057, in main&lt;br /&gt;
pdb._runscript(mainpyfile)&lt;br /&gt;
File "/usr/lib/python2.4/pdb.py", line 982, in _runscript&lt;br /&gt;
self.run(statement, globals=globals_, locals=locals_)&lt;br /&gt;
File "/usr/lib/python2.4/bdb.py", line 366, in run&lt;br /&gt;
exec cmd in globals, locals&lt;br /&gt;
File "&amp;lt;string&amp;gt;", line 1, in ?&lt;br /&gt;
File "/home/korpios/bin/mminfo", line 87, in ?&lt;br /&gt;
print unicode(medium).encode('latin-1', 'replace')&lt;br /&gt;
File "/home/korpios/py3p/mmpython/mediainfo.py", line&lt;br /&gt;
350, in __unicode__&lt;br /&gt;
result += MediaInfo.__unicode__(self)&lt;br /&gt;
File "/home/korpios/py3p/mmpython/mediainfo.py", line&lt;br /&gt;
156, in __unicode__&lt;br /&gt;
(a, unicode(b), unicode(self[b])) or a, keys, u'' )&lt;br /&gt;
File "/home/korpios/py3p/mmpython/mediainfo.py", line&lt;br /&gt;
155, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
result += reduce( lambda a,b: self[b] and b !=&lt;br /&gt;
u'url' and u'%s\n        %s: %s' % \
UnicodeDecodeError: 'ascii' codec can't decode byte&lt;br /&gt;
0xa9 in position 0: ordinal not in range(128)&lt;br /&gt;
Uncaught exception. Entering post mortem debugging&lt;br /&gt;
Running 'cont' or 'step' will restart the program&lt;br /&gt;
&amp;gt; /home/korpios/py3p/mmpython/mediainfo.py(155)&amp;lt;lambda&amp;gt;()&lt;br /&gt;
-&amp;gt; result += reduce( lambda a,b: self[b] and b !=&lt;br /&gt;
u'url' and u'%s\n        %s: %s' % \
(Pdb) print `b`&lt;br /&gt;
'copyright'&lt;br /&gt;
(Pdb) whatis b&lt;br /&gt;
&amp;lt;type 'str'&amp;gt;&lt;br /&gt;
(Pdb) print `self[b]`&lt;br /&gt;
'\xa9 2004 Electronic Arts Inc. All rights reserved.'&lt;br /&gt;
(Pdb) whatis self[b]&lt;br /&gt;
&amp;lt;type 'str'&amp;gt;&lt;br /&gt;
(Pdb) print `ord(self[b][0])`&lt;br /&gt;
169&lt;br /&gt;
(Pdb) print `hex(ord(self[b][0]))`&lt;br /&gt;
'0xa9'&lt;/p&gt;&lt;/div&gt;</description><pubDate>Tue, 01 Feb 2005 01:23:22 -0000</pubDate><guid isPermaLink="false">https://sourceforge.nete45eb1fc0bbcfa2846fb26d63c8394455fee3368</guid></item></channel></rss>