[Python-checkins] cpython: Replace bootstrap imports with real C API calls.
eli.bendersky
python-checkins at python.org
Thu Apr 5 04:42:51 CEST 2012
http://hg.python.org/cpython/rev/1ddf58262706
changeset: 76110:1ddf58262706
user: Eli Bendersky <eliben at gmail.com>
date: Thu Apr 05 05:40:58 2012 +0300
summary:
Replace bootstrap imports with real C API calls.
files:
Modules/_elementtree.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -3034,8 +3034,7 @@
PyMODINIT_FUNC
PyInit__elementtree(void)
{
- PyObject* m;
- PyObject* g;
+ PyObject *m, *g, *temp;
char* bootstrap;
/* Initialize object types */
@@ -3067,10 +3066,6 @@
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 @@
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");
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list