homepage

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 <1446270102.89.0.424617028731.issue25522@psf.upfronthosting.co.za>
In-reply-to
Content
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 __init__.py#> 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?".)
else:
 go = True
if go:
 <save as requested>
else:
 (get name again> # or put in while not go loop
History
Date User Action Args
2015年10月31日 05:41:43terry.reedysetrecipients: + terry.reedy, markroseman, lac
2015年10月31日 05:41:42terry.reedysetmessageid: <1446270102.89.0.424617028731.issue25522@psf.upfronthosting.co.za>
2015年10月31日 05:41:42terry.reedylinkissue25522 messages
2015年10月31日 05:41:41terry.reedycreate

AltStyle によって変換されたページ (->オリジナル) /