-
Notifications
You must be signed in to change notification settings - Fork 160
Open
Description
pyrsistent.pdeque now accepts the maxlen=0 setting, but it does not handle it correctly:
from pyrsistent import pdeque
dq = pdeque([0], maxlen=0)
print(dq, len(dq)) # expected pdeque([], maxlen=0) and 0
dq = dq.append(1)
print(dq, len(dq)) # expected still length 0, but length becomes 2pdeque([0], maxlen=0) 1
pdeque([0, 1], maxlen=0) 2
Although maxlen=0 is not common, it is still an inconsistent behavior. The problem originates in _pdeque.py: during construction t = t[-maxlen:] leaves t unchanged for maxlen=0, so _length is set incorrectly. A fix would be to special-case maxlen=0.
Note: This issue was identified by an automated testing tool for academic research and manually verified. If you have any concerns about this type of reporting, please let me know, and I will adjust my workflow accordingly.
Metadata
Metadata
Assignees
Labels
No labels