Message87291
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 |
|
Date |
User |
Action |
Args |
2009-05-05 21:47:16 | jmillikin | set | recipients:
+ jmillikin |
2009-05-05 21:47:16 | jmillikin | set | messageid: <1241560036.33.0.817766851688.issue5945@psf.upfronthosting.co.za> |
2009-05-05 21:47:14 | jmillikin | link | issue5945 messages |
2009-05-05 21:47:14 | jmillikin | create | |
|