mirror of
https://github.com/python/cpython.git
synced 2025-10-20 00:13:47 +00:00
gh-134411: assert PyLong_FromLong(x) != NULL
when x
is known to be small (#134415)
Since `PyLong_From Long(PY_MONITORING_DEBUGGER_ID)` falls to `small_int` case and can't return `NULL`. Added `assert`s for extra confidence. https://github.com/python/cpython/issues/134411#issuecomment-2897653868
This commit is contained in:
parent
1e672935b4
commit
cf19b6435d
1 changed files with 4 additions and 0 deletions
|
@ -2558,18 +2558,22 @@ PyObject *_Py_CreateMonitoringObject(void)
|
|||
err = PyObject_SetAttrString(events, "NO_EVENTS", _PyLong_GetZero());
|
||||
if (err) goto error;
|
||||
PyObject *val = PyLong_FromLong(PY_MONITORING_DEBUGGER_ID);
|
||||
assert(val != NULL); /* Can't return NULL because the int is small. */
|
||||
err = PyObject_SetAttrString(mod, "DEBUGGER_ID", val);
|
||||
Py_DECREF(val);
|
||||
if (err) goto error;
|
||||
val = PyLong_FromLong(PY_MONITORING_COVERAGE_ID);
|
||||
assert(val != NULL);
|
||||
err = PyObject_SetAttrString(mod, "COVERAGE_ID", val);
|
||||
Py_DECREF(val);
|
||||
if (err) goto error;
|
||||
val = PyLong_FromLong(PY_MONITORING_PROFILER_ID);
|
||||
assert(val != NULL);
|
||||
err = PyObject_SetAttrString(mod, "PROFILER_ID", val);
|
||||
Py_DECREF(val);
|
||||
if (err) goto error;
|
||||
val = PyLong_FromLong(PY_MONITORING_OPTIMIZER_ID);
|
||||
assert(val != NULL);
|
||||
err = PyObject_SetAttrString(mod, "OPTIMIZER_ID", val);
|
||||
Py_DECREF(val);
|
||||
if (err) goto error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue