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 jmillikin
Recipients jmillikin
Date 2009-05-05.21:47:13
SpamBayes Score 9.992007e-15
Marked as misclassified No
Message-id <1241560036.33.0.817766851688.issue5945@psf.upfronthosting.co.za>
In-reply-to
Content
In Python 2, PyMapping_Check will return 0 for list objects. In Python
3, it returns 1. Obviously, this makes it rather difficult to
differentiate between mappings and other sized iterables. In addition,
it differs from the behavior of the ``collections.Mapping`` ABC --
isinstance([], collections.Mapping) returns False.

Since most of the PyMapping_* functions don't seem to work properly on
lists, I believe this behavior is erroneous.

The behavior can be seen from a C extension, or if you're lazy, using
ctypes:

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.CDLL('libpython2.6.so').PyMapping_Check(ctypes.py_object([]))
0

Python 3.0.1+ (r301:69556, Apr 15 2009, 15:59:22)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.CDLL('libpython3.0.so').PyMapping_Check(ctypes.py_object([]))
1
History
Date User Action Args
2009-05-05 21:47:16jmillikinsetrecipients: + jmillikin
2009-05-05 21:47:16jmillikinsetmessageid: <1241560036.33.0.817766851688.issue5945@psf.upfronthosting.co.za>
2009-05-05 21:47:14jmillikinlinkissue5945 messages
2009-05-05 21:47:14jmillikincreate