Skip to content

Commit 200788c

Browse files
committed
Allow more docstrings to be removed during compilation in some modules
1 parent 5dc2a37 commit 200788c

4 files changed

Lines changed: 40 additions & 38 deletions

File tree

Modules/cPickle.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,12 +2295,12 @@ Pickler_dump(Picklerobject *self, PyObject *args)
22952295
static struct PyMethodDef Pickler_methods[] =
22962296
{
22972297
{"dump", (PyCFunction)Pickler_dump, METH_VARARGS,
2298-
"dump(object) --"
2299-
"Write an object in pickle format to the object's pickle stream"},
2298+
PyDoc_STR("dump(object) -- "
2299+
"Write an object in pickle format to the object's pickle stream")},
23002300
{"clear_memo", (PyCFunction)Pickle_clear_memo, METH_NOARGS,
2301-
"clear_memo() -- Clear the picklers memo"},
2301+
PyDoc_STR("clear_memo() -- Clear the picklers memo")},
23022302
{"getvalue", (PyCFunction)Pickle_getvalue, METH_VARARGS,
2303-
"getvalue() -- Finish picking a list-based pickle"},
2303+
PyDoc_STR("getvalue() -- Finish picking a list-based pickle")},
23042304
{NULL, NULL} /* sentinel */
23052305
};
23062306

@@ -4301,15 +4301,16 @@ Unpickler_noload(Unpicklerobject *self, PyObject *args)
43014301

43024302
static struct PyMethodDef Unpickler_methods[] = {
43034303
{"load", (PyCFunction)Unpickler_load, METH_VARARGS,
4304-
"load() -- Load a pickle"
4304+
PyDoc_STR("load() -- Load a pickle")
43054305
},
43064306
{"noload", (PyCFunction)Unpickler_noload, METH_VARARGS,
4307+
PyDoc_STR(
43074308
"noload() -- not load a pickle, but go through most of the motions\n"
43084309
"\n"
43094310
"This function can be used to read past a pickle without instantiating\n"
43104311
"any objects or importing any modules. It can also be used to find all\n"
43114312
"persistent references without instantiating any objects or importing\n"
4312-
"any modules.\n"
4313+
"any modules.\n")
43134314
},
43144315
{NULL, NULL} /* sentinel */
43154316
};
@@ -4648,34 +4649,34 @@ static PyTypeObject Unpicklertype = {
46484649

46494650
static struct PyMethodDef cPickle_methods[] = {
46504651
{"dump", (PyCFunction)cpm_dump, METH_VARARGS,
4651-
"dump(object, file, [binary]) --"
4652+
PyDoc_STR("dump(object, file, [binary]) --"
46524653
"Write an object in pickle format to the given file\n"
46534654
"\n"
46544655
"If the optional argument, binary, is provided and is true, then the\n"
46554656
"pickle will be written in binary format, which is more space and\n"
4656-
"computationally efficient. \n"
4657+
"computationally efficient. \n")
46574658
},
46584659
{"dumps", (PyCFunction)cpm_dumps, METH_VARARGS,
4659-
"dumps(object, [binary]) --"
4660+
PyDoc_STR("dumps(object, [binary]) --"
46604661
"Return a string containing an object in pickle format\n"
46614662
"\n"
46624663
"If the optional argument, binary, is provided and is true, then the\n"
46634664
"pickle will be written in binary format, which is more space and\n"
4664-
"computationally efficient. \n"
4665+
"computationally efficient. \n")
46654666
},
46664667
{"load", (PyCFunction)cpm_load, METH_VARARGS,
4667-
"load(file) -- Load a pickle from the given file"},
4668+
PyDoc_STR("load(file) -- Load a pickle from the given file")},
46684669
{"loads", (PyCFunction)cpm_loads, METH_VARARGS,
4669-
"loads(string) -- Load a pickle from the given string"},
4670+
PyDoc_STR("loads(string) -- Load a pickle from the given string")},
46704671
{"Pickler", (PyCFunction)get_Pickler, METH_VARARGS,
4671-
"Pickler(file, [binary]) -- Create a pickler\n"
4672+
PyDoc_STR("Pickler(file, [binary]) -- Create a pickler\n"
46724673
"\n"
46734674
"If the optional argument, binary, is provided and is true, then\n"
46744675
"pickles will be written in binary format, which is more space and\n"
4675-
"computationally efficient. \n"
4676+
"computationally efficient. \n")
46764677
},
46774678
{"Unpickler", (PyCFunction)get_Unpickler, METH_VARARGS,
4678-
"Unpickler(file) -- Create an unpickler"},
4679+
PyDoc_STR("Unpickler(file) -- Create an unpickler")},
46794680
{ NULL, NULL }
46804681
};
46814682

Modules/operator.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ op_delslice(PyObject *s, PyObject *a)
146146

