@@ -2163,13 +2163,17 @@ dec_from_long(PyTypeObject *type, const PyObject *v,
21632163/* Return a new PyDecObject from a PyLongObject. Use the context for
21642164 conversion. */
21652165static PyObject *
2166- PyDecType_FromLong (PyTypeObject * type , const PyObject * pylong ,
2167- PyObject * context )
2166+ PyDecType_FromLong (PyTypeObject * type , const PyObject * v , PyObject * context )
21682167{
21692168 PyObject * dec ;
21702169 uint32_t status = 0 ;
21712170
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 );
21732177 if (dec == NULL ) {
21742178 return NULL ;
21752179 }
@@ -2185,15 +2189,20 @@ PyDecType_FromLong(PyTypeObject *type, const PyObject *pylong,
21852189/* Return a new PyDecObject from a PyLongObject. Use a maximum context
21862190 for conversion. If the conversion is not exact, set InvalidOperation. */
21872191static PyObject *
2188- PyDecType_FromLongExact (PyTypeObject * type , const PyObject * pylong ,
2192+ PyDecType_FromLongExact (PyTypeObject * type , const PyObject * v ,
21892193 PyObject * context )
21902194{
21912195 PyObject * dec ;
21922196 uint32_t status = 0 ;
21932197 mpd_context_t maxctx ;
21942198
2199+ if (!PyLong_Check (v )) {
2200+ PyErr_SetString (PyExc_TypeError , "argument must be an integer" );
2201+ return NULL ;
2202+ }
2203+
21952204 mpd_maxcontext (& maxctx );
2196- dec = dec_from_long (type , pylong , & maxctx , & status );
2205+ dec = dec_from_long (type , v , & maxctx , & status );
21972206 if (dec == NULL ) {
21982207 return NULL ;
21992208 }
0 commit comments