On 29.11.2016 00:50, Brett Cannon wrote:
Seventh, these *.missing.py files if they are directly executed are totally going to be abused like *.pth files, I can just feel it in my bones. We need to be okay with this if we accept this PEP as-is.
Since the purpose of the PEP was to allow distributors to guide users through the installation process of extra packages in order to get access to parts of the stdlib which are not installed, I think the PEP is overly broad in concept to address this one use case. Just as with .pth files, the possibility to hook arbitrary code execution into the module search path will get abused for all kinds of weird things, esp. if the whole sys.path is scanned for the .missing.py module and not only the part where the stdlib lives (as was suggested in the thread). So why not limit the PEP to just the intended use case ? I.e. define a static list of modules which do make up the Python stdlib and then have the importer turn a ModuleNotFoundError error into a nice distribution specific error message, if and only if the imported module is from the set of stdlib modules. The change of the error message could be done by having the distributor patch the importer or we could have the importer call a function defined via sitecustomize.py by the distributor to return a message. Thinking about this some more... We don't even need a list of stdlib modules. Simply define a general purpose import error formatting function, e.g. sys.formatimporterror(), pass in the name of the module and let it determine the error message based on the available information. A distributor could then provide a custom function that knows about the installed Python packages and then guides the user to install any missing ones. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Experts (#1, Nov 29 2016)
Python Projects, Coaching and Consulting ... http://www.egenix.com/ Python Database Interfaces ... http://products.egenix.com/ Plone/Zope Database Interfaces ... http://zope.egenix.com/
::: We implement business ideas - efficiently in both time and costs ::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ http://www.malemburg.com/