Open harryxu opened 2 months ago
@alhirzel Would it work correctly if we replace float('Inf')
with sys.maxsize
as the maxlen
parameter?
@alhirzel Would it work correctly if we replace
float('Inf')
withsys.maxsize
as themaxlen
parameter?
I tried; it won’t work and will cause a memory error.
I stumbled upon this when simply running the unit tests:
test/test_pysm.py:1423:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pysm.pysm.patch_deque.<locals>.deque_maxlen object at 0x7903f66f9460>, iterable = [], maxlen = inf
def __init__(self, iterable=None, maxlen=0):
# pylint: disable=no-member
if iterable is None:
iterable = []
if maxlen in [None, 0]:
maxlen = float('Inf')
#maxlen = sys.maxsize
> self.q = deque_module.deque(iterable, maxlen)
E TypeError: an integer is required
pysm/pysm.py:49: TypeError
The proposal with sys.maxsize
fixed at least the test.
Env:
Error:
Through investigation, I found that the issue was caused by patch_deque in pysm using float('Inf') as the maxlen parameter for deque.
https://github.com/pgularski/pysm/blob/b48cbc79c06a70b84454bcbb24a5ac2095652c0b/pysm/pysm.py#L47-L48
The following is the code I ran in the ESP32 shell, which resulted in the same error.