Meldgaard
Agony Unleashed Agony Empire
|
Posted - 2010.06.30 22:39:00 -
[1]
Edited by: Meldgaard on 30/06/2010 22:47:08 Edited by: Meldgaard on 30/06/2010 22:42:58
Originally by: Alyzza There seems to be a bit of a "bug" when corporations have bytes in their description which can't be encoded as unicode.
I have the same error just with the ccp event in char/UpcomingCalendarEvents.xml.aspx: Row(eventID:37679,ownerID:793028819,ownerName:Agony Unleashed,eventDate:1277985600,eventTitle:api test ignore,duration:180,importance:0,response:Undecided,eventText:test1 ) Traceback (most recent call last): File "./eveapibug.py", line 28, in <module> print event File "/home/rasmusm/local/src/evegate2ical/eveapi.py", line 557, in __str__ return "Row(" + ','.join(map(lambda k, v: "%s:%s" % (str(k), str(v)), self._cols, self._row)) + ")" File "/home/rasmusm/local/src/evegate2ical/eveapi.py", line 557, in <lambda> return "Row(" + ','.join(map(lambda k, v: "%s:%s" % (str(k), str(v)), self._cols, self._row)) + ")" UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 178: ordinal not in range(128)
this test code (and test xml on my test server) gives the error:
EDIT: arg its a bad forum, you can get the file here: http://eveapi.rasmusm.dk/eveapibug.py
|
Meldgaard
Agony Unleashed Agony Empire
|
Posted - 2010.07.01 09:47:00 -
[3]
Originally by: Entity Edited by: Entity on 01/07/2010 02:13:38
Originally by: Meldgaard And i fund the bug: Eve api is utf-8 and the parser is using unicode strings.
Here is a quick and dirty fix: http://eveapi.rasmusm.dk/eveapi-utf-8.patch
Hm?. I'm not quite sure that is actually a bug. See, it's up to the implementor to output with the correct encoding for the target (in your case a console window). The objects returned by the parser are supposed to be regular/unicode strings. If you encode them they technically stop being strings and start being binary data that just so happens to be some representation of said string.
Edit: Oh and welcome to the headache that is python and encodings.
The problem is (as i understand it, because yes this is my first time with utf-8 in python) that the eveapi are returning strings in uft-8, but in _Parser.__str__ you are calling str() on the variable holding the utf-8 string, this will cast an exception if the utf-8 string do include char outside of unicode (like in the description of the ccp created event about the ore primae)
PS. I forgot to say thank you for making this nice api wrapper, other than this but (and i blame utf-8) its a pleasure to be working with.
|