Message244655
The argparse Namespace can be missleading in case where the args names are not valid identifiers, eg thinks like a closing bracket:
In [5]: Namespace(a=1, **{')':3})
Out[5]: Namespace()=3, a=1)
more funny:
In [3]: Namespace(a=1, **{s:3})
Out[3]: Namespace(a=1, b=2), Namespace(c=3)
for `s = 'b=2), Namespace(c'`
With this patch the args that are not valid identifiers are shown in ** unpacked-dict, which has the side effect of almost always having repr(eval(repr(obj)))== repr(obj). I'm sure we can find counter example with quotes and triple-quoted string... but anyway.
with this patch (indentation mine for easy comparison):
>>> from argparse import Namespace
>>> Namespace(a=1, **{')': 3})
Namespace(a=1, **{')': 3})
Which is I think what most user would expect.
Test passes locally (except SSL cert, network thingies, curses and threaded_lru_cache) which look unrelated and is most likely due to my machine. |
|
Date |
User |
Action |
Args |
2015-06-02 06:00:52 | mbussonn | set | recipients:
+ mbussonn |
2015-06-02 06:00:51 | mbussonn | set | messageid: <1433224851.97.0.184092285023.issue24360@psf.upfronthosting.co.za> |
2015-06-02 06:00:51 | mbussonn | link | issue24360 messages |
2015-06-02 06:00:51 | mbussonn | create | |
|