[Python-Dev] problem with assignment shadows builtin warning

Samuele Pedroni pedronis@bluewin.ch
Mon, 16 Jun 2003 21:59:36 +0200


I really think this thing need a PEP.

I think especially describing the future semantics of bultin lookup.

While I see that reusing builtin names is contrived (but we are not always 
disallowing that, for backward compability), I see the proposed approach as 
rather adhoc: you can't mess with a module builtins view unelss it already did.

regards.


At 15:33 16.06.2003 -0400, Jeremy Hylton wrote:
>I ran into a problem with the new deprecation warning today.  When you
>are doing package imports, Python uses setattr to populate the namespace
>of the parent package.  That is, if you import A.B.C, Python does the
>equiavalent of setattr(A, "B", A.B) and setattr(A.B, "C", A.B.C).
>
>The result is that I get a bunch of deprecation warnings if my modules
>shadow builtin names.  Module names that are also builtin names are
>common in some work projects.  (Ouput from our test runner is at the end
>of the message.)
>
>Do we want to discourage the use of module names that overlap with
>builtin names?  If so, we need a better error message, because if you go
>to the line mentioned in the warning you won't see an obvious assignment
>:-).
>
>My initial reaction was that we should not have a deprecation warning
>for this kind of shadowing, but I'm growing less comfortable about the
>names.  I'd definitely complain about a top-level "import list"; I don't
>know why it is any better as a module within a package.
>
>Jeremy
>
>
>/home/jeremy/src/Zope3/build/lib.linux-i686-2.3/zope/app/security/_protections.py:85: 
>DeprecationWarning: assignment shadows builtin
>   from persistence.list import PersistentList
>/home/jeremy/src/Zope3/build/lib.linux-i686-2.3/zope/app/security/_protections.py:93: 
>DeprecationWarning: assignment shadows builtin
>   from persistence.dict import PersistentDict
>/home/jeremy/src/Zope3/build/lib.linux-i686-2.3/zope/app/event/globalservice.py:22: 
>DeprecationWarning: assignment shadows builtin
>   from zope.interface.type import TypeRegistry
>/home/jeremy/src/Zope3/build/lib.linux-i686-2.3/zope/app/ftp/__init__.py:22: 
>DeprecationWarning: assignment shadows builtin
>   from zope.app.interfaces.file import IReadFile, IWriteFile
>/home/jeremy/src/Zope3/build/lib.linux-i686-2.3/zodb/storage/tests/test_demo.py:21: 
>DeprecationWarning: assignment shadows builtin
>   from zodb.storage.file import FileStorage
>/home/jeremy/src/Zope3/build/lib.linux-i686-2.3/zope/app/event/subs.py:37: 
>DeprecationWarning: assignment shadows builtin
>   from zope.app.services.type import PersistentTypeRegistry
>/home/jeremy/src/Zope3/build/lib.linux-i686-2.3/zope/app/browser/content/image.py:19: 
>DeprecationWarning: assignment shadows builtin
>   from zope.app.browser.content.file import FileUpload
>/home/jeremy/src/Zope3/build/lib.linux-i686-2.3/zope/app/content/file.py:26: 
>DeprecationWarning: assignment shadows builtin
>   from zope.app.interfaces.content.file import IFile, IReadFile,
>IFileContent
>/home/jeremy/src/Zope3/build/lib.linux-i686-2.3/zope/app/content/image.py:18: 
>DeprecationWarning: assignment shadows builtin
>   from zope.app.content.file import File
>
>
>
>_______________________________________________
>Python-Dev mailing list
>Python-Dev@python.org
>http://mail.python.org/mailman/listinfo/python-dev