aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/compat.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2018-01-28 03:04:39 +0700
committerSergey M․ <dstftw@gmail.com>2018-01-28 05:48:18 +0700
commit65220c3bd6bfcb9023af904634ce1e76592cfe3e (patch)
treed41c43c81d631e0d0e5275b39ac38874ada5e333 /youtube_dl/compat.py
parentc989bdbef8fdcfd38d51b987a4c745479d02e2f2 (diff)
Add support for IronPython
Diffstat (limited to 'youtube_dl/compat.py')
-rw-r--r--youtube_dl/compat.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index 646c9d79c..27ece2d29 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -2897,9 +2897,24 @@ except TypeError:
if isinstance(spec, compat_str):
spec = spec.encode('ascii')
return struct.unpack(spec, *args)
+
+ class compat_Struct(struct.Struct):
+ def __init__(self, fmt):
+ if isinstance(fmt, compat_str):
+ fmt = fmt.encode('ascii')
+ super(compat_Struct, self).__init__(fmt)
else:
compat_struct_pack = struct.pack
compat_struct_unpack = struct.unpack
+ if platform.python_implementation() == 'IronPython' and sys.version_info < (2, 7, 8):
+ class compat_Struct(struct.Struct):
+ def unpack(self, string):
+ if not isinstance(string, buffer):
+ string = buffer(string)
+ return super(compat_Struct, self).unpack(string)
+ else:
+ compat_Struct = struct.Struct
+
try:
from future_builtins import zip as compat_zip
@@ -2941,6 +2956,7 @@ __all__ = [
'compat_HTMLParseError',
'compat_HTMLParser',
'compat_HTTPError',
+ 'compat_Struct',
'compat_b64decode',
'compat_basestring',
'compat_chr',