Remove "break" `Integer` to `bytes` conversion
@@ -406,19 +406,14 @@ class Integer(Type):
self.value = value
def __bytes__(self):
- # pylint: disable=line-too-long
- if self.value == 0:
- octets = [0]
- else:
- # Split long integers into multiple octets.
- remainder = self.value
- octets = []
+ octets = [self.value & 0b11111111]
- while True:
- octets.append(remainder & 0b11111111)
- if remainder == 0 or remainder == -1:
- break
+ # Append remaining octets for long integers.
+ remainder = self.value
+ while remainder not in (0, -1):
remainder = remainder >> 8
+ octets.append(remainder & 0b11111111)
+
if remainder == 0 and octets[-1] == 0b10000000:
octets.append(0)
octets.reverse()
