[Python-Dev] PEP 578: Python Runtime Audit Hooks (original) (raw)
Steve Dower steve.dower at python.org
Sat Mar 30 12:13:30 EDT 2019
- Previous message (by thread): [Python-Dev] PEP 578: Python Runtime Audit Hooks
- Next message (by thread): [Python-Dev] PEP 578: Python Runtime Audit Hooks
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 30Mar.2019 0747, Nick Coghlan wrote:
I like this PEP in principle, but the specific "openforimport" name bothers me a lot, as it implies that "importing" is the only situation where a file will be opened for code execution.
If this part of the API were lower down the stack (e.g. "io.openforcodeexecution") then I think it would make more sense - APIs like tokenize.open(), runpy.runpath(), PyRunSimpleFile(), shelve, etc, could use that, without having to introduce a dependency on importlib to get access to the functionality.
It was called "open_for_exec" at one point, though I forget exactly why we changed it. But I have no problem with moving it. Something like this?
PyImport_OpenForImport -> PyIO_OpenForExec PyImport_SetOpenForImportHook -> PyIO_SetOpenForExecHook importlib.util.open_for_import -> _io.open_for_exec
Or more in line with Nick's suggestion:
PyImport_OpenForImport -> PyIO_OpenExecutableCode PyImport_SetOpenForImportHook -> PyIO_SetOpenExecutableCodeHook importlib.util.open_for_import -> _io.open_executable_code
I dropped "For", but I don't really care that much about the name. I'd be okay dropping either "executable" or "code" as well - I don't really have a good sense of which will make people more likely to use this correctly.
Cheers, Steve
- Previous message (by thread): [Python-Dev] PEP 578: Python Runtime Audit Hooks
- Next message (by thread): [Python-Dev] PEP 578: Python Runtime Audit Hooks
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]