]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Remove cruft and simplify.
authorBrian Wellington <bwelling@xbill.org>
Wed, 20 May 2020 22:18:16 +0000 (15:18 -0700)
committerBrian Wellington <bwelling@xbill.org>
Wed, 20 May 2020 22:18:16 +0000 (15:18 -0700)
This also makes slices with steps work, although nothing uses them.

dns/wiredata.py

index 14f36fc12aa6801df136a19665bd47ae7fd9fb92..71edf91943b77deae31a1021114a4150249c02e4 100644 (file)
 
 import dns.exception
 
-# Figure out what constant python passes for an unspecified slice bound.
-# It's supposed to be sys.maxint, yet on 64-bit windows sys.maxint is 2^31 - 1
-# but Python uses 2^63 - 1 as the constant.  Rather than making pointless
-# extra comparisons, duplicating code, or weakening WireData, we just figure
-# out what constant Python will use.
-
-
-class _SliceUnspecifiedBound(bytes):
-
-    def __getitem__(self, key):
-        return key.stop
-
-_unspecified_bound = _SliceUnspecifiedBound()[1:]
-
 
 class WireData(bytes):
     # WireData is a binary type with stricter slicing
@@ -43,17 +29,14 @@ class WireData(bytes):
                 # make sure we are not going outside of valid ranges,
                 # do stricter control of boundaries than python does
                 # by default
-                start = key.start
-                stop = key.stop
 
-                for index in (start, stop):
+                for index in (key.start, key.stop):
                     if index is None:
                         continue
                     elif abs(index) > len(self):
                         raise dns.exception.FormError
 
-                return WireData(super(WireData, self).__getitem__(
-                    slice(start, stop)))
+                return WireData(super().__getitem__(key))
             return self.unwrap()[key]
         except IndexError:
             raise dns.exception.FormError