summaryrefslogtreecommitdiff
path: root/bs4/element.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2012-08-17 09:32:45 -0400
committerLeonard Richardson <leonardr@segfault.org>2012-08-17 09:32:45 -0400
commitadd51d411ddfce7e283ac735f6b9860633a7bb28 (patch)
treeceb57384aa5928e9860477468d951d2c260216fe /bs4/element.py
parentcff5b21e13c8952f693a327eecdcf6c3c6cd5050 (diff)
Got rid of a UnicodeDecodeError when attribute names contain non-ASCII characters.
Diffstat (limited to 'bs4/element.py')
-rw-r--r--bs4/element.py4
1 files changed, 2 insertions, 2 deletions
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 = ''