[Python-checkins] r81997 - python/branches/py3k-cdecimal/Modules/cdecimal/cdecimal.c
stefan.krah
python-checkins at python.org
Tue Jun 15 15:11:01 CEST 2010
Author: stefan.krah
Date: Tue Jun 15 15:11:01 2010
New Revision: 81997
Log:
1) context.setflags() and context.settraps() incorrectly returned -1.
2) Remove superfluous casts.
Modified:
python/branches/py3k-cdecimal/Modules/cdecimal/cdecimal.c
Modified: python/branches/py3k-cdecimal/Modules/cdecimal/cdecimal.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/cdecimal/cdecimal.c (original)
+++ python/branches/py3k-cdecimal/Modules/cdecimal/cdecimal.c Tue Jun 15 15:11:01 2010
@@ -211,7 +211,7 @@
ssize_t n, j;
if (!PyList_Check(list)) {
- PyErr_Format(PyExc_TypeError, "argument must be a signal list");
+ PyErr_SetString(PyExc_TypeError, "argument must be a signal list");
return UINT32_MAX;
}
@@ -274,7 +274,7 @@
overflow = 0;
x = PyLong_AsLongAndOverflow(v, &overflow);
if (overflow != 0 || x < 0 || x > (long)MPD_Max_status) {
- PyErr_Format(PyExc_ValueError, "invalid flag value");
+ PyErr_SetString(PyExc_ValueError, "invalid flag value");
return UINT32_MAX;
}
@@ -803,7 +803,7 @@
}
static PyObject *
-context_unsafe_setprec(PyObject *self, PyObject *value, void *closure UNUSED)
+context_unsafe_setprec(PyObject *self, PyObject *value)
{
mpd_context_t *ctx = CtxAddr(self);
@@ -815,7 +815,7 @@
}
static PyObject *
-context_unsafe_setemin(PyObject *self, PyObject *value, void *closure UNUSED)
+context_unsafe_setemin(PyObject *self, PyObject *value)
{
mpd_context_t *ctx = CtxAddr(self);
@@ -827,7 +827,7 @@
}
static PyObject *
-context_unsafe_setemax(PyObject *self, PyObject *value, void *closure UNUSED)
+context_unsafe_setemax(PyObject *self, PyObject *value)
{
mpd_context_t *ctx = CtxAddr(self);
@@ -1386,6 +1386,24 @@
);
}
+static PyObject *
+PyDec_SetStatusFromList(PyObject *self, PyObject *value)
+{
+ if (context_setstatus_list(self, value) < 0) {
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+PyDec_SetTrapsFromList(PyObject *self, PyObject *value)
+{
+ if (context_settraps_list(self, value) < 0) {
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
static PyGetSetDef context_getsets [] =
{
@@ -4723,15 +4741,15 @@
{ "shift", _DecCtx_mpd_qshift, METH_VARARGS, doc_ctx_shift },
/* Set context values */
- { "setflags", (PyCFunction)context_setstatus_list, METH_O, doc_ctx_setflags },
- { "settraps", (PyCFunction)context_settraps_list, METH_O, doc_ctx_settraps },
+ { "setflags", PyDec_SetStatusFromList, METH_O, doc_ctx_setflags },
+ { "settraps", PyDec_SetTrapsFromList, METH_O, doc_ctx_settraps },
{ "clear_flags", context_clear_flags, METH_NOARGS, doc_ctx_clear_flags },
{ "clear_traps", context_clear_traps, METH_NOARGS, doc_ctx_clear_traps },
/* Unsafe set functions with no range checks */
- { "unsafe_setprec", (PyCFunction)context_unsafe_setprec, METH_O, NULL },
- { "unsafe_setemin", (PyCFunction)context_unsafe_setemin, METH_O, NULL },
- { "unsafe_setemax", (PyCFunction)context_unsafe_setemax, METH_O, NULL },
+ { "unsafe_setprec", context_unsafe_setprec, METH_O, NULL },
+ { "unsafe_setemin", context_unsafe_setemin, METH_O, NULL },
+ { "unsafe_setemax", context_unsafe_setemax, METH_O, NULL },
/* Miscellaneous */
{ "__copy__", (PyCFunction)context_copy, METH_NOARGS, NULL },
More information about the Python-checkins
mailing list