8000 gh-124513: Check args in framelocalsproxy_new() by vstinner · Pull Request #124515 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-124513: Check args in framelocalsproxy_new() #124515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
reject also keyword arguments
  • Loading branch information
vstinner committed Sep 25, 2024
commit 467b9cbf8907d6036f7c51779d67fdae76a4b6d3
2 changes: 2 additions & 0 deletions Lib/test/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ def make_frame():
FrameLocalsProxy() # no arguments
with self.assertRaises(TypeError):
FrameLocalsProxy(123) # wrong type
with self.assertRaises(TypeError):
FrameLocalsProxy(frame=sys._getframe()) # no keyword arguments


class FrameLocalsProxyMappingTests(mapping_tests.TestHashMappingProtocol):
Expand Down
6 changes: 6 additions & 0 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ framelocalsproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
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;
Expand Down
Loading
0