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.

classification
Title: *args unpacking can mask TypeErrors
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Stefan Pochmann, r.david.murray, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-07-28 16:03 by Stefan Pochmann, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2957 merged serhiy.storchaka, 2017-07-31 10:31
PR 2991 merged serhiy.storchaka, 2017-08-03 08:40
Messages (4)
msg299402 - (view) Author: Stefan Pochmann (Stefan Pochmann) * Date: 2017-07-28 16:03
Python 3.6 makes it sound like maps aren't iterable:

>>> map(str, *map(int, [[]]))
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    map(str, *map(int, [[]]))
TypeError: type object argument after * must be an iterable, not map

More, including a likely explanation, in my question and its answer here:
https://stackoverflow.com/q/45363330/1672429

Apparently the TypeError from int([]) gets mistaken for a TypeError indicating non-iterability of the map object.
msg299411 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-07-28 17:07
Thanks for the report.  Retitling because this has nothing to do with map:

>>> def foo(*args):
...     raise TypeError('fake')
...     yield 1
... 
>>> foo(1, *foo())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: foo() argument after * must be an iterable, not generator
>>> foo(*foo())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in foo
TypeError: fake
msg299690 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-08-03 08:37
New changeset 25e4f779d7ae9f37a1933cb5cbfad06e673c01f9 by Serhiy Storchaka in branch 'master':
bpo-31071: Avoid masking original TypeError in call with * unpacking (#2957)
https://github.com/python/cpython/commit/25e4f779d7ae9f37a1933cb5cbfad06e673c01f9
msg299694 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-08-03 09:14
New changeset 946a0b69e217ff22a6c056047eab42053e9a2d5f by Serhiy Storchaka in branch '3.6':
[3.6] bpo-31071: Avoid masking original TypeError in call with * unpacking (GH-2957) (#2991)
https://github.com/python/cpython/commit/946a0b69e217ff22a6c056047eab42053e9a2d5f
History
Date User Action Args
2022-04-11 14:58:49adminsetgithub: 75254
2017-08-03 09:18:25serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-08-03 09:14:37serhiy.storchakasetmessages: + msg299694
2017-08-03 08:40:10serhiy.storchakasetpull_requests: + pull_request3030
2017-08-03 08:37:19serhiy.storchakasetmessages: + msg299690
2017-07-31 10:32:38serhiy.storchakasetassignee: serhiy.storchaka

nosy: + serhiy.storchaka
components: + Interpreter Core
stage: needs patch -> patch review
2017-07-31 10:31:51serhiy.storchakasetpull_requests: + pull_request3005
2017-07-28 17:07:53r.david.murraysetnosy: + r.david.murray
title: Bad error message about maps not iterable -> *args unpacking can mask TypeErrors
messages: + msg299411

versions: + Python 3.7
stage: needs patch
2017-07-28 16:03:22Stefan Pochmanncreate