mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
gh-55664: Add warning when creating a type using a namespace dictionary with non-string keys. (GH-105338)
Co-authored-by: Daniel Urban <durban@users.noreply.github.com>
This commit is contained in:
parent
3bb6912d88
commit
f7c05d7ad3
3 changed files with 28 additions and 1 deletions
|
@ -3828,6 +3828,17 @@ type_new_impl(type_new_ctx *ctx)
|
|||
// Put the proper slots in place
|
||||
fixup_slot_dispatchers(type);
|
||||
|
||||
if (!_PyDict_HasOnlyStringKeys(type->tp_dict)) {
|
||||
if (PyErr_WarnFormat(
|
||||
PyExc_RuntimeWarning,
|
||||
1,
|
||||
"non-string key in the __dict__ of class %.200s",
|
||||
type->tp_name) == -1)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (type_new_set_names(type) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue