Skip to content

Commit 467b9cb

Browse files
committed
reject also keyword arguments
1 parent 2dd64c9 commit 467b9cb

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Lib/test/test_frame.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ def make_frame():
512512
FrameLocalsProxy() # no arguments
513513
with self.assertRaises(TypeError):
514514
FrameLocalsProxy(123) # wrong type
515+
with self.assertRaises(TypeError):
516+
FrameLocalsProxy(frame=sys._getframe()) # no keyword arguments
515517

516518

517519
class FrameLocalsProxyMappingTests(mapping_tests.TestHashMappingProtocol):

Objects/frameobject.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ framelocalsproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
324324
}
325325
PyFrameObject *frame = (PyFrameObject*)item;
326326

327+
if (kwds != NULL && PyDict_Size(kwds) != 0) {
328+
PyErr_SetString(PyExc_TypeError,
329+
"FrameLocalsProxy takes no keyword arguments");
330+
return 0;
331+
}
332+
327333
PyFrameLocalsProxyObject *self = (PyFrameLocalsProxyObject *)type->tp_alloc(type, 0);
328334
if (self == NULL) {
329335
return NULL;

0 commit comments

Comments
 (0)