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.

Title: Python 2.7's is not compatible with Python 3's map
Type: behavior Stage: resolved
Components: Documentation Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: akuchling, docs@python, eric.smith,, jesstess, joncle, ncoghlan, python-dev, rhettinger
Priority: normal Keywords: needs review

Created on 2013-10-23 13:16 by, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
issue19363.patch, 2014-02-17 10:55 review
Messages (9)
msg201020 - (view) Author: Gareth Rees ( * (Python triager) Date: 2013-10-23 13:16
In Python 2.7, 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 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.
msg206812 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2013-12-22 10:20
I agree with you in principle, but it is far too late in 2.7's development to take away a capability.
msg209798 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2014-01-31 15:33
I agree with Raymond: it would have been nice to do this, but it's too late. Closing.
msg210249 - (view) Author: Gareth Rees ( * (Python triager) Date: 2014-02-04 16:40
What about a documentation change instead? The future_builtins chapter
<> in the
standard library documentation could note the incompatibility.

I've attached a patch which adds the following note to the
documentation for

    Note: In Python 3, map() does not accept None for the function
    argument. (zip() can be used instead.)
msg210639 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-02-08 13:43
Switched to be a docs-only bug as Gareth suggested.
msg211289 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2014-02-15 19:37
Gareth Rees: it doesn't look like you attached the patch mentioned in your 02/04 comment.
msg211407 - (view) Author: Gareth Rees ( * (Python triager) Date: 2014-02-17 10:55
Sorry about that; here it is. I had second thoughts about recommending zip() as an alternative (that would only work for cases where the None was constant; in other cases you might need lambda *args: args, but this seemed too complicated), so the note now says only:

    Note: In Python 3, map() does not accept None for the
    function argument.
msg212968 - (view) Author: Jessica McKellar (jesstess) * (Python triager) Date: 2014-03-09 18:33
Thanks for the patch, Gareth.Rees!

The patch applies cleanly and the docs build cleanly with it. I visually inspected the addition in the built HTML docs and it looks good.

=> patch review
msg212969 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-03-09 19:01
New changeset 16c5d7c289c6 by Benjamin Peterson in branch '2.7':
note that future_builtin's map is not quite like python 3's (closes #19363)
Date User Action Args
2022-04-11 14:57:52adminsetgithub: 63562
2014-03-09 19:01:29python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg212969

resolution: fixed
stage: patch review -> resolved
2014-03-09 18:33:53jesstesssetnosy: + jesstess
messages: + msg212968

keywords: + needs review, - patch
stage: needs patch -> patch review
2014-02-17 10:55:22gdr@garethrees.orgsetfiles: + issue19363.patch
keywords: + patch
messages: + msg211407
2014-02-15 19:37:50akuchlingsetnosy: + akuchling
messages: + msg211289
2014-02-08 13:43:16ncoghlansetassignee: rhettinger -> docs@python
components: + Documentation, - Library (Lib)

nosy: + ncoghlan, docs@python
messages: + msg210639
resolution: wont fix -> (no value)
stage: resolved -> needs patch
2014-02-04 16:40:21gdr@garethrees.orgsetstatus: closed -> open

messages: + msg210249
2014-01-31 15:33:32eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg209798

resolution: wont fix
stage: resolved
2013-12-22 10:20:16rhettingersetmessages: + msg206812
2013-10-24 16:30:30rhettingersetassignee: rhettinger

nosy: + rhettinger
2013-10-23 13:24:19jonclesetnosy: + joncle
2013-10-23 13:16:29gdr@garethrees.orgcreate