为什么解包此地图对象会打印 "must be an iterable, not map"?

Why does unpacking this map object print "must be an iterable, not map"?

这是怎么回事?

>>> list(map(lambda *x: x, *map(None, 'abc')))
Traceback (most recent call last):
  File "<pyshell#52>", line 1, in <module>
    list(map(lambda *x: x, *map(None, 'abc')))
TypeError: type object argument after * must be an iterable, not map

忽略代码的无意义。这是关于错误信息,"iterable, not map"。地图 可迭代的,不是吗?

如果我只将 None 替换为 str,整个事情就可以正常进行:

>>> list(map(lambda *x: x, *map(str, 'abc')))
[('a', 'b', 'c')]

所以现在 Python 对 map 没有任何问题。

这发生在我的 Python 3.6.1 中。我的 Python 3.5.2 反而提高了预期的 TypeError: 'NoneType' object is not callable。谷歌搜索 "must be an iterable, not map" 根本找不到任何结果。所以很明显这是最近才推出的东西。

这只是一个 Python 错误吗?或者这有什么意义吗?

更新: Reported as bug 现在,按照建议。

我认为这是一个错误。这是导致此异常的来源:

https://github.com/python/cpython/blob/b1660800f4f519dbfab9e5a4ad3eae1cfabab3ed/Python/ceval.c#L2514-L2523

python 字节码的反汇编确认它正在使用 BUILD_TUPLE_UNPACK_WITH_CALL

上面代码中的 "bug" 是假设 any TypeError_PyList_Extending 参数数组意味着它不是可迭代,但是 __iter__ 本身可能引发 TypeError。它正在重新抛出这个异常

我建议在 https://bugs.python.org

打开一个错误