-#ifndef IS_PY3K
-static void
-py_restore_tstate (void *p)
-{
- PyFrameObject *frame = p;
- PyThreadState *tstate = PyThreadState_GET ();
-
- tstate->frame = frame;
-}
-
-/* Create a dummy PyFrameObject, needed to work around
- a Python-2.4 bug with generators. */
-static PyObject *
-push_dummy_python_frame (void)
-{
- PyObject *empty_string, *null_tuple, *globals;
- PyCodeObject *code;
- PyFrameObject *frame;
- PyThreadState *tstate;
-
- empty_string = PyString_FromString ("");
- if (!empty_string)
- return NULL;
-
- null_tuple = PyTuple_New (0);
- if (!null_tuple)
- {
- Py_DECREF (empty_string);
- return NULL;
- }
-
- code = PyCode_New (0, /* argcount */
- 0, /* nlocals */
- 0, /* stacksize */
- 0, /* flags */
- empty_string, /* code */
- null_tuple, /* consts */
- null_tuple, /* names */
- null_tuple, /* varnames */
-#if PYTHON_API_VERSION >= 1010
- null_tuple, /* freevars */
- null_tuple, /* cellvars */
-#endif
- empty_string, /* filename */
- empty_string, /* name */
- 1, /* firstlineno */
- empty_string /* lnotab */
- );
-
- Py_DECREF (empty_string);
- Py_DECREF (null_tuple);
-
- if (!code)
- return NULL;
-
- globals = PyDict_New ();
- if (!globals)
- {
- Py_DECREF (code);
- return NULL;
- }
-
- tstate = PyThreadState_GET ();
-
- frame = PyFrame_New (tstate, code, globals, NULL);
-
- Py_DECREF (globals);
- Py_DECREF (code);
-
- if (!frame)
- return NULL;
-
- tstate->frame = frame;
- make_cleanup (py_restore_tstate, frame->f_back);
- return (PyObject *) frame;
-}
-#endif
-