2013-10-11, 22:51
Was having some problems with r950 and stable with a programme called "The House that £100K Built"
error was:
The offending tuple x is (u'title', u'The House That \xa3100K Built'), and type(x[1]) is unicode
Problem seems to be Python sees the string as ascii but it's unicode, and an attempt to encode it into unicode is producing an error
I've changed from line 226 to read
This traps the error by including unicode into the TRUE condition, then ignoring any unicode characters if encode('utf-8') throws an error
error was:
Code:
Traceback (most recent call last):
File "/usr/local/bin/MythDataGrabber.orig", line 274, in <module>
writeData()
File "/usr/local/bin/MythDataGrabber.orig", line 228, in writeData
else: f.write('%s = "%s"\n' % x)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 24: ordinal not in range(128)
Problem seems to be Python sees the string as ascii but it's unicode, and an attempt to encode it into unicode is producing an error
I've changed from line 226 to read
Code:
#filter out unicode strings:
if (type(x[1]) == str) or (type(x[1]) == unicode):
try:
f.write('%s = "%s"\n' % (x[0],x[1].encode('utf-8')))
except:
f.write('%s = "%s"\n' % (x[0],x[1].encode('ascii','ignore')))
else: f.write('%s = "%s"\n' % x)