-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-1635741: Clean sysdict and builtins of interpreter #21605
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -286,8 +286,8 @@ PyInterpreterState_Clear(PyInterpreterState *interp) | |||||
} | ||||||
HEAD_UNLOCK(runtime); | ||||||
|
||||||
PyDict_Clear(interp->sysdict); | ||||||
PyDict_Clear(interp->builtins); | ||||||
PyObject *sysdict = interp->sysdict; | ||||||
PyObject *builtins = interp->builtins; | ||||||
|
||||||
Py_CLEAR(interp->audit_hooks); | ||||||
|
||||||
|
@@ -311,6 +311,13 @@ PyInterpreterState_Clear(PyInterpreterState *interp) | |||||
if (_PyRuntimeState_GetFinalizing(runtime) == NULL) { | ||||||
_PyWarnings_Fini(interp); | ||||||
} | ||||||
|
||||||
/* We don't clear sysdict and builtins until the end of this function. | ||||||
Because clearing other attributes can execute arbitrary Python code | ||||||
which reuqires sysdict and builtins. */ | ||||||
PyDict_Clear(sysdict); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the point of adding two local variables, why not accessing directly the structure member?
Suggested change
Same remark on folowing line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interp->sysdict and interp->builtins will be cleared before this line. https://github.com/python/cpython/blob/master/Python/pystate.c#L297-L298 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aha, I didn't notice. In this case, I suggest to move Py_CLEAR(interp->sysdict) and Py_CLEAR(interp->builtins) at the end. Something like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated. And I delete the description info. |
||||||
PyDict_Clear(builtins); | ||||||
|
||||||
// XXX Once we have one allocator per interpreter (i.e. | ||||||
// per-interpreter GC) we must ensure that all of the interpreter's | ||||||
// objects have been cleaned up at the point. | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.