Browse Source

msgpack: require msgpack >= 1.0.3

... and remove support code for older versions.
Thomas Waldmann 3 years ago
parent
commit
0937ae9078
2 changed files with 9 additions and 14 deletions
  1. 1 1
      setup.py
  2. 8 13
      src/borg/helpers/msgpack.py

+ 1 - 1
setup.py

@@ -66,7 +66,7 @@ on_rtd = os.environ.get('READTHEDOCS')
 install_requires = [
     # we are rather picky about msgpack versions, because a good working msgpack is
     # very important for borg, see: https://github.com/borgbackup/borg/issues/3753
-    'msgpack >=0.5.6, <=1.0.3, !=1.0.1',
+    'msgpack >=1.0.3, <=1.0.3',
     # Please note:
     # using any other version is not supported by borg development and
     # any feedback related to issues caused by this will be ignored.

+ 8 - 13
src/borg/helpers/msgpack.py

@@ -30,8 +30,6 @@ from msgpack import OutOfData
 
 version = mp_version
 
-_post_100 = version >= (1, 0, 0)
-
 
 class PackException(Exception):
     """Exception while msgpack packing"""
@@ -99,9 +97,8 @@ class Unpacker(mp_Unpacker):
                   max_bin_len=max_bin_len,
                   max_array_len=max_array_len,
                   max_map_len=max_map_len,
-                  max_ext_len=max_ext_len)
-        if _post_100:
-            kw['strict_map_key'] = strict_map_key
+                  max_ext_len=max_ext_len,
+                  strict_map_key=strict_map_key)
         super().__init__(**kw)
 
     def unpack(self):
@@ -138,10 +135,9 @@ def unpackb(packed, *, raw=True, unicode_errors=None,
                   max_bin_len=max_bin_len,
                   max_array_len=max_array_len,
                   max_map_len=max_map_len,
-                  max_ext_len=max_ext_len)
+                  max_ext_len=max_ext_len,
+                  strict_map_key=strict_map_key)
         kw.update(kwargs)
-        if _post_100:
-            kw['strict_map_key'] = strict_map_key
         return mp_unpackb(packed, **kw)
     except Exception as e:
         raise UnpackException(e)
@@ -162,10 +158,9 @@ def unpack(stream, *, raw=True, unicode_errors=None,
                   max_bin_len=max_bin_len,
                   max_array_len=max_array_len,
                   max_map_len=max_map_len,
-                  max_ext_len=max_ext_len)
+                  max_ext_len=max_ext_len,
+                  strict_map_key=strict_map_key)
         kw.update(kwargs)
-        if _post_100:
-            kw['strict_map_key'] = strict_map_key
         return mp_unpack(stream, **kw)
     except Exception as e:
         raise UnpackException(e)
@@ -182,8 +177,8 @@ def is_slow_msgpack():
 def is_supported_msgpack():
     # DO NOT CHANGE OR REMOVE! See also requirements and comments in setup.py.
     import msgpack
-    return (0, 5, 6) <= msgpack.version <= (1, 0, 3) and \
-           msgpack.version not in [(1, 0, 1), ]  # < add bad releases here to deny list
+    return (1, 0, 3) <= msgpack.version <= (1, 0, 3) and \
+           msgpack.version not in []  # < add bad releases here to deny list
 
 
 def get_limited_unpacker(kind):