浏览代码

[compat] Fix test_cmdline_umlauts on Python 2.6

The original statement raises uncaught UnicodeWarning on Python 2.6
Yen Chi Hsuan 9 年之前
父节点
当前提交
ec3518725b
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      youtube_dl/compat.py

+ 5 - 2
youtube_dl/compat.py

@@ -2596,9 +2596,12 @@ except ImportError:  # Python < 3.3
 
 
 try:
-    assert shlex.split('中文') == ['中文']
+    args = shlex.split('中文')
+    assert (isinstance(args, list) and
+            isinstance(args[0], compat_str) and
+            args[0] == '中文')
     compat_shlex_split = shlex.split
-except (AssertionError, UnicodeWarning, UnicodeEncodeError):
+except (AssertionError, UnicodeEncodeError):
     # Working around shlex issue with unicode strings on some python 2
     # versions (see http://bugs.python.org/issue1548891)
     def compat_shlex_split(s, comments=False, posix=True):