Author: Aaron Tubbs <[email protected]>
Branch:
Changeset: r82039:3280ef85d9b7
Date: 2016-02-01 15:44 -0800
http://bitbucket.org/pypy/pypy/changeset/3280ef85d9b7/
Log: Adding support for f_locals to frameobject in CPyExt.
diff --git a/pypy/module/cpyext/frameobject.py
b/pypy/module/cpyext/frameobject.py
--- a/pypy/module/cpyext/frameobject.py
+++ b/pypy/module/cpyext/frameobject.py
@@ -17,6 +17,7 @@
PyFrameObjectFields = (PyObjectFields +
(("f_code", PyCodeObject),
("f_globals", PyObject),
+ ("f_locals", PyObject),
("f_lineno", rffi.INT),
))
cpython_struct("PyFrameObject", PyFrameObjectFields, PyFrameObjectStruct)
@@ -35,6 +36,7 @@
py_frame = rffi.cast(PyFrameObject, py_obj)
py_frame.c_f_code = rffi.cast(PyCodeObject, make_ref(space, frame.pycode))
py_frame.c_f_globals = make_ref(space, frame.get_w_globals())
+ py_frame.c_f_locals = make_ref(space, frame.get_w_locals())
rffi.setintfield(py_frame, 'c_f_lineno', frame.getorcreatedebug().f_lineno)
@cpython_api([PyObject], lltype.Void, external=False)
@@ -43,6 +45,7 @@
py_code = rffi.cast(PyObject, py_frame.c_f_code)
Py_DecRef(space, py_code)
Py_DecRef(space, py_frame.c_f_globals)
+ Py_DecRef(space, py_frame.c_f_locals)
from pypy.module.cpyext.object import PyObject_dealloc
PyObject_dealloc(space, py_obj)
@@ -72,6 +75,7 @@
space.interp_w(PyCode, w_code) # sanity check
py_frame.c_f_code = rffi.cast(PyCodeObject, make_ref(space, w_code))
py_frame.c_f_globals = make_ref(space, w_globals)
+ py_frame.c_f_locals = make_ref(space, w_locals)
return py_frame
@cpython_api([PyFrameObject], rffi.INT_real, error=-1)
diff --git a/pypy/module/cpyext/include/frameobject.h
b/pypy/module/cpyext/include/frameobject.h
--- a/pypy/module/cpyext/include/frameobject.h
+++ b/pypy/module/cpyext/include/frameobject.h
@@ -8,6 +8,7 @@
PyObject_HEAD
PyCodeObject *f_code;
PyObject *f_globals;
+ PyObject *f_locals;
int f_lineno;
} PyFrameObject;
diff --git a/pypy/module/cpyext/test/test_frameobject.py
b/pypy/module/cpyext/test/test_frameobject.py
--- a/pypy/module/cpyext/test/test_frameobject.py
+++ b/pypy/module/cpyext/test/test_frameobject.py
@@ -9,6 +9,7 @@
PyObject *py_srcfile = PyString_FromString("filename");
PyObject *py_funcname = PyString_FromString("funcname");
PyObject *py_globals = PyDict_New();
+ PyObject *py_locals = PyDict_New();
PyObject *empty_string = PyString_FromString("");
PyObject *empty_tuple = PyTuple_New(0);
PyCodeObject *py_code;
@@ -39,7 +40,7 @@
PyThreadState_Get(), /*PyThreadState *tstate,*/
py_code, /*PyCodeObject *code,*/
py_globals, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
+ py_locals /*PyObject *locals*/
);
if (!py_frame) goto bad;
py_frame->f_lineno = 48; /* Does not work with CPython */
@@ -51,6 +52,7 @@
Py_XDECREF(empty_string);
Py_XDECREF(empty_tuple);
Py_XDECREF(py_globals);
+ Py_XDECREF(py_locals);
Py_XDECREF(py_code);
Py_XDECREF(py_frame);
return NULL;
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit