mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #24931: Resolve __dict__ conflict in namedtuple subclasses.
This commit is contained in:
parent
1a83746418
commit
7a3602e7cf
4 changed files with 19 additions and 14 deletions
|
@ -272,23 +272,14 @@ class {typename}(tuple):
|
|||
'Return a nicely formatted representation string'
|
||||
return self.__class__.__name__ + '({repr_fmt})' % self
|
||||
|
||||
@property
|
||||
def __dict__(self):
|
||||
'A new OrderedDict mapping field names to their values'
|
||||
return OrderedDict(zip(self._fields, self))
|
||||
|
||||
def _asdict(self):
|
||||
'Return a new OrderedDict which maps field names to their values.'
|
||||
return self.__dict__
|
||||
return OrderedDict(zip(self._fields, self))
|
||||
|
||||
def __getnewargs__(self):
|
||||
'Return self as a plain tuple. Used by copy and pickle.'
|
||||
return tuple(self)
|
||||
|
||||
def __getstate__(self):
|
||||
'Exclude the OrderedDict from pickling'
|
||||
return None
|
||||
|
||||
{field_defs}
|
||||
"""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue