bpo-39142: Avoid converting namedtuple instances to ConvertingTuple. (GH-17773)

This uses the heuristic of assuming a named tuple is a subclass of
tuple with a _fields attribute. This change means that contents of
a named tuple wouldn't be converted - if a user wants to have
ConvertingTuple functionality from a namedtuple, they will have to
implement it themselves.
This commit is contained in:
Vinay Sajip 2020-01-01 19:32:11 +00:00 committed by GitHub
parent 22424c02e5
commit 46abfc1416
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View file

@ -448,7 +448,7 @@ class BaseConfigurator(object):
value = ConvertingList(value)
value.configurator = self
elif not isinstance(value, ConvertingTuple) and\
isinstance(value, tuple):
isinstance(value, tuple) and not hasattr(value, '_fields'):
value = ConvertingTuple(value)
value.configurator = self
elif isinstance(value, str): # str for py3k