Author lemburg
Recipients ezio.melotti, lemburg, shihai1991, vstinner
Date 2020-09-23.16:51:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <b893849d-ab4f-d985-8b8c-8767b76de1c7@egenix.com>
In-reply-to <1600872594.55.0.261984022225.issue41842@roundup.psfhosted.org>
Content
On 23.09.2020 16:49, STINNER Victor wrote:
> 
> STINNER Victor <vstinner@python.org> added the comment:
> 
>> Just found an internal API which already takes care of
>> unregistering a search function: _PyCodec_Forget().
>>
>> All that needs to be done is to expose this as codecs.unregister()
>> and add the clearing of the lookup cache.
> 
> Yeah, I saw this function, but it's related to the cache, not to the list of search functions.

Ah, right. I just looked at the first occurance of codec_search_path :-)

>> BTW: While you're at it, having a way to access the search function
>> list from Python would be nice as well, since this would then open
>> up the possibility to reorder search functions.
> 
> I didn't hear anyone (ok, apart you) who requested to order search functions.

This has come up in the past from people who wanted to override
builtin codecs with their own versions.

> I dislike the idea of exposing it, since it introduces the risk that someone "unregisters" a search function simply by removing it from the list, without invalidating the cache.
> 
> I prefer to hide the internals to ensure that the cache remains consistent.

Sure, a function would merely return a tuple with the entries,
not the list itself, e.g. in pseudo code:

def get_search_path():
    return tuple(interp->codec_search_path)

For replacing the vanilla setup, this is not needed, since only
one search function gets registered (the builtin one), so rather
low priority, I guess.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Sep 23 2020)
>>> Python Projects, Coaching and Support ...    https://www.egenix.com/
>>> Python Product Development ...        https://consulting.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
               https://www.egenix.com/company/contact/
                     https://www.malemburg.com/
History
Date User Action Args
2020-09-23 16:51:36lemburgsetrecipients: + lemburg, vstinner, ezio.melotti, shihai1991
2020-09-23 16:51:36lemburglinkissue41842 messages
2020-09-23 16:51:36lemburgcreate