[Python-checkins] Document CodeType.replace (GH-17776)

Miss Islington (bot) webhook-mailer at python.org
Wed Jan 1 01:28:00 EST 2020


https://github.com/python/cpython/commit/dad526eb36530186f625a2724c8835fe3df3c8c1
commit: dad526eb36530186f625a2724c8835fe3df3c8c1
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-12-31T22:27:56-08:00
summary:

Document CodeType.replace (GH-17776)

(cherry picked from commit 22424c02e51fab3b62cbe255d0b87d1b55b9a6c3)

Co-authored-by: Anthony Sottile <asottile at umich.edu>

files:
M Doc/library/types.rst
M Objects/clinic/codeobject.c.h
M Objects/codeobject.c

diff --git a/Doc/library/types.rst b/Doc/library/types.rst
index 9393f9e6db990..3529c2b0edb89 100644
--- a/Doc/library/types.rst
+++ b/Doc/library/types.rst
@@ -132,7 +132,7 @@ Standard names are defined for the following types:
    .. versionadded:: 3.6
 
 
-.. data:: CodeType
+.. class:: CodeType(**kwargs)
 
    .. index:: builtin: compile
 
@@ -143,6 +143,12 @@ Standard names are defined for the following types:
    Note that the audited arguments may not match the names or positions
    required by the initializer.
 
+   .. method:: CodeType.replace(**kwargs)
+
+     Return a copy of the code object with new values for the specified fields.
+
+     .. versionadded:: 3.8
+
 .. data:: CellType
 
    The type for cell objects: such objects are used as containers for
diff --git a/Objects/clinic/codeobject.c.h b/Objects/clinic/codeobject.c.h
index 6596de051cacb..1dd82278cf3d5 100644
--- a/Objects/clinic/codeobject.c.h
+++ b/Objects/clinic/codeobject.c.h
@@ -11,7 +11,7 @@ PyDoc_STRVAR(code_replace__doc__,
 "        co_lnotab=None)\n"
 "--\n"
 "\n"
-"Return a new code object with new specified fields.");
+"Return a copy of the code object with new values for the specified fields.");
 
 #define CODE_REPLACE_METHODDEF    \
     {"replace", (PyCFunction)(void(*)(void))code_replace, METH_FASTCALL|METH_KEYWORDS, code_replace__doc__},
@@ -253,4 +253,4 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=fade581d6313a0c2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=27fe34e82106b220 input=a9049054013a1b77]*/
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index f0b62ec94148d..522e1a9f2a419 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -610,7 +610,7 @@ code.replace
     co_name: unicode(c_default="self->co_name") = None
     co_lnotab: PyBytesObject(c_default="(PyBytesObject *)self->co_lnotab") = None
 
-Return a new code object with new specified fields.
+Return a copy of the code object with new values for the specified fields.
 [clinic start generated code]*/
 
 static PyObject *
@@ -622,7 +622,7 @@ code_replace_impl(PyCodeObject *self, int co_argcount,
                   PyObject *co_varnames, PyObject *co_freevars,
                   PyObject *co_cellvars, PyObject *co_filename,
                   PyObject *co_name, PyBytesObject *co_lnotab)
-/*[clinic end generated code: output=25c8e303913bcace input=77189e46579ec426]*/
+/*[clinic end generated code: output=25c8e303913bcace input=d9051bc8f24e6b28]*/
 {
 #define CHECK_INT_ARG(ARG) \
         if (ARG < 0) { \



More information about the Python-checkins mailing list