https://github.com/python/cpython/commit/b9e10d1a0fc4d8428d4b36eb127570a832c26b6f
commit: b9e10d1a0fc4d8428d4b36eb127570a832c26b6f
branch: main
author: Sergey B Kirpichev <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2024-08-19T07:51:38Z
summary:

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]>

files:
A Misc/NEWS.d/next/Library/2024-07-21-10-45-24.gh-issue-122081.dNrYMq.rst
M 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
index 00000000000000..4c988b16168047
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-07-21-10-45-24.gh-issue-122081.dNrYMq.rst
@@ -0,0 +1,2 @@
+Fix a crash in the :func:`!decimal.IEEEContext` optional function
+available via the ``EXTRA_FUNCTIONALITY`` configuration flag.
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index 94a2cc2c8e5f8a..15855e2cf1bb32 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -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;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to