Skip to content

Commit e55628c

Browse files
committed
Remove Emscripten import trampoline
As far as I know this isn't actually needed. It was originally added to work around typos in the CPython test suite, but those typos have since been fixed and I am unaware of any user code that requires the trampoline.
1 parent 84caa33 commit e55628c

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

‎Python/import.c‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -839,16 +839,6 @@ _PyImport_ClearExtension(PyObject *name, PyObject *filename)
839839
}
840840

841841

842-
/*******************/
843-
844-
#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
845-
#include <emscripten.h>
846-
EM_JS(PyObject*, _PyImport_InitFunc_TrampolineCall, (PyModInitFunction func), {
847-
return wasmTable.get(func)();
848-
});
849-
#endif // __EMSCRIPTEN__ && PY_CALL_TRAMPOLINE
850-
851-
852842
/*****************************/
853843
/* single-phase init modules */
854844
/*****************************/
@@ -1285,7 +1275,7 @@ import_find_extension(PyThreadState *tstate, PyObject *name,
12851275
else {
12861276
if (def->m_base.m_init == NULL)
12871277
return NULL;
1288-
mod = _PyImport_InitFunc_TrampolineCall(def->m_base.m_init);
1278+
mod = def->m_base.m_init();
12891279
if (mod == NULL)
12901280
return NULL;
12911281
if (PyObject_SetItem(modules, name, mod) == -1) {
@@ -1400,7 +1390,7 @@ create_builtin(PyThreadState *tstate, PyObject *name, PyObject *spec)
14001390
/* Cannot re-init internal module ("sys" or "builtins") */
14011391
return import_add_module(tstate, name);
14021392
}
1403-
mod = _PyImport_InitFunc_TrampolineCall(*p->initfunc);
1393+
mod = (*p->initfunc)();
14041394
if (mod == NULL) {
14051395
return NULL;
14061396
}

‎Python/importdl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp)
166166

167167
/* Package context is needed for single-phase init */
168168
oldcontext = _PyImport_SwapPackageContext(newcontext);
169-
m = _PyImport_InitFunc_TrampolineCall(p0);
169+
m = p0();
170170
_PyImport_SwapPackageContext(oldcontext);
171171

172172
if (m == NULL) {

‎Python/importdl.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ extern PyObject *_PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *);
1212

1313
typedef PyObject *(*PyModInitFunction)(void);
1414

15-
#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
16-
extern PyObject *_PyImport_InitFunc_TrampolineCall(PyModInitFunction func);
17-
#else
18-
#define _PyImport_InitFunc_TrampolineCall(func) (func)()
19-
#endif
20-
2115
/* Max length of module suffix searched for -- accommodates "module.slb" */
2216
#define MAXSUFFIXSIZE 12
2317

0 commit comments

Comments
 (0)