Update types.py
It have been seen that under specific vendor response  with bad corrupted data the received value can be significantly larger than integer and current code will take it for a long processing time by blocking other code being running. The suggested code will improve the processing time in this case.
@@ -70,8 +70,7 @@ class Counter(Integer): # type: ignore
def __init__(self, value):
# type: (int) -> None
- while value >= 2 ** 32:
- value = value - (2 ** 32)
+ value &= 0xffffffff
if value <= 0:
value = 0
super().__init__(value)
@@ -144,8 +143,7 @@ class Counter64(Integer): # type: ignore
def __init__(self, value):
# type: (int) -> None
- while value >= 2 ** 64:
- value = value - (2 ** 64)
+ value &= 0xffffffffffffffff
if value <= 0:
value = 0
super().__init__(value)
