From add51d411ddfce7e283ac735f6b9860633a7bb28 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Fri, 17 Aug 2012 09:32:45 -0400 Subject: Got rid of a UnicodeDecodeError when attribute names contain non-ASCII characters. --- bs4/element.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bs4/element.py') diff --git a/bs4/element.py b/bs4/element.py index 2e3be46..26422fd 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -987,7 +987,7 @@ class Tag(PageElement): if isinstance(val, list) or isinstance(val, tuple): val = ' '.join(val) elif not isinstance(val, basestring): - val = str(val) + val = unicode(val) elif ( isinstance(val, AttributeValueWithCharsetSubstitution) and eventual_encoding is not None): @@ -995,7 +995,7 @@ class Tag(PageElement): text = self.format_string(val, formatter) decoded = ( - str(key) + '=' + unicode(key) + '=' + EntitySubstitution.quoted_attribute_value(text)) attrs.append(decoded) close = '' -- cgit v1.2.3