gh-117953: Add Internal struct _Py_ext_module_loader_info (gh-118194)

This helps with a later change that splits up _PyImport_LoadDynamicModuleWithSpec().
This commit is contained in:
Eric Snow 2024-04-24 11:42:01 -06:00 committed by GitHub
parent 9b280ab0ab
commit 5865fa5f9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 180 additions and 94 deletions

View file

@ -14,10 +14,38 @@ extern "C" {
extern const char *_PyImport_DynLoadFiletab[];
extern PyObject *_PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *);
typedef PyObject *(*PyModInitFunction)(void);
struct _Py_ext_module_loader_info {
PyObject *filename;
#ifndef MS_WINDOWS
PyObject *filename_encoded;
#endif
PyObject *name;
PyObject *name_encoded;
/* path is always a borrowed ref of name or filename,
* depending on if it's builtin or not. */
PyObject *path;
const char *hook_prefix;
const char *newcontext;
};
extern void _Py_ext_module_loader_info_clear(
struct _Py_ext_module_loader_info *info);
extern int _Py_ext_module_loader_info_init(
struct _Py_ext_module_loader_info *info,
PyObject *name,
PyObject *filename);
extern int _Py_ext_module_loader_info_init_from_spec(
struct _Py_ext_module_loader_info *info,
PyObject *spec);
extern PyObject *_PyImport_LoadDynamicModuleWithSpec(
struct _Py_ext_module_loader_info *info,
PyObject *spec,
FILE *fp);
/* Max length of module suffix searched for -- accommodates "module.slb" */
#define MAXSUFFIXSIZE 12