Skip to content

Commit 5b69d94

Browse files
committed
remove Modules/_decimal/docstrings.h
1 parent 10fe41b commit 5b69d94

10 files changed

+257
-100
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ struct _Py_global_strings {
602602
STRUCT_FOR_ID(module)
603603
STRUCT_FOR_ID(module_globals)
604604
STRUCT_FOR_ID(modules)
605+
STRUCT_FOR_ID(modulo)
605606
STRUCT_FOR_ID(month)
606607
STRUCT_FOR_ID(mro)
607608
STRUCT_FOR_ID(msg)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile.pre.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3355,7 +3355,7 @@ MODULE_UNICODEDATA_DEPS=$(srcdir)/Modules/unicodedata_db.h $(srcdir)/Modules/uni
33553355
MODULE__CTYPES_DEPS=$(srcdir)/Modules/_ctypes/ctypes.h
33563356
MODULE__CTYPES_TEST_DEPS=$(srcdir)/Modules/_ctypes/_ctypes_test_generated.c.h
33573357
MODULE__CTYPES_MALLOC_CLOSURE=@MODULE__CTYPES_MALLOC_CLOSURE@
3358-
MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@
3358+
MODULE__DECIMAL_DEPS=@LIBMPDEC_INTERNAL@
33593359
MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@
33603360
MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h
33613361
MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h

Modules/_decimal/_decimal.c

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050
#include <ctype.h> // isascii()
5151
#include <stdlib.h>
5252

53-
#include "docstrings.h"
54-
5553
#ifdef EXTRA_FUNCTIONALITY
5654
#define _PY_DEC_ROUND_GUARD MPD_ROUND_GUARD
5755
#else
@@ -1510,32 +1508,37 @@ context_dealloc(PyObject *self)
15101508
Py_DECREF(tp);
15111509
}
15121510

1513-
static int
1514-
context_init(PyObject *self, PyObject *args, PyObject *kwds)
1515-
{
1516-
static char *kwlist[] = {
1517-
"prec", "rounding", "Emin", "Emax", "capitals", "clamp",
1518-
"flags", "traps", NULL
1519-
};
1520-
PyObject *prec = Py_None;
1521-
PyObject *rounding = Py_None;
1522-
PyObject *emin = Py_None;
1523-
PyObject *emax = Py_None;
1524-
PyObject *capitals = Py_None;
1525-
PyObject *clamp = Py_None;
1526-
PyObject *status = Py_None;
1527-
PyObject *traps = Py_None;
1528-
1529-
assert(PyTuple_Check(args));
1530-
1531-
if (!PyArg_ParseTupleAndKeywords(
1532-
args, kwds,
1533-
"|OOOOOOOO", kwlist,
1534-
&prec, &rounding, &emin, &emax, &capitals, &clamp, &status, &traps
1535-
)) {
1536-
return -1;
1537-
}
1511+
/*[clinic input]
1512+
_decimal.Context.__init__ as context_init
1513+
1514+
prec: object = None
1515+
rounding: object = None
1516+
Emin as emin: object = None
1517+
Emax as emax: object = None
1518+
capitals: object = None
1519+
clamp: object = None
1520+
flags as status: object = None
1521+
traps: object = None
1522+
1523+
Create context.
1524+
1525+
The context affects almost all operations and controls rounding,
1526+
Over/Underflow, raising of exceptions and much more. A new context
1527+
can be constructed as follows:
1528+
1529+
>>> c = Context(prec=28, Emin=-425000000, Emax=425000000,
1530+
... rounding=ROUND_HALF_EVEN, capitals=1, clamp=1,
1531+
... traps=[InvalidOperation, DivisionByZero, Overflow],
1532+
... flags=[])
1533+
>>>
1534+
[clinic start generated code]*/
15381535

1536+
static int
1537+
context_init_impl(PyObject *self, PyObject *prec, PyObject *rounding,
1538+
PyObject *emin, PyObject *emax, PyObject *capitals,
1539+
PyObject *clamp, PyObject *status, PyObject *traps)
1540+
/*[clinic end generated code: output=8bfdc59fbe862f44 input=45c704b93cd02959]*/
1541+
{
15391542
return context_setattrs(
15401543
self, prec, rounding,
15411544
emin, emax, capitals,
@@ -3210,17 +3213,25 @@ PyDec_FromObject(PyObject *v, PyObject *context)
32103213
}
32113214
}
32123215

3216+
/*[clinic input]
3217+
@classmethod
3218+
_decimal.Decimal.__new__ as dec_new
3219+
3220+
value as v: object(c_default="NULL") = "0"
3221+
context: object = None
3222+
3223+
Construct a new Decimal object.
3224+
3225+
value can be an integer, string, tuple, or another Decimal object. If
3226+
no value is given, return Decimal('0'). The context does not affect
3227+
the conversion and is only passed to determine if the InvalidOperation
3228+
trap is active.
3229+
[clinic start generated code]*/
3230+
32133231
static PyObject *
3214-
dec_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
3232+
dec_new_impl(PyTypeObject *type, PyObject *v, PyObject *context)
3233+
/*[clinic end generated code: output=5371cbce41508fe7 input=6353a3563bea247b]*/
32153234
{
3216-
static char *kwlist[] = {"value", "context", NULL};
3217-
PyObject *v = NULL;
3218-
PyObject *context = Py_None;
3219-
3220-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", kwlist,
3221-
&v, &context)) {
3222-
return NULL;
3223-
}
32243235
decimal_state *state = get_module_state_by_def(type);
32253236
CONTEXT_CHECK_VA(state, context);
32263237

@@ -6204,7 +6215,7 @@ static PyType_Slot dec_slots[] = {
62046215
{Py_tp_repr, dec_repr},
62056216
{Py_tp_hash, dec_hash},
62066217
{Py_tp_str, dec_str},
6207-
{Py_tp_doc, (void *)doc_decimal},
6218+
{Py_tp_doc, (void *)dec_new__doc__},
62086219
{Py_tp_richcompare, dec_richcompare},
62096220
{Py_tp_methods, dec_methods},
62106221
{Py_tp_getset, dec_getsets},
@@ -7851,7 +7862,7 @@ static PyType_Slot context_slots[] = {
78517862
{Py_tp_repr, context_repr},
78527863
{Py_tp_getattro, context_getattr},
78537864
{Py_tp_setattro, context_setattr},
7854-
{Py_tp_doc, (void *)doc_context},
7865+
{Py_tp_doc, (void *)context_init__doc__},
78557866
{Py_tp_methods, context_methods},
78567867
{Py_tp_getset, context_getsets},
78577868
{Py_tp_init, context_init},
@@ -8308,7 +8319,7 @@ static struct PyModuleDef_Slot _decimal_slots[] = {
83088319
static struct PyModuleDef _decimal_module = {
83098320
PyModuleDef_HEAD_INIT,
83108321
.m_name = "decimal",
8311-
.m_doc = doc__decimal,
8322+
.m_doc = "C decimal arithmetic module",
83128323
.m_size = sizeof(decimal_state),
83138324
.m_methods = _decimal_methods,
83148325
.m_slots = _decimal_slots,

Modules/_decimal/clinic/_decimal.c.h

Lines changed: 199 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)