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:

https://github.com/python/cpython/blob/b1660800f4f519dbfab9e5a4ad3eae1cfabab3ed/python/ceval.c#l2514-l2523

a disassembly of python bytecode confirms using build_tuple_unpack_with_call

the "bug" in code above assumes any typeerror while _pylist_extending argument array means wasn't iterable, __iter__ raise typeerror. rethrowing exception

i'd suggest opening bug @ https://bugs.python.org


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -