https://github.com/python/cpython/commit/6e05537676da56b37ba0c9dbb459b60422918988
commit: 6e05537676da56b37ba0c9dbb459b60422918988
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-04-12T08:46:20Z
summary:

gh-117764: Add docstrings and signatures for the __replace__ methods (GH-117768)

files:
M Modules/_datetimemodule.c
M Objects/codeobject.c
M Objects/namespaceobject.c
M Objects/structseq.c

diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 2c9ef4b52851b7..06004e258b2eff 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -3645,7 +3645,8 @@ static PyMethodDef date_methods[] = {
 
     DATETIME_DATE_REPLACE_METHODDEF
 
-    {"__replace__", _PyCFunction_CAST(datetime_date_replace), METH_FASTCALL | 
METH_KEYWORDS},
+    {"__replace__", _PyCFunction_CAST(datetime_date_replace), METH_FASTCALL | 
METH_KEYWORDS,
+     PyDoc_STR("__replace__($self, /, **changes)\n--\n\nThe same as 
replace().")},
 
     {"__reduce__", (PyCFunction)date_reduce,        METH_NOARGS,
      PyDoc_STR("__reduce__() -> (cls, state)")},
@@ -4772,7 +4773,8 @@ static PyMethodDef time_methods[] = {
 
     DATETIME_TIME_REPLACE_METHODDEF
 
-    {"__replace__", _PyCFunction_CAST(datetime_time_replace), METH_FASTCALL | 
METH_KEYWORDS},
+    {"__replace__", _PyCFunction_CAST(datetime_time_replace), METH_FASTCALL | 
METH_KEYWORDS,
+     PyDoc_STR("__replace__($self, /, **changes)\n--\n\nThe same as 
replace().")},
 
      {"fromisoformat", (PyCFunction)time_fromisoformat, METH_O | METH_CLASS,
      PyDoc_STR("string -> time from a string in ISO 8601 format")},
@@ -6619,7 +6621,8 @@ static PyMethodDef datetime_methods[] = {
 
     DATETIME_DATETIME_REPLACE_METHODDEF
 
-    {"__replace__", _PyCFunction_CAST(datetime_datetime_replace), 
METH_FASTCALL | METH_KEYWORDS},
+    {"__replace__", _PyCFunction_CAST(datetime_datetime_replace), 
METH_FASTCALL | METH_KEYWORDS,
+     PyDoc_STR("__replace__($self, /, **changes)\n--\n\nThe same as 
replace().")},
 
     {"astimezone",  _PyCFunction_CAST(datetime_astimezone), METH_VARARGS | 
METH_KEYWORDS,
      PyDoc_STR("tz -> convert to local time in new timezone tz\n")},
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index f14ff73394b168..825f521b439235 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -2170,7 +2170,8 @@ static struct PyMethodDef code_methods[] = {
     {"co_positions", (PyCFunction)code_positionsiterator, METH_NOARGS},
     CODE_REPLACE_METHODDEF
     CODE__VARNAME_FROM_OPARG_METHODDEF
-    {"__replace__", _PyCFunction_CAST(code_replace), 
METH_FASTCALL|METH_KEYWORDS},
+    {"__replace__", _PyCFunction_CAST(code_replace), 
METH_FASTCALL|METH_KEYWORDS,
+     PyDoc_STR("__replace__($self, /, **changes)\n--\n\nThe same as 
replace().")},
     {NULL, NULL}                /* sentinel */
 };
 
diff --git a/Objects/namespaceobject.c b/Objects/namespaceobject.c
index b975bcfeea2cdf..a6b02fd011cf4f 100644
--- a/Objects/namespaceobject.c
+++ b/Objects/namespaceobject.c
@@ -219,7 +219,9 @@ namespace_replace(PyObject *self, PyObject *args, PyObject 
*kwargs)
 static PyMethodDef namespace_methods[] = {
     {"__reduce__", (PyCFunction)namespace_reduce, METH_NOARGS,
      namespace_reduce__doc__},
-    {"__replace__", _PyCFunction_CAST(namespace_replace), 
METH_VARARGS|METH_KEYWORDS, NULL},
+    {"__replace__", _PyCFunction_CAST(namespace_replace), 
METH_VARARGS|METH_KEYWORDS,
+     PyDoc_STR("__replace__($self, /, **changes)\n--\n\n"
+        "Return a copy of the namespace object with new values for the 
specified attributes.")},
     {NULL,         NULL}  // sentinel
 };
 
diff --git a/Objects/structseq.c b/Objects/structseq.c
index 661d96a968fb80..ec5c5ab45ba813 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -453,7 +453,9 @@ structseq_replace(PyStructSequence *self, PyObject *args, 
PyObject *kwargs)
 
 static PyMethodDef structseq_methods[] = {
     {"__reduce__", (PyCFunction)structseq_reduce, METH_NOARGS, NULL},
-    {"__replace__", _PyCFunction_CAST(structseq_replace), METH_VARARGS | 
METH_KEYWORDS, NULL},
+    {"__replace__", _PyCFunction_CAST(structseq_replace), METH_VARARGS | 
METH_KEYWORDS,
+     PyDoc_STR("__replace__($self, /, **changes)\n--\n\n"
+        "Return a copy of the structure with new values for the specified 
fields.")},
     {NULL, NULL}  // sentinel
 };
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to