@@ -2163,13 +2163,17 @@ dec_from_long(PyTypeObject *type, const PyObject *v, |
|
|
2163 |
2163 |
/* Return a new PyDecObject from a PyLongObject. Use the context for |
2164 |
2164 |
conversion. */ |
2165 |
2165 |
static PyObject * |
2166 |
|
-PyDecType_FromLong(PyTypeObject *type, const PyObject *pylong, |
2167 |
|
-PyObject *context) |
|
2166 |
+PyDecType_FromLong(PyTypeObject *type, const PyObject *v, PyObject *context) |
2168 |
2167 |
{ |
2169 |
2168 |
PyObject *dec; |
2170 |
2169 |
uint32_t status = 0; |
2171 |
2170 |
|
2172 |
|
-dec = dec_from_long(type, pylong, CTX(context), &status); |
|
2171 |
+if (!PyLong_Check(v)) { |
|
2172 |
+PyErr_SetString(PyExc_TypeError, "argument must be an integer"); |
|
2173 |
+return NULL; |
|
2174 |
+ } |
|
2175 |
+ |
|
2176 |
+dec = dec_from_long(type, v, CTX(context), &status); |
2173 |
2177 |
if (dec == NULL) { |
2174 |
2178 |
return NULL; |
2175 |
2179 |
} |
@@ -2185,15 +2189,20 @@ PyDecType_FromLong(PyTypeObject *type, const PyObject *pylong, |
|
|
2185 |
2189 |
/* Return a new PyDecObject from a PyLongObject. Use a maximum context |
2186 |
2190 |
for conversion. If the conversion is not exact, set InvalidOperation. */ |
2187 |
2191 |
static PyObject * |
2188 |
|
-PyDecType_FromLongExact(PyTypeObject *type, const PyObject *pylong, |
|
2192 |
+PyDecType_FromLongExact(PyTypeObject *type, const PyObject *v, |
2189 |
2193 |
PyObject *context) |
2190 |
2194 |
{ |
2191 |
2195 |
PyObject *dec; |
2192 |
2196 |
uint32_t status = 0; |
2193 |
2197 |
mpd_context_t maxctx; |
2194 |
2198 |
|
|
2199 |
+if (!PyLong_Check(v)) { |
|
2200 |
+PyErr_SetString(PyExc_TypeError, "argument must be an integer"); |
|
2201 |
+return NULL; |
|
2202 |
+ } |
|
2203 |
+ |
2195 |
2204 |
mpd_maxcontext(&maxctx); |
2196 |
|
-dec = dec_from_long(type, pylong, &maxctx, &status); |
|
2205 |
+dec = dec_from_long(type, v, &maxctx, &status); |
2197 |
2206 |
if (dec == NULL) { |
2198 |
2207 |
return NULL; |
2199 |
2208 |
} |