]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-122081: fixed crash in decimal.IEEEContext() (GH-122082) (#123136)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 19 Aug 2024 08:44:11 +0000 (10:44 +0200)
committerGitHub <noreply@github.com>
Mon, 19 Aug 2024 08:44:11 +0000 (14:14 +0530)
gh-122081: fixed crash in decimal.IEEEContext() (GH-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

* Update Misc/NEWS.d/next/Library/2024-07-21-10-45-24.gh-issue-122081.dNrYMq.rst

* Apply suggestions from code review

---------

(cherry picked from commit b9e10d1a0fc4d8428d4b36eb127570a832c26b6f)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Misc/NEWS.d/next/Library/2024-07-21-10-45-24.gh-issue-122081.dNrYMq.rst [new file with mode: 0644]
Modules/_decimal/_decimal.c

diff --git a/Misc/NEWS.d/next/Library/2024-07-21-10-45-24.gh-issue-122081.dNrYMq.rst b/Misc/NEWS.d/next/Library/2024-07-21-10-45-24.gh-issue-122081.dNrYMq.rst
new file mode 100644 (file)
index 0000000..4c988b1
--- /dev/null
@@ -0,0 +1,2 @@
+Fix a crash in the :func:`!decimal.IEEEContext` optional function
+available via the ``EXTRA_FUNCTIONALITY`` configuration flag.
index 2daa24c823a54287b5b5b23a4307a64765072e14..81e548f3b48245830babd95f0f94a1b004becb7a 100644 (file)
@@ -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;
@@ -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;