bpo-34301: Add _PyInterpreterState_Get() helper function (GH-8592)

sys_setcheckinterval() now uses a local variable to parse arguments,
before writing into interp->check_interval.
This commit is contained in:
Victor Stinner 2018-08-03 15:33:52 +02:00 committed by GitHub
parent 2ebd3813af
commit caba55b3b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 107 additions and 93 deletions

View file

@ -3,6 +3,7 @@
#include "Python.h"
#include "code.h"
#include "structmember.h"
#include "internal/pystate.h"
/* Holder for co_extra information */
typedef struct {
@ -428,7 +429,7 @@ static void
code_dealloc(PyCodeObject *co)
{
if (co->co_extra != NULL) {
PyInterpreterState *interp = PyThreadState_Get()->interp;
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
_PyCodeObjectExtra *co_extra = co->co_extra;
for (Py_ssize_t i = 0; i < co_extra->ce_size; i++) {
@ -871,7 +872,7 @@ _PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
int
_PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
{
PyInterpreterState *interp = PyThreadState_Get()->interp;
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
if (!PyCode_Check(code) || index < 0 ||
index >= interp->co_extra_user_count) {