Skip to content

Commit bade862

Browse files
committed
filter 569XZilmstmps out of locals()
1 parent f33d835 commit bade862

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

Python/ceval.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,24 @@ PyEval_GetLocals(void)
28572857
return NULL;
28582858
}
28592859

2860-
PyObject *locals = current_frame->f_locals;
2860+
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+
return NULL;
2874+
}
2875+
}
2876+
}
2877+
28612878
assert(locals != NULL);
28622879
return locals;
28632880
}

0 commit comments

Comments
 (0)