Skip to content

Commit f9c7ec5

Browse files
committed
gh-117174: Rename <string> to <__interactive_string__> for interactive code objects
Using <string> leads to confusion when linecache it's populated with <string> entries as the inspect module heavily relies on it. An example: ./python -c "import inspect;x=eval('lambda x: x');print(inspect.getsource(x))" The code above should trigger an exception because we should not be able to get the source of x (it's dynamically generated) but if we use <string> as name for interactive code it will return gives the full string.
1 parent 1dc1521 commit f9c7ec5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Modules/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pymain_run_command(wchar_t *command)
249249

250250
PyCompilerFlags cf = _PyCompilerFlags_INIT;
251251
cf.cf_flags |= PyCF_IGNORE_COOKIE;
252-
ret = _PyRun_SimpleStringFlagsWithName(PyBytes_AsString(bytes), "<string>", &cf);
252+
ret = _PyRun_SimpleStringFlagsWithName(PyBytes_AsString(bytes), "<__interactive_string__>", &cf);
253253
Py_DECREF(bytes);
254254
return (ret != 0);
255255

0 commit comments

Comments
 (0)