Very strange issues with collections.Mapping
Chris Angelico
rosuav at gmail.com
Thu Jan 18 16:42:11 EST 2018
On Fri, Jan 19, 2018 at 8:37 AM, Jason Swails <jason.swails at gmail.com> wrote:
> The root cause of the issue comes down to the following check returning
> true:
>
> isinstance([], collections.Mapping)
>
> Obviously you can get this behavior if you register `list` as a subclass of
> the Mapping ABC, but I'm not doing that. Because the issue is so rare (but
> still common enough that I need to address it), it's hard to reproduce in a
> bench test.
Just a quickie: Have you confirmed for sure that it is a vanilla list
- that "type(x) is type([])" - not some subclass thereof?
Other than that, I don't have any specific tips; have fun
instrumenting your code to try to figure this out! (And I mean that
sincerely - this kind of thing CAN be fun.)
ChrisA
More information about the Python-list
mailing list