We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f33d835 commit bade862Copy full SHA for bade862
1 file changed
Python/ceval.c
@@ -2857,7 +2857,24 @@ PyEval_GetLocals(void)
2857
return NULL;
2858
}
2859
2860
- PyObject *locals = current_frame->f_locals;
+ assert(PyDict_Check(current_frame->f_locals));
2861
+
2862
+ PyObject *locals = PyDict_New();
2863
+ if (locals == NULL) {
2864
+ return NULL;
2865
+ }
2866
2867
+ PyObject *key, *value;
2868
+ Py_ssize_t pos = 0;
2869
+ while (PyDict_Next(current_frame->f_locals, &pos, &key, &value)) {
2870
+ Py_UCS4 first = PyUnicode_ReadChar(key, 0);
2871
+ if (first != '$') {
2872
+ if (PyDict_SetItem(locals, key, value) < 0) {
2873
2874
2875
2876
2877
2878
assert(locals != NULL);
2879
return locals;
2880
0 commit comments