[compat] Rename struct_(un)pack to compat_struct_(un)pack
[youtube-dl] / youtube_dl / utils.py
index c9702fd93f59862fa5bb261f38b5f7ccb6977116..dbac38b555ad59f2178c58e6d6cfd8ce88a6aefe 100644 (file)
@@ -44,6 +44,7 @@ from .compat import (
     compat_parse_qs,
     compat_socket_create_connection,
     compat_str,
+    compat_struct_pack,
     compat_urllib_error,
     compat_urllib_parse,
     compat_urllib_parse_urlencode,
@@ -52,7 +53,6 @@ from .compat import (
     compat_urlparse,
     compat_xpath,
     shlex_quote,
-    struct_pack,
 )
 
 from .socks import (
@@ -63,6 +63,8 @@ from .socks import (
 
 def register_socks_protocols():
     # "Register" SOCKS protocols
+    # In Python < 2.6.5, urlsplit() suffers from bug https://bugs.python.org/issue7904
+    # URLs with protocols not in urlparse.uses_netloc are not handled correctly
     for scheme in ('socks', 'socks4', 'socks4a', 'socks5'):
         if scheme not in compat_urlparse.uses_netloc:
             compat_urlparse.uses_netloc.append(scheme)
@@ -1257,7 +1259,7 @@ def bytes_to_intlist(bs):
 def intlist_to_bytes(xs):
     if not xs:
         return b''
-    return struct_pack('%dB' % len(xs), *xs)
+    return compat_struct_pack('%dB' % len(xs), *xs)
 
 
 # Cross-platform file locking