about summary refs log tree commit diff
path: root/youtube_dl/compat.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2015-10-25 20:30:54 +0100
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2015-10-25 20:30:54 +0100
commit387db16a789fea25795433538d80513c18d0f699 (patch)
treef063b2b90017abbc6aa5491f48b09a342b263b3c /youtube_dl/compat.py
parent36e6f62cd0883f0f486d1666d010e5d9e6d515bd (diff)
downloadyoutube-dl-387db16a789fea25795433538d80513c18d0f699.tar.gz
youtube-dl-387db16a789fea25795433538d80513c18d0f699.tar.xz
youtube-dl-387db16a789fea25795433538d80513c18d0f699.zip
[compat] compat_etree_fromstring: only decode bytes objects
Diffstat (limited to 'youtube_dl/compat.py')
-rw-r--r--youtube_dl/compat.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index cf10835ca..f39d4e9a9 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -216,8 +216,7 @@ except ImportError:  # Python 2.6
 if sys.version_info[0] >= 3:
     compat_etree_fromstring = xml.etree.ElementTree.fromstring
 else:
-    # on python 2.x the the attributes of a node are str objects instead of
-    # unicode
+    # on python 2.x the the attributes of a node aren't always unicode objects
     etree = xml.etree.ElementTree
 
     # on 2.6 XML doesn't have a parser argument, function copied from CPython
@@ -231,7 +230,8 @@ else:
     def _element_factory(*args, **kwargs):
         el = etree.Element(*args, **kwargs)
         for k, v in el.items():
-            el.set(k, v.decode('utf-8'))
+            if isinstance(v, bytes):
+                el.set(k, v.decode('utf-8'))
         return el
 
     def compat_etree_fromstring(text):