summaryrefslogtreecommitdiff
path: root/Modules/_decimal
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2014-04-29 18:24:50 +0200
committerStefan Krah <skrah@bytereef.org>2014-04-29 18:24:50 +0200
commitddd20ae65c905ea693fbcf618fd2b2cf95b9ae8a (patch)
tree49d6633a4e73b720579a54a9e4a0dfb2ae7239d1 /Modules/_decimal
parent9c5cdbac15917d706b3539a1728c701c7559854a (diff)
downloadcpython-ddd20ae65c905ea693fbcf618fd2b2cf95b9ae8a.tar.gz
Issue #21374: Fix pickling of DecimalTuple.
Diffstat (limited to 'Modules/_decimal')
-rw-r--r--Modules/_decimal/_decimal.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index ea5253efb6..8be9be6489 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -3542,7 +3542,7 @@ PyDec_Round(PyObject *dec, PyObject *args)
}
}
-static PyObject *DecimalTuple = NULL;
+static PyTypeObject *DecimalTuple = NULL;
/* Return the DecimalTuple representation of a PyDecObject. */
static PyObject *
PyDec_AsTuple(PyObject *dec, PyObject *dummy UNUSED)
@@ -3625,7 +3625,7 @@ PyDec_AsTuple(PyObject *dec, PyObject *dummy UNUSED)
}
}
- result = PyObject_CallFunctionObjArgs(DecimalTuple,
+ result = PyObject_CallFunctionObjArgs((PyObject *)DecimalTuple,
sign, coeff, expt, NULL);
out:
@@ -5562,9 +5562,14 @@ PyInit__decimal(void)
/* DecimalTuple */
ASSIGN_PTR(collections, PyImport_ImportModule("collections"));
- ASSIGN_PTR(DecimalTuple, PyObject_CallMethod(collections,
+ ASSIGN_PTR(DecimalTuple, (PyTypeObject *)PyObject_CallMethod(collections,
"namedtuple", "(ss)", "DecimalTuple",
"sign digits exponent"));
+
+ ASSIGN_PTR(obj, PyUnicode_FromString("decimal"));
+ CHECK_INT(PyDict_SetItemString(DecimalTuple->tp_dict, "__module__", obj));
+ Py_CLEAR(obj);
+
/* MutableMapping */
ASSIGN_PTR(MutableMapping, PyObject_GetAttrString(collections,
"MutableMapping"));
@@ -5591,7 +5596,7 @@ PyInit__decimal(void)
CHECK_INT(PyModule_AddObject(m, "Context",
(PyObject *)&PyDecContext_Type));
Py_INCREF(DecimalTuple);
- CHECK_INT(PyModule_AddObject(m, "DecimalTuple", DecimalTuple));
+ CHECK_INT(PyModule_AddObject(m, "DecimalTuple", (PyObject *)DecimalTuple));
/* Create top level exception */