https://github.com/python/cpython/commit/a69472e242e768545d734cf336bdbbff6f749f3f commit: a69472e242e768545d734cf336bdbbff6f749f3f branch: 3.14 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: sobolevn <m...@sobolevn.me> date: 2025-07-21T09:23:33Z summary:
[3.14] gh-134411: assert `PyLong_FromLong(x) != NULL` when `x` is known to be small (GH-134415) (#136910) gh-134411: assert `PyLong_FromLong(x) != NULL` when `x` is known to be small (GH-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 (cherry picked from commit cf19b6435d02dd7be11b84a44f4a8a9f1a935b15) Co-authored-by: Sergey Muraviov <smu...@mail.ru> files: M Python/instrumentation.c diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 13bdd041becd69..5b26a078085806 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -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; _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: arch...@mail-archive.com