fix unicode and exceptions
This commit is contained in:
parent
b517adfed1
commit
b042b4b7f6
2 changed files with 3 additions and 6 deletions
|
|
@ -257,14 +257,14 @@ class ContactThreadPage(PageBase):
|
|||
|
||||
self.browser.submit() # submit current form
|
||||
except FormNotFoundError, e:
|
||||
error = 'Unknown error (%s)' % e
|
||||
error = u'Unknown error (%s)' % e
|
||||
p_list = self.document.getElementsByTagName('p')
|
||||
for p in p_list:
|
||||
if p.hasAttribute('align') and p.getAttribute('align') == 'center':
|
||||
error = p.firstChild.data
|
||||
break
|
||||
|
||||
raise AdopteCantPostMail(error)
|
||||
raise AdopteCantPostMail(error.encode('utf-8'))
|
||||
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -38,10 +38,7 @@ def to_unicode(text):
|
|||
if isinstance(text, unicode):
|
||||
return text
|
||||
if not isinstance(text, str):
|
||||
try:
|
||||
text = str(text)
|
||||
except UnicodeError:
|
||||
pass
|
||||
text = str(text)
|
||||
try:
|
||||
return unicode(text, 'utf-8')
|
||||
except UnicodeError:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue