[New-bugs-announce] [issue19363] Python 2.7's future_builtins.map is not compatible with Python 3's map

Gareth Rees report at bugs.python.org
Wed Oct 23 15:16:29 CEST 2013


New submission from Gareth Rees:

In Python 2.7, future_builtins.map accepts None as its first (function) argument:

    Python 2.7.5 (default, Aug  1 2013, 01:01:17) 
    >>> from future_builtins import map
    >>> list(map(None, range(3), 'ABC'))
    [(0, 'A'), (1, 'B'), (2, 'C')]

But in Python 3.x, map does not accept None as its first argument:

    Python 3.3.2 (default, May 21 2013, 11:50:47) 
    >>> list(map(None, range(3), 'ABC'))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'NoneType' object is not callable

The documentation says, "if you want to write code compatible with Python 3 builtins, import them from this module," so this incompatibility may give Python 2.7 programmers the false impression that a program which uses map(None, ...) is portable to Python 3.

I suggest that future_builtins.map in Python 2.7 should behave the same as map in Python 3: that is, it should raise a TypeError if None was passed as the first argument.

----------
components: Library (Lib)
messages: 201020
nosy: Gareth.Rees
priority: normal
severity: normal
status: open
title: Python 2.7's future_builtins.map is not compatible with Python 3's map
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19363>
_______________________________________


More information about the New-bugs-announce mailing list