[Python-Dev] cpython: Simplify the code of get_attrib_from_keywords somewhat.

Serhiy Storchaka storchaka at gmail.com
Mon Apr 22 19:13:49 CEST 2013


On 22.04.13 15:52, eli.bendersky wrote:
> http://hg.python.org/cpython/rev/c9674421d78e
> changeset:   83494:c9674421d78e
> user:        Eli Bendersky <eliben at gmail.com>
> date:        Mon Apr 22 05:52:16 2013 -0700
> summary:
>    Simplify the code of get_attrib_from_keywords somewhat.

> -        PyDict_DelItem(kwds, attrib_str);
> +        PyDict_DelItemString(kwds, ATTRIB_KEY);

PyDict_GetItemString() and PyDict_DelItemString() internally create a 
Python string. I.e. new code creates one additional string if attrib was 
found in kwds.

> -    if (attrib)
> -        PyDict_Update(attrib, kwds);
> +    assert(attrib);

attrib can be NULL in case of memory allocation error.




More information about the Python-Dev mailing list