python - Why does unpacking this map object print "must be an iterable, not map"? -
what going on here?
>>> 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 iterable, not map
ignore senselessness of code. error message, "iterable, not map". maps are iterables, not?
and if replace none
str
, whole thing works fine:
>>> list(map(lambda *x: x, *map(str, 'abc'))) [('a', 'b', 'c')]
so python doesn't have issue map
there after all.
this happens in python 3.6.1. python 3.5.2 instead raises expected typeerror: 'nonetype' object not callable
. , googling "must iterable, not map" finds no results @ all. apparently introduced recently.
is python bug? or there sense this?
update: reported bug now, suggested.
i'd consider bug. here's source causes exception:
a disassembly of python bytecode confirms using build_tuple_unpack_with_call
the "bug" in code above assumes any typeerror
while _pylist_extend
ing argument array means wasn't iterable, __iter__
raise typeerror. rethrowing exception
i'd suggest opening bug @ https://bugs.python.org
Comments
Post a Comment