[issue29821] importing module shutil executes file 'copy.py'

Ammar Askar report at bugs.python.org
Wed Mar 15 17:06:17 EDT 2017


Ammar Askar added the comment:

As per discussion with haypo on irc, this is not a bug since essentially you've made a file which shadows the following stdlib module https://docs.python.org/3/library/copy.html

When shutil goes to import the copy module, your copy module is given higher priority in the import machinery which is why your code gets executed. You can read up more about this here: http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html#the-name-shadowing-trap

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29821>
_______________________________________


More information about the Python-bugs-list mailing list