summaryrefslogtreecommitdiffstats
path: root/Objects/frameobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r--Objects/frameobject.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 9f1c031..f3a66ff 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -310,14 +310,31 @@ framelocalsproxy_dealloc(PyObject *self)
static PyObject *
framelocalsproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
+ if (PyTuple_GET_SIZE(args) != 1) {
+ PyErr_Format(PyExc_TypeError,
+ "FrameLocalsProxy expected 1 argument, got %zd",
+ PyTuple_GET_SIZE(args));
+ return NULL;
+ }
+ PyObject *item = PyTuple_GET_ITEM(args, 0);
+
+ if (!PyFrame_Check(item)) {
+ PyErr_Format(PyExc_TypeError, "expect frame, not %T", item);
+ return NULL;
+ }
+ PyFrameObject *frame = (PyFrameObject*)item;
+
+ if (kwds != NULL && PyDict_Size(kwds) != 0) {
+ PyErr_SetString(PyExc_TypeError,
+ "FrameLocalsProxy takes no keyword arguments");
+ return 0;
+ }
+
PyFrameLocalsProxyObject *self = (PyFrameLocalsProxyObject *)type->tp_alloc(type, 0);
if (self == NULL) {
return NULL;
}
- PyFrameObject *frame = (PyFrameObject*)PyTuple_GET_ITEM(args, 0);
- assert(PyFrame_Check(frame));
-
((PyFrameLocalsProxyObject*)self)->frame = (PyFrameObject*)Py_NewRef(frame);
return (PyObject *)self;