summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2000-08-27 20:31:27 (GMT)
committerThomas Wouters <thomas@python.org>2000-08-27 20:31:27 (GMT)
commitdd13e4f91ff2d8824e852afaec59d95d7dd409b3 (patch)
tree89497ccf5d8b6307d7b32bb71a8142c00b494bfa /Python/ceval.c
parente868211e106d4da348925e1c1bd1ea62b3560721 (diff)
downloadcpython-dd13e4f91ff2d8824e852afaec59d95d7dd409b3.zip
cpython-dd13e4f91ff2d8824e852afaec59d95d7dd409b3.tar.gz
cpython-dd13e4f91ff2d8824e852afaec59d95d7dd409b3.tar.bz2
Replace the run-time 'future-bytecode-stream-inspection' hack to find out
how 'import' was called with a compiletime mechanism: create either a tuple of the import arguments, or None (in the case of a normal import), add it to the code-block constants, and load it onto the stack before calling IMPORT_NAME.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c56
1 files changed, 1 insertions, 55 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 2648add..53a5177 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -71,7 +71,6 @@ static int import_all_from(PyObject *, PyObject *);
static PyObject *build_class(PyObject *, PyObject *, PyObject *);
static int exec_statement(PyFrameObject *,
PyObject *, PyObject *, PyObject *);
-static PyObject *find_from_args(PyFrameObject *, int);
static void set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *);
static void reset_exc_info(PyThreadState *);
@@ -1627,11 +1626,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
"__import__ not found");
break;
}
- u = find_from_args(f, INSTR_OFFSET());
- if (u == NULL) {
- x = u;
- break;
- }
+ u = POP();
w = Py_BuildValue("(OOOO)",
w,
f->f_globals,
@@ -3068,55 +3063,6 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
return 0;
}
-/* Hack for ni.py */
-static PyObject *
-find_from_args(PyFrameObject *f, int nexti)
-{
- int opcode;
- int oparg;
- PyObject *list, *name;
- unsigned char *next_instr;
-
- _PyCode_GETCODEPTR(f->f_code, &next_instr);
- next_instr += nexti;
-
- opcode = (*next_instr++);
- if (opcode != IMPORT_FROM && opcode != IMPORT_STAR) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- list = PyList_New(0);
- if (list == NULL)
- return NULL;
-
- if (opcode == IMPORT_STAR) {
- name = PyString_FromString("*");
- if (!name)
- Py_DECREF(list);
- else {
- if (PyList_Append(list, name) < 0) {
- Py_DECREF(list);
- }
- Py_DECREF(name);
- }
- } else {
- do {
- oparg = (next_instr[1]<<8) + next_instr[0];
- /* Jump over our own argument, the next instruction
- (which is a STORE), and its argument.*/
- next_instr += 5;
- name = Getnamev(f, oparg);
- if (PyList_Append(list, name) < 0) {
- Py_DECREF(list);
- break;
- }
- opcode = (*next_instr++);
- } while (opcode == IMPORT_FROM);
- }
- return list;
-}
-
#ifdef DYNAMIC_EXECUTION_PROFILE