[Scons-users] env.Dictionary bug? doc problem?

Paweł Tomulik ptomulik at meil.pw.edu.pl
Mon Jul 23 08:11:58 EDT 2018


W dniu 22.07.2018 o 20:18, Mats Wichmann pisze:
> === manpage:
>
>  env.Dictionary([vars])
>
>     Returns a dictionary object containing copies of all of the
> construction variables in the environment. If there are any variable
> names specified, only the specified construction variables are returned
> in the dictionary.
>
>     Example:
>
>     dict = env.Dictionary()
>     cc_dict = env.Dictionary('CC', 'CCFLAGS', 'CCCOM')
>
>
> [...]
> And that's pretty easy to see in the code, which uses a list
> comprehension if there are arguments, extracting only the values and
> ignoring the keys.
>
>     def Dictionary(self, *args):
>         if not args:
>             return self._dict

Looks like it returns reference to the original internal dictionary, is
it the same as "a dictionary object containing copies of all of the
construction variables in the environment"

>         dlist = [self._dict[x] for x in args]
>         if len(dlist) == 1:
>             dlist = dlist[0]
>         return dlist

And this returns a list, not a dictionary.
>
> If the documentation is correct, what we really want is a "dictionary
> slicing" type of operation (maybe using itertools, maybe using a
> dictionary view object).
>

Looks like the implementation is not in accordance with the documentation .

-- 
Paweł Tomulik
Instytut Techniki Lotniczej i Mechaniki Stosowanej
Politechnika Warszawska
pok. 204, tel. +48 22 234 5722




More information about the Scons-users mailing list