[issue29360] _PyStack_AsDict(): Don't check if all keys are strings nor if keys are unique

STINNER Victor report at bugs.python.org
Tue Jan 24 08:33:42 EST 2017


STINNER Victor added the comment:

> I don't know. To that that is crashed when pass non-string keys.

Oh ok. I found a way to create a dictionary with equal keys and pass it to dict(**kw) in my fast_init branch (I already removed the PyUnicode_Check() asssertion in this branch):

haypo at selma$ ./python bug.py 
call with: {'a': 1, 'b': 2}
python: Objects/abstract.c:2471: _PyStack_AsDict: Assertion `PyDict_GetItem(kwdict, key) == NULL' failed.
Aborted


So yes, with special objects, the PyDict_GetItem()==NULL assertion fails. With pystack_asdict-2.patch, the duplicated (equal) keys are merged as expected:

$ ./python bug.py 
call with: {'a': 1, 'b': 2}
got: {'a': 2}

Again, there is also a bug in my fast_init branch, I should avoid double conversion dict=>kwnames=>dict to call a type.

----------
Added file: http://bugs.python.org/file46408/bug.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29360>
_______________________________________


More information about the Python-bugs-list mailing list