summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-09-13 08:34:15 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2014-09-13 08:34:15 +0200
commit4eefbfdbfd472398ed5e40b13d20e3a92f837f52 (patch)
tree4591dcb7a31b95c7e78a576ab218d0b292ae8452
parent652f283135705f5734d44913811396dac4a98b29 (diff)
downloadyoutube-dl-4eefbfdbfd472398ed5e40b13d20e3a92f837f52.tar.gz
youtube-dl-4eefbfdbfd472398ed5e40b13d20e3a92f837f52.tar.xz
youtube-dl-4eefbfdbfd472398ed5e40b13d20e3a92f837f52.zip
[utils] Fix find_xpath_attr on 2.6
-rw-r--r--youtube_dl/utils.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index d920c65a4..8828161e5 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -280,6 +280,11 @@ if sys.version_info >= (2, 7):
         return node.find(expr)
 else:
     def find_xpath_attr(node, xpath, key, val):
+        # Here comes the crazy part: In 2.6, if the xpath is a unicode,
+        # .//node does not match if a node is a direct child of . !
+        if isinstance(xpath, unicode):
+            xpath = xpath.encode('ascii')
+
         for f in node.findall(xpath):
             if f.attrib.get(key) == val:
                 return f