Commit 828efdea authored by Eli Bendersky's avatar Eli Bendersky

Replace bootstrap imports with real C API calls.

parent b5ebf271
...@@ -3034,8 +3034,7 @@ static struct PyModuleDef _elementtreemodule = { ...@@ -3034,8 +3034,7 @@ static struct PyModuleDef _elementtreemodule = {
PyMODINIT_FUNC PyMODINIT_FUNC
PyInit__elementtree(void) PyInit__elementtree(void)
{ {
PyObject* m; PyObject *m, *g, *temp;
PyObject* g;
char* bootstrap; char* bootstrap;
/* Initialize object types */ /* Initialize object types */
...@@ -3067,10 +3066,6 @@ PyInit__elementtree(void) ...@@ -3067,10 +3066,6 @@ PyInit__elementtree(void)
PyDict_SetItemString(g, "__builtins__", PyEval_GetBuiltins()); PyDict_SetItemString(g, "__builtins__", PyEval_GetBuiltins());
bootstrap = ( bootstrap = (
"from copy import deepcopy\n"
"from xml.etree import ElementPath\n"
"def iter(node, tag=None):\n" /* helper */ "def iter(node, tag=None):\n" /* helper */
" if tag == '*':\n" " if tag == '*':\n"
" tag = None\n" " tag = None\n"
...@@ -3094,8 +3089,14 @@ PyInit__elementtree(void) ...@@ -3094,8 +3089,14 @@ PyInit__elementtree(void)
if (!PyRun_String(bootstrap, Py_file_input, g, NULL)) if (!PyRun_String(bootstrap, Py_file_input, g, NULL))
return NULL; return NULL;
elementpath_obj = PyDict_GetItemString(g, "ElementPath"); if (!(temp = PyImport_ImportModule("copy")))
elementtree_deepcopy_obj = PyDict_GetItemString(g, "deepcopy"); return NULL;
elementtree_deepcopy_obj = PyObject_GetAttrString(temp, "deepcopy");
Py_XDECREF(temp);
if (!(elementpath_obj = PyImport_ImportModule("xml.etree.ElementPath")))
return NULL;
elementtree_iter_obj = PyDict_GetItemString(g, "iter"); elementtree_iter_obj = PyDict_GetItemString(g, "iter");
elementtree_itertext_obj = PyDict_GetItemString(g, "itertext"); elementtree_itertext_obj = PyDict_GetItemString(g, "itertext");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment