mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
parent
d7adfe129c
commit
95919c096c
2 changed files with 31 additions and 5 deletions
|
@ -2000,6 +2000,10 @@ class NamedTupleMeta(type):
|
|||
default_names=', '.join(defaults_dict.keys())))
|
||||
nm_tpl.__new__.__defaults__ = tuple(defaults)
|
||||
nm_tpl._field_defaults = defaults_dict
|
||||
# update from user namespace without overriding special namedtuple attributes
|
||||
for key in ns:
|
||||
if not hasattr(nm_tpl, key):
|
||||
setattr(nm_tpl, key, ns[key])
|
||||
return nm_tpl
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue