From: Sergey B Kirpichev Date: Thu, 26 Feb 2026 22:02:39 +0000 (+0300) Subject: gh-141510: support frozendict's in the C decimal module (gh-145165) X-Git-Tag: v3.15.0a7~140 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3a381e54fcabb2d8649cbfc2dff9933ee7c4d0b;p=thirdparty%2FPython%2Fcpython.git gh-141510: support frozendict's in the C decimal module (gh-145165) --- diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index b520b062ebc6..fe8c8ce12da0 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -3963,15 +3963,21 @@ class ContextFlags: d.update(c.flags) self.assertEqual(d, c.flags) self.assertEqual(c.flags, d) + self.assertEqual(frozendict(d), c.flags) + self.assertEqual(c.flags, frozendict(d)) d[Inexact] = True self.assertNotEqual(d, c.flags) self.assertNotEqual(c.flags, d) + self.assertNotEqual(frozendict(d), c.flags) + self.assertNotEqual(c.flags, frozendict(d)) # Invalid SignalDict d = {Inexact:False} self.assertNotEqual(d, c.flags) self.assertNotEqual(c.flags, d) + self.assertNotEqual(frozendict(d), c.flags) + self.assertNotEqual(c.flags, frozendict(d)) d = ["xyz"] self.assertNotEqual(d, c.flags) diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index dcea4da8f242..c42757e042e7 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -552,7 +552,7 @@ dict_as_flags(decimal_state *state, PyObject *val) uint32_t flags = 0; int x; - if (!PyDict_Check(val)) { + if (!PyAnyDict_Check(val)) { PyErr_SetString(PyExc_TypeError, "argument must be a signal dict"); return DEC_INVALID_SIGNALS; @@ -802,7 +802,7 @@ signaldict_richcompare(PyObject *v, PyObject *w, int op) if (PyDecSignalDict_Check(state, w)) { res = (SdFlags(v)==SdFlags(w)) ^ (op==Py_NE) ? Py_True : Py_False; } - else if (PyDict_Check(w)) { + else if (PyAnyDict_Check(w)) { uint32_t flags = dict_as_flags(state, w); if (flags & DEC_ERRORS) { if (flags & DEC_INVALID_SIGNALS) {