[Scons-users] error on scons 3.1.1. nd python 3.5

Mats Wichmann mats at wichmann.us
Fri Oct 25 09:24:49 EDT 2019


On 10/25/19 6:12 AM, daggs wrote:
> Greetings Bill,
> I do have custom builders.
> I'm not sure what you mean by "your build system", can you elaborate please?
> infact, now that I think of it, I'm in the process of migrating a 
> project that worked on scons + python 2.7 to newer scons  python 3.5.
> I remember that the old code used lambda and maybe map in the same 
> manner within a func which scans a folder, looks for all files with a 
> specific extension.
> in addition, I have hte ability to run just the parts with the custom 
> builders and not all the project, in that scenario, I don't see the error.
> so this might be the issue.
> I'll check an update,
> Thanks for the help.


>         AttributeError: 'map' object has no attribute 'get_state':
...
>         "/home/daggs/workspace/scons_3.0/scons-3.1.1/bin/../engine/SCons/Taskmaster.py",
>         line 860:
>              childstate = child.get_state()
> 
>         what is is error and how can I solve it?

Indeed, as Bill noted, map() now returns a special object (map object), 
which you can then iterate over, as opposed to the mapped list.  Part of 
porting scons itself to Python 3 was wrapping nearly every instance of 
map that is going to passed around in a list call (it's not needed if 
you proceed to iterate over it, or use a join to create a string 
representation, etc. but a lot of places made something by map and 
returned it to the caller). So:

slist = map(str, source)

becomes

slist = list(map(str, source))

that is quick and it works although it does give right back the 
speed/memory gains the Python developers tried to give us by not needing 
to generate the whole list on the spot.

as an aside, I find I very rarely use map/filter any more, usually a 
comprehension will be more expressive for me. I think the generic advice 
may be map can be marginally faster, if performance is critical, but 
only in the case where you have an existing function which is called (my 
example above of calling str); if you need a lambda as the map function, 
the comprehension will win.


More information about the Scons-users mailing list