Skip to content

Commit b9e10d1

Browse files
skirpichevpicnixzkumaraditya303
authored
gh-122081: fixed crash in decimal.IEEEContext() (#122082)
* 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 <[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]>
1 parent be257c5 commit b9e10d1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a crash in the :func:`!decimal.IEEEContext` optional function
2+
available via the ``EXTRA_FUNCTIONALITY`` configuration flag.

Modules/_decimal/_decimal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ init_extended_context(PyObject *v)
15191519
#ifdef EXTRA_FUNCTIONALITY
15201520
/* Factory function for creating IEEE interchange format contexts */
15211521
static PyObject *
1522-
ieee_context(PyObject *dummy UNUSED, PyObject *v)
1522+
ieee_context(PyObject *module, PyObject *v)
15231523
{
15241524
PyObject *context;
15251525
mpd_ssize_t bits;
@@ -1536,7 +1536,7 @@ ieee_context(PyObject *dummy UNUSED, PyObject *v)
15361536
goto error;
15371537
}
15381538

1539-
decimal_state *state = get_module_state_by_def(Py_TYPE(v));
1539+
decimal_state *state = get_module_state(module);
15401540
context = PyObject_CallObject((PyObject *)state->PyDecContext_Type, NULL);
15411541
if (context == NULL) {
15421542
return NULL;

0 commit comments

Comments
 (0)