Skip to content

Commit 22424c0

Browse files
asottilepablogsal
authored andcommitted
Document CodeType.replace (GH-17776)
1 parent 37143a8 commit 22424c0

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

Doc/library/types.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Standard names are defined for the following types:
132132
.. versionadded:: 3.6
133133

134134

135-
.. data:: CodeType
135+
.. class:: CodeType(**kwargs)
136136

137137
.. index:: builtin: compile
138138

@@ -143,6 +143,12 @@ Standard names are defined for the following types:
143143
Note that the audited arguments may not match the names or positions
144144
required by the initializer.
145145

146+
.. method:: CodeType.replace(**kwargs)
147+
148+
Return a copy of the code object with new values for the specified fields.
149+
150+
.. versionadded:: 3.8
151+
146152
.. data:: CellType
147153

148154
The type for cell objects: such objects are used as containers for

Objects/clinic/codeobject.c.h

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

Objects/codeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ code.replace
610610
co_name: unicode(c_default="self->co_name") = None
611611
co_lnotab: PyBytesObject(c_default="(PyBytesObject *)self->co_lnotab") = None
612612
613-
Return a new code object with new specified fields.
613+
Return a copy of the code object with new values for the specified fields.
614614
[clinic start generated code]*/
615615

616616
static PyObject *
@@ -622,7 +622,7 @@ code_replace_impl(PyCodeObject *self, int co_argcount,
622622
PyObject *co_varnames, PyObject *co_freevars,
623623
PyObject *co_cellvars, PyObject *co_filename,
624624
PyObject *co_name, PyBytesObject *co_lnotab)
625-
/*[clinic end generated code: output=25c8e303913bcace input=77189e46579ec426]*/
625+
/*[clinic end generated code: output=25c8e303913bcace input=d9051bc8f24e6b28]*/
626626
{
627627
#define CHECK_INT_ARG(ARG) \
628628
if (ARG < 0) { \

0 commit comments

Comments
 (0)