[Python-ideas] PEP: Distributing a Subset of the Standard Library

Tomas Orsava torsava at redhat.com
Mon Dec 5 04:56:58 EST 2016


On 12/03/2016 05:08 AM, Nick Coghlan wrote:
>> Though I believe the default sys.excepthook function is currently written in
>> C, so it wouldn't be very easy for distributors to customize it. Maybe it
>> could be made to read module=error_message pairs from some external file,
>> which would be easier to modify?
> The default implementation is written in C, but distributors could
> patch site.py to replace it with a custom one written in Python. For
> example, publish a "fedora-hooks" module to PyPI (so non-system Python
> installations or applications regularly run without the site module
> can readily use the same hooks if they choose to do so), and then
> patch site.py in the system Python to do:
>
>      import fedora_hooks
>      fedora_hooks.install_excepthook()
>
> The nice thing about that approach is it wouldn't need a new switch to
> turn it off - it would get turned off with all the other site-specific
> customisations when -S or -I is used. It would also better open things
> up to redistributor experimentation in existing releases (2.7, 3.5,
> etc) before we commit to a specific approach in the reference
> interpreter (such as adding an optional 'platform.hooks' submodule
> that vendors may provide, and relevant stdlib APIs will then call
> automatically to override the default upstream provided processing).

Ah, but of course! That leaves us with only one part of the PEP 
unresolved: When the build process is unable to compile some modules 
when building Python from source (such as _sqlite3 due to missing sqlite 
headers), it would be great to provide a custom message when one then 
tries to import such module when using the compiled Python.

Do you see a 'pretty' solution for that within this framework?

Yours aye,
Tomas


More information about the Python-ideas mailing list