PMap order changes in Python 3.11a3, causing a doctest failure
musicinmybrain opened this issue · 2 comments
One doctest in pyrsistent/_pmap.py
fails on Python 3.11a3 because the order of PMap
entries is not as expected.
I suspect this is due to the change from siphash24
to siphash13
for str
/bytes
.
I’m happy to submit a PR if you can suggest a preferred approach to dealing with this. One way to make these doctests order-insensitive would be to compare against a dict
and expect a particular Boolean result, e.g. instead of
>>> m1
pmap({'b': 3, 'a': 1})
write
>>> m1 == {'a': 1, 'b': 2}
True
but of course this has slightly less value as documentation.
The failing doctest is:
___________________________________ [doctest] pyrsistent._pmap.PMap.update ____________________________________
211
212 Return a new PMap with the items in Mappings inserted. If the same key is present in multiple
213 maps the rightmost (last) value is inserted.
214
215 >>> m1 = m(a=1, b=2)
216 >>> m1.update(m(a=2, c=3), {'a': 17, 'd': 35})
Expected:
pmap({'c': 3, 'b': 2, 'a': 17, 'd': 35})
Got:
pmap({'d': 35, 'c': 3, 'b': 2, 'a': 17})
/home/ben/src/forks/pyrsistent/pyrsistent/_pmap.py:216: DocTestFailure
(Test command was PYTHONHASHSEED=0 PYTHONPATH="$PWD" pytest --doctest-modules pyrsistent
.)
Nice find! I'm good with the equality comparison you suggest above even though it's slightly contrived as doc. I haven't found any better way after some very quick research. Please file a PR!