@@ -1571,7 +1571,6 @@ init_extended_context(PyObject *v)
15711571/*[clinic input]
15721572_decimal.IEEEContext
15731573
1574- self as module: self
15751574 bits: Py_ssize_t
15761575 /
15771576
@@ -1582,8 +1581,8 @@ IEEE_CONTEXT_MAX_BITS.
15821581[clinic start generated code]*/
15831582
15841583static PyObject *
1585- _decimal_Decimal_IEEEContext_impl (PyObject * module , Py_ssize_t bits )
1586- /*[clinic end generated code: output=042b8664fd2830f7 input=32882ba8f6a2d230 ]*/
1584+ _decimal_IEEEContext_impl (PyObject * module , Py_ssize_t bits )
1585+ /*[clinic end generated code: output=19a35f320fe19789 input=5cff864d899eb2d7 ]*/
15871586{
15881587 PyObject * context ;
15891588 mpd_context_t ctx ;
@@ -1928,10 +1927,10 @@ Get the current default context.
19281927[clinic start generated code]*/
19291928
19301929static PyObject *
1931- _decimal_Decimal_getcontext_impl (PyObject * self )
1932- /*[clinic end generated code: output=7efa232c0136dbba input=2d641118d62b25d4 ]*/
1930+ _decimal_getcontext_impl (PyObject * module )
1931+ /*[clinic end generated code: output=5982062c4d39e3dd input=7ac316fe42a1b6f5 ]*/
19331932{
1934- return PyDec_GetCurrentContext (self );
1933+ return PyDec_GetCurrentContext (module );
19351934}
19361935
19371936/*[clinic input]
@@ -1944,10 +1943,10 @@ Set a new default context.
19441943[clinic start generated code]*/
19451944
19461945static PyObject *
1947- _decimal_Decimal_setcontext (PyObject * self , PyObject * context )
1948- /*[clinic end generated code: output=20e7a377da25e02f input=4a5f0e2f660ee0e5 ]*/
1946+ _decimal_setcontext (PyObject * module , PyObject * context )
1947+ /*[clinic end generated code: output=8065f870be2852ce input=b57d7ee786b022a6 ]*/
19491948{
1950- return PyDec_SetCurrentContext (self , context );
1949+ return PyDec_SetCurrentContext (module , context );
19511950}
19521951
19531952/* Context manager object for the 'with' statement. The manager
@@ -1979,12 +1978,11 @@ default context is used.
19791978[clinic start generated code]*/
19801979
19811980static PyObject *
1982- _decimal_Decimal_localcontext_impl (PyObject * m , PyObject * local ,
1983- PyObject * prec , PyObject * rounding ,
1984- PyObject * Emin , PyObject * Emax ,
1985- PyObject * capitals , PyObject * clamp ,
1986- PyObject * flags , PyObject * traps )
1987- /*[clinic end generated code: output=21cc25fbed642f2f input=77906e599937a9b5]*/
1981+ _decimal_localcontext_impl (PyObject * m , PyObject * local , PyObject * prec ,
1982+ PyObject * rounding , PyObject * Emin ,
1983+ PyObject * Emax , PyObject * capitals ,
1984+ PyObject * clamp , PyObject * flags , PyObject * traps )
1985+ /*[clinic end generated code: output=f97568232f55f5c2 input=af5c0c34dcf94cfc]*/
19881986{
19891987 PyObject * global ;
19901988
@@ -3624,7 +3622,7 @@ pydec_format(PyObject *dec, PyObject *context, PyObject *fmt, decimal_state *sta
36243622_decimal.Decimal.__format__
36253623
36263624 self as dec: self
3627- format_spec as fmtarg: object
3625+ format_spec as fmtarg: unicode
36283626 override: object = NULL
36293627 /
36303628
@@ -3634,7 +3632,7 @@ Formats the Decimal according to fmtarg.
36343632static PyObject *
36353633_decimal_Decimal___format___impl (PyObject * dec , PyObject * fmtarg ,
36363634 PyObject * override )
3637- /*[clinic end generated code: output=4b3640b7f0c8b6a5 input=399a574acc9f0d08 ]*/
3635+ /*[clinic end generated code: output=4b3640b7f0c8b6a5 input=41a600cc5135e705 ]*/
36383636{
36393637 PyObject * result = NULL ;
36403638 PyObject * dot = NULL ;
@@ -3649,34 +3647,27 @@ _decimal_Decimal___format___impl(PyObject *dec, PyObject *fmtarg,
36493647 Py_ssize_t size ;
36503648 decimal_state * state = get_module_state_by_def (Py_TYPE (dec ));
36513649 CURRENT_CONTEXT (state , context );
3652- if (PyUnicode_Check (fmtarg )) {
3653- fmt = (char * )PyUnicode_AsUTF8AndSize (fmtarg , & size );
3654- if (fmt == NULL ) {
3655- return NULL ;
3656- }
3650+ fmt = (char * )PyUnicode_AsUTF8AndSize (fmtarg , & size );
3651+ if (fmt == NULL ) {
3652+ return NULL ;
3653+ }
36573654
3658- if (size > 0 && fmt [size - 1 ] == 'N' ) {
3659- if (PyErr_WarnEx (PyExc_DeprecationWarning ,
3660- "Format specifier 'N' is deprecated" , 1 ) < 0 ) {
3661- return NULL ;
3662- }
3655+ if (size > 0 && fmt [size - 1 ] == 'N' ) {
3656+ if (PyErr_WarnEx (PyExc_DeprecationWarning ,
3657+ "Format specifier 'N' is deprecated" , 1 ) < 0 ) {
3658+ return NULL ;
36633659 }
3660+ }
36643661
3665- if (size > 0 && fmt [0 ] == '\0' ) {
3666- /* NUL fill character: must be replaced with a valid UTF-8 char
3667- before calling mpd_parse_fmt_str(). */
3668- replace_fillchar = 1 ;
3669- fmt = dec_strdup (fmt , size );
3670- if (fmt == NULL ) {
3671- return NULL ;
3672- }
3673- fmt [0 ] = '_' ;
3662+ if (size > 0 && fmt [0 ] == '\0' ) {
3663+ /* NUL fill character: must be replaced with a valid UTF-8 char
3664+ before calling mpd_parse_fmt_str(). */
3665+ replace_fillchar = 1 ;
3666+ fmt = dec_strdup (fmt , size );
3667+ if (fmt == NULL ) {
3668+ return NULL ;
36743669 }
3675- }
3676- else {
3677- PyErr_SetString (PyExc_TypeError ,
3678- "format arg must be str" );
3679- return NULL ;
3670+ fmt [0 ] = '_' ;
36803671 }
36813672
36823673 if (!mpd_parse_fmt_str (& spec , fmt , CtxCaps (context ))) {
@@ -6194,10 +6185,10 @@ static PyType_Spec context_spec = {
61946185
61956186static PyMethodDef _decimal_methods [] =
61966187{
6197- _DECIMAL_DECIMAL_GETCONTEXT_METHODDEF
6198- _DECIMAL_DECIMAL_SETCONTEXT_METHODDEF
6199- _DECIMAL_DECIMAL_LOCALCONTEXT_METHODDEF
6200- _DECIMAL_DECIMAL_IEEECONTEXT_METHODDEF
6188+ _DECIMAL_GETCONTEXT_METHODDEF
6189+ _DECIMAL_SETCONTEXT_METHODDEF
6190+ _DECIMAL_LOCALCONTEXT_METHODDEF
6191+ _DECIMAL_IEEECONTEXT_METHODDEF
62016192 { NULL , NULL , 1 , NULL }
62026193};
62036194
0 commit comments