[compat] Fix test_cmdline_umlauts on Python 2.6
authorYen Chi Hsuan <yan12125@gmail.com>
Thu, 7 Jul 2016 14:30:58 +0000 (22:30 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Thu, 7 Jul 2016 14:30:58 +0000 (22:30 +0800)
The original statement raises uncaught UnicodeWarning on Python 2.6

youtube_dl/compat.py

index 83b96d38fe66f063608a4669b9880da1481fda23..b8aaf5a461c9e3ca2884c748ebb3225a2fd9fe29 100644 (file)
@@ -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):