* gh-122081: fixed crash in decimal.IEEEContext()
Now
$ ./configure CFLAGS=-DEXTRA_FUNCTIONALITY -q && make -s && \
./python -m test test_decimal
- PASS
* Apply suggestions from code review
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* Update Misc/NEWS.d/next/Library/2024-07-21-10-45-24.gh-issue-122081.dNrYMq.rst
* Apply suggestions from code review
---------
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
--- /dev/null
+Fix a crash in the :func:`!decimal.IEEEContext` optional function
+available via the ``EXTRA_FUNCTIONALITY`` configuration flag.
#ifdef EXTRA_FUNCTIONALITY
/* Factory function for creating IEEE interchange format contexts */
static PyObject *
-ieee_context(PyObject *dummy UNUSED, PyObject *v)
+ieee_context(PyObject *module, PyObject *v)
{
PyObject *context;
mpd_ssize_t bits;
goto error;
}
- decimal_state *state = get_module_state_by_def(Py_TYPE(v));
+ decimal_state *state = get_module_state(module);
context = PyObject_CallObject((PyObject *)state->PyDecContext_Type, NULL);
if (context == NULL) {
return NULL;