[issue29360] Don't check if all keys are strings in _PyStack_AsDict()

2017-01-24 Thread STINNER Victor
STINNER Victor added the comment: Attached pystack_asdict-2.patch removes the two assertions and rewrites _PyStack_AsDict() documentation to describe better how it handles non-string and duplicated keys (don't check keys type and merge duplicated keys). > We should either ensure that

[issue29360] Don't check if all keys are strings in _PyStack_AsDict()

2017-01-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > func(**{'x': 1, 'x': 2}) In this example the dictionary contains only one item. You need more complex example for making the assertion failing. Keys with non-constant hashes or equality, so first they are different, and later they become equal.

[issue29360] Don't check if all keys are strings in _PyStack_AsDict()

2017-01-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: We should either ensure that _PyStack_AsDict() is called only by CALL_FUNCTION_KW, and not by other way, or remove both assertions. I prefer the second option. They were here only for self-testing. -- ___ Python

[issue29360] Don't check if all keys are strings in _PyStack_AsDict()

2017-01-24 Thread STINNER Victor
STINNER Victor added the comment: Victor> PyPy (and other Python implementations?) don't support non-string in type dictionary. INADA Naoki> Wow! I thought it's Python's language. If we can prohibit non string name in all namespace, there might be possible optimization. That's a different

[issue29360] Don't check if all keys are strings in _PyStack_AsDict()

2017-01-24 Thread STINNER Victor
STINNER Victor added the comment: Serhiy Storchaka: "The assertion was valid while all keywords did came from a constant keywords tuple in CALL_FUNCTION_KW. But if the FASTCALL protocol is extended for var-keyword arguments, keywords can be arbitrary and the assertion can fail. The assertion

[issue29360] Don't check if all keys are strings in _PyStack_AsDict()

2017-01-24 Thread STINNER Victor
STINNER Victor added the comment: Serhiy Storchaka: "The assertion was valid while all keywords did came from a constant keywords tuple in CALL_FUNCTION_KW. But if the FASTCALL protocol is extended for var-keyword arguments, keywords can be arbitrary and the assertion can fail. The assertion

[issue29360] Don't check if all keys are strings in _PyStack_AsDict()

2017-01-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The assertion was valid while all keywords did came from a constant keywords tuple in CALL_FUNCTION_KW. But if the FASTCALL protocol is extended for var-keyword arguments, keywords can be arbitrary and the assertion can fail. The assertion on the next line

[issue29360] Don't check if all keys are strings in _PyStack_AsDict()

2017-01-24 Thread INADA Naoki
INADA Naoki added the comment: patch LGTM. Python 2 supported `dict(**{1:3})`. But I don't know there are any functions supporting non-string keyword argument. > PyPy (and other Python implementations?) don't support non-string in type > dictionary. Wow! I thought it's Python's language. If

[issue29360] Don't check if all keys are strings in _PyStack_AsDict()

2017-01-24 Thread STINNER Victor
New submission from STINNER Victor: While running the test suite on issues #29259 (tp_fastcall) and #29358 (tp_fastnew and tp_fastinit), a few test failed on the following assertion of _PyStack_AsDict(): assert(PyUnicode_CheckExact(key)); For example, test_dict calls dict(**{1: 2}) which

[issue29360] Don't check if all keys are strings in _PyStack_AsDict()

2017-01-24 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +inada.naoki, serhiy.storchaka ___ Python tracker ___