This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients NeilGirdhar, alexdelorenzo, eric.smith, levkivskyi, rhettinger
Date 2018-08-10.20:53:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
For the record, I don't disagree with namedtuples not having a base class.

Maybe it's best to let copy.deepcopy() deal with namedtuples, instead of trying to detect them here. So just special case exact tuples and lists, and pass everything else to copy.deepcopy().

>>> C = namedtuple('C', 'a b c')
>>> c = C(1, 2, 3)
>>> b=copy.deepcopy(c)
>>> b
C(a=1, b=2, c=3)
>>> hasattr(b, '_fields')
>>> hasattr(c, '_fields')
>>> b is c

Although by doing that, you lose dict_factory or tuple_factory on nested data structures, and namedtuples that contain dataclasses would be handled differently, I think. I'll do some investigating.
Date User Action Args
2018-08-10 20:53:14eric.smithsetrecipients: + eric.smith, rhettinger, NeilGirdhar, levkivskyi, alexdelorenzo
2018-08-10 20:53:14eric.smithsetmessageid: <>
2018-08-10 20:53:14eric.smithlinkissue34363 messages
2018-08-10 20:53:14eric.smithcreate