New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>: Usually non-string keyword names are rejected.
>>> def f(**kwargs): pass >>> >>> >>> ... >>> f(**{0:0}) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: f() keywords must be strings >>> dict(**{0:0}) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: keywords must be strings There are checks in multiple places that satisfy this: in _PyEval_EvalCodeWithName(), PyArg_ValidateKeywordArguments(), PyArg_ParseTupleAndKeywords(), etc. But SimpleNamespace is an exception. >>> from types import SimpleNamespace >>> SimpleNamespace(**{0:0}) namespace() Non-string keys are omitted in the repr. Wouldn't be better to add also the check that keyword names for SimpleNamespace constructor are strings? I don't know how classify this issue, as a bug or an enhancement. Based on the StackOverflow question: https://stackoverflow.com/questions/46164770/accepting-integers-as-keys-of-kwargs. ---------- components: Interpreter Core messages: 303450 nosy: haypo, serhiy.storchaka priority: normal severity: normal status: open title: SimpleNamespace accepts non-string keyword names _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31655> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com