A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-August/037718.html below:

[Python-Dev] PyMapping_Check Bug?

[Python-Dev] PyMapping_Check Bug? [Python-Dev] PyMapping_Check Bug?Guido van Rossum guido at python.org
Mon Aug 18 08:03:43 EDT 2003
> Are these OK, though:
> 
> >>> operator.isMappingType(())
> True
> >>> operator.isMappingType([])
> True
> >>> operator.isMappingType("")
> True

These are because those types have all grown a mapping-style getitem
implementation in order to support extended slicing.

> I just found out that this change is the cause for a Bug in my shapelib
> bindings which at one point try to determine whether a method argument
> is a dictionary like object by testing whether PyMapping_Check returns
> true and that assume it's a sequence otherwise.

> As a work-around it seems I can use isSequenceType/PySequence_Check to
> effectively turn the test around and determine whether the object is a
> sequence and assume it's a mapping otherwise.

Still, my suggestion is not to try to guess whether an object is a
sequence or a mapping.  The two APIs are too similar, and becoming
more so in each release.  Instead, you should have an explicit
indicator passed by the caller (maybe a keyword argument).

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4