summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2012-04-05 02:40:58 (GMT)
committerEli Bendersky <eliben@gmail.com>2012-04-05 02:40:58 (GMT)
commit828efdea568953666c099d3a9c11eab609663d95 (patch)
tree5993a5c273452da17e8c6cd95073e28632a0095f
parentb5ebf271de17597c12162abb49b0e0447f4c86b2 (diff)
downloadcpython-828efdea568953666c099d3a9c11eab609663d95.zip
cpython-828efdea568953666c099d3a9c11eab609663d95.tar.gz
cpython-828efdea568953666c099d3a9c11eab609663d95.tar.bz2
Replace bootstrap imports with real C API calls.
-rw-r--r--Modules/_elementtree.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index c5bbc80..4263497 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -3034,8 +3034,7 @@ static struct PyModuleDef _elementtreemodule = {
PyMODINIT_FUNC
PyInit__elementtree(void)
{
- PyObject* m;
- PyObject* g;
+ PyObject *m, *g, *temp;
char* bootstrap;
/* Initialize object types */
@@ -3067,10 +3066,6 @@ PyInit__elementtree(void)
PyDict_SetItemString(g, "__builtins__", PyEval_GetBuiltins());
bootstrap = (
-
- "from copy import deepcopy\n"
- "from xml.etree import ElementPath\n"
-
"def iter(node, tag=None):\n" /* helper */
" if tag == '*':\n"
" tag = None\n"
@@ -3094,8 +3089,14 @@ PyInit__elementtree(void)
if (!PyRun_String(bootstrap, Py_file_input, g, NULL))
return NULL;
- elementpath_obj = PyDict_GetItemString(g, "ElementPath");
- elementtree_deepcopy_obj = PyDict_GetItemString(g, "deepcopy");
+ if (!(temp = PyImport_ImportModule("copy")))
+ 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_itertext_obj = PyDict_GetItemString(g, "itertext");