[Python-checkins] r81976 - python/branches/py3k-cdecimal/Modules/cdecimal/cdecimal.c
stefan.krah
python-checkins at python.org
Mon Jun 14 11:05:26 CEST 2010
Author: stefan.krah
Date: Mon Jun 14 11:05:25 2010
New Revision: 81976
Log:
1) In the DefaultContext, the InvalidOperation signal was triggered only
by the InvalidOperation condition rather than by all conditions of
the InvalidOperation spectrum. This bug was introduced by the recent
DefaultContext compatibility changes.
2) Change the handling of invalid parameters in context initialization:
a) It is of limited value to set InvalidContext in the new context.
b) It is not wise to set InvalidContext in the current context either:
setcontext(Context(<invalid values>)) must fail even if
InvalidOperation is disabled in the current context.
3) Must use XDECREF in PyDec_SetCurrentContext().
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 Mon Jun 14 11:05:25 2010
@@ -1172,7 +1172,7 @@
static mpd_context_t dflt_ctx = {
28, DEC_DFLT_EMAX, DEC_DFLT_EMIN,
- MPD_Invalid_operation|MPD_Division_by_zero|MPD_Overflow,
+ MPD_IEEE_Invalid_operation|MPD_Division_by_zero|MPD_Overflow,
0, 0, MPD_ROUND_HALF_EVEN, 0, 1
};
@@ -1212,13 +1212,12 @@
!mpd_qsetstatus(ctx, t.status) ||
!mpd_qsetclamp(ctx, t.clamp) ||
!mpd_qsetcr(ctx, t.allcr)) {
- if (dec_addstatus(ctx, MPD_Invalid_context)) {
- return -1;
- }
+ PyErr_SetString(PyExc_ValueError, "invalid context");
+ return -1;
}
if (capitals != 0 && capitals != 1) {
- PyErr_SetString(PyExc_ValueError, "invalid value for capitals");
+ PyErr_SetString(PyExc_ValueError, "invalid context");
return -1;
}
CtxCaps(self) = capitals;
@@ -1481,7 +1480,7 @@
Py_INCREF(v);
}
- Py_DECREF(module_context);
+ Py_XDECREF(module_context);
module_context = v;
module_context_set = 1;
Py_RETURN_NONE;
More information about the Python-checkins
mailing list