This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients lac, markroseman, terry.reedy
Date 2015-10-31.05:41:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When users 'saveas', warn if name matches that of a stdlib modules. Note that shadowing is opposite for lib and binary (builtin) modules, so message needs to be different.  I am not worrying about 3rd party modules on the search path (ie, site-packages), which would be shadowed like lib modules. Rough outline of code to add to IOBinding.

from os,path import dirname
import sys

# this part on initiallzation or first saveas call
def libmodules():
    with open(dirname(dirname(__file__))) as lib:
        for f in lib:
            if <directory containing> or f.endswith(.py):
                yield f
# test.test__all__ has this code

islibmodule = frozenset(libmodules()).__contains__
isbinmodule = frozenset(sys.builtin_module_names).__contains__

# this part after saveas dialog returns
if islibmodule(name):
    go = warn("This name matches a stdlib name in /Lib. If you run python in this directory, you will not be able to import the stdlib module.  Continue?".)
elif isbinmodule(name):
    go = warn("This name matches a builtin stdlib name.  You will not be able to import this file.  Continue?".)
    go = True
if go:
    <save as requested>
   (get name again>  # or put in while not go loop
Date User Action Args
2015-10-31 05:41:43terry.reedysetrecipients: + terry.reedy, markroseman, lac
2015-10-31 05:41:42terry.reedysetmessageid: <>
2015-10-31 05:41:42terry.reedylinkissue25522 messages
2015-10-31 05:41:41terry.reedycreate