Skip to content

Commit

Permalink
pythongh-122081: fixed crash in decimal.IEEEContext() (python#122082)
Browse files Browse the repository at this point in the history
* pythongh-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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]>
  • Loading branch information
3 people authored Aug 19, 2024
1 parent be257c5 commit b9e10d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a crash in the :func:`!decimal.IEEEContext` optional function
available via the ``EXTRA_FUNCTIONALITY`` configuration flag.
4 changes: 2 additions & 2 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ init_extended_context(PyObject *v)
#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;
Expand All @@ -1536,7 +1536,7 @@ ieee_context(PyObject *dummy UNUSED, PyObject *v)
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;
Expand Down

0 comments on commit b9e10d1

Please sign in to comment.