A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-June/036426.html below:

[Python-Dev] problem with assignment shadows builtin warning

[Python-Dev] problem with assignment shadows builtin warning [Python-Dev] problem with assignment shadows builtin warningGuido van Rossum guido@python.org
Mon, 16 Jun 2003 16:17:01 -0400
> The simplest fix is to operate on the dict directly rather than using
> PyObject_SetAttrString on the module.  It's a little ugly because the it
> looks like that import code isn't limited to operating on modules.  I
> guess the patch would have to be something like
> 
>     if (PyModule_Check(mod)) {
>         PyObject *dict = PyModule_GetDict(mod);
>         if (!dict) {
>             Py_XDECREF(m);
>             m = NULL;
>         }
>         else if (PyDict_SetItemString(dict, subname, res) < 0) {
>             Py_XDECREF(m);
>             m = NULL;
>         }
>     }
>     else {
>         PyObject_SetAttrString(mod, subname, res) < 0) {
>             Py_XDECREF(m);
>             m = NULL;
>         }
>     }
> 
> Ugly.  Luckily that's the only PyObject_SetAttrString() in the import
> code.

But it sounds like a good idea to check this in.  Please add a comment
like

/* Don't want to use PyObject_SetAttrString() because of warnings about
   overriding builtins when the submodule name happens to shadow a
   built-in */

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4