147147
#undef spam1
148148
#undef spam2
149-
#define spam1(OP,DOC) {#OP, OP, METH_VARARGS, DOC},
149+
#define spam1(OP,DOC) {#OP, OP, METH_VARARGS, PyDoc_STR(DOC)},
150150
#define spam2(OP,ALTOP,DOC) {#OP, op_##OP, METH_VARARGS, DOC}, \
151-
{#ALTOP, op_##OP, METH_VARARGS, DOC},
151+
{#ALTOP, op_##OP, METH_VARARGS, PyDoc_STR(DOC)},
152152

153153
static struct PyMethodDef operator_methods[] = {
154154

Modules/parsermodule.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,15 @@ parser_issuite(PyST_Object *self, PyObject *args, PyObject *kw)
442442
static PyMethodDef
443443
parser_methods[] = {
444444
{"compile", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE,
445-
"Compile this ST object into a code object."},
445+
PyDoc_STR("Compile this ST object into a code object.")},
446446
{"isexpr", (PyCFunction)parser_isexpr, PUBLIC_METHOD_TYPE,
447-
"Determines if this ST object was created from an expression."},
447+
PyDoc_STR("Determines if this ST object was created from an expression.")},
448448
{"issuite", (PyCFunction)parser_issuite, PUBLIC_METHOD_TYPE,
449-
"Determines if this ST object was created from a suite."},
449+
PyDoc_STR("Determines if this ST object was created from a suite.")},
450450
{"tolist", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE,
451-
"Creates a list-tree representation of this ST."},
451+
PyDoc_STR("Creates a list-tree representation of this ST.")},
452452
{"totuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE,
453-
"Creates a tuple-tree representation of this ST."},
453+
PyDoc_STR("Creates a tuple-tree representation of this ST.")},
454454

455455
{NULL, NULL, 0, NULL}
456456
};
@@ -2816,37 +2816,37 @@ parser__pickler(PyObject *self, PyObject *args)
28162816
*/
28172817
static PyMethodDef parser_functions[] = {
28182818
{"ast2tuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE,
2819-
"Creates a tuple-tree representation of an ST."},
2819+
PyDoc_STR("Creates a tuple-tree representation of an ST.")},
28202820
{"ast2list", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE,
2821-
"Creates a list-tree representation of an ST."},
2821+
PyDoc_STR("Creates a list-tree representation of an ST.")},
28222822
{"compileast", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE,
2823-
"Compiles an ST object into a code object."},
2823+
PyDoc_STR("Compiles an ST object into a code object.")},
28242824
{"compilest", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE,
2825-
"Compiles an ST object into a code object."},
2825+
PyDoc_STR("Compiles an ST object into a code object.")},
28262826
{"expr", (PyCFunction)parser_expr, PUBLIC_METHOD_TYPE,
2827-
"Creates an ST object from an expression."},
2827+
PyDoc_STR("Creates an ST object from an expression.")},
28282828
{"isexpr", (PyCFunction)parser_isexpr, PUBLIC_METHOD_TYPE,
2829-
"Determines if an ST object was created from an expression."},
2829+
PyDoc_STR("Determines if an ST object was created from an expression.")},
28302830
{"issuite", (PyCFunction)parser_issuite, PUBLIC_METHOD_TYPE,
2831-
"Determines if an ST object was created from a suite."},
2831+
PyDoc_STR("Determines if an ST object was created from a suite.")},
28322832
{"suite", (PyCFunction)parser_suite, PUBLIC_METHOD_TYPE,
2833-
"Creates an ST object from a suite."},
2833+
PyDoc_STR("Creates an ST object from a suite.")},
28342834
{"sequence2ast", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
2835-
"Creates an ST object from a tree representation."},
2835+
PyDoc_STR("Creates an ST object from a tree representation.")},
28362836
{"sequence2st", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
2837-
"Creates an ST object from a tree representation."},
2837+
PyDoc_STR("Creates an ST object from a tree representation.")},
28382838
{"st2tuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE,
2839-
"Creates a tuple-tree representation of an ST."},
2839+
PyDoc_STR("Creates a tuple-tree representation of an ST.")},
28402840
{"st2list", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE,
2841-
"Creates a list-tree representation of an ST."},
2841+
PyDoc_STR("Creates a list-tree representation of an ST.")},
28422842
{"tuple2ast", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
2843-
"Creates an ST object from a tree representation."},
2843+
PyDoc_STR("Creates an ST object from a tree representation.")},
28442844
{"tuple2st", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE,
2845-
"Creates an ST object from a tree representation."},
2845+
PyDoc_STR("Creates an ST object from a tree representation.")},
28462846

28472847
/* private stuff: support pickle module */
28482848
{"_pickler", (PyCFunction)parser__pickler, METH_VARARGS,
2849-
"Returns the pickle magic to allow ST objects to be pickled."},
2849+
PyDoc_STR("Returns the pickle magic to allow ST objects to be pickled.")},
28502850

28512851
{NULL, NULL, 0, NULL}
28522852
};

Modules/symtablemodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ symtable_symtable(PyObject *self, PyObject *args)
3939

4040
static PyMethodDef symtable_methods[] = {
4141
{"symtable", symtable_symtable, METH_VARARGS,
42-
"Return symbol and scope dictionaries used internally by compiler."},
42+
PyDoc_STR("Return symbol and scope dictionaries"
43+
" used internally by compiler.")},
4344
{NULL, NULL} /* sentinel */
4445
};
4546

0 commit comments

Comments
 (0)