Skip to content

Commit 46f320d

Browse files
Merge branch 'main' into re-group-name
2 parents 8909d14 + 130a8c3 commit 46f320d

File tree

102 files changed

+2089
-767
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2089
-767
lines changed

Doc/c-api/code.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,33 @@ bound into a function.
3333
3434
Return the number of free variables in *co*.
3535
36-
.. c:function:: PyCodeObject* PyCode_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab)
36+
.. c:function:: PyCodeObject* PyCode_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
3737
3838
Return a new code object. If you need a dummy code object to create a frame,
3939
use :c:func:`PyCode_NewEmpty` instead. Calling :c:func:`PyCode_New` directly
40-
can bind you to a precise Python version since the definition of the bytecode
41-
changes often.
40+
will bind you to a precise Python version since the definition of the bytecode
41+
changes often. The many arguments of this function are inter-dependent in complex
42+
ways, meaning that subtle changes to values are likely to result in incorrect
43+
execution or VM crashes. Use this function only with extreme care.
4244
43-
.. c:function:: PyCodeObject* PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab)
45+
.. versionchanged:: 3.11
46+
Added ``exceptiontable`` parameter.
47+
48+
.. c:function:: PyCodeObject* PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
4449
4550
Similar to :c:func:`PyCode_New`, but with an extra "posonlyargcount" for positional-only arguments.
51+
The same caveats that apply to ``PyCode_New`` also apply to this function.
4652
4753
.. versionadded:: 3.8
4854
55+
.. versionchanged:: 3.11
56+
Added ``exceptiontable`` parameter.
57+
4958
.. c:function:: PyCodeObject* PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
5059
5160
Return a new empty code object with the specified filename,
52-
function name, and first line number. It is illegal to
53-
:func:`exec` or :func:`eval` the resulting code object.
61+
function name, and first line number. The resulting code
62+
object will raise an ``Exception`` if executed.
5463
5564
.. c:function:: int PyCode_Addr2Line(PyCodeObject *co, int byte_offset)
5665

Doc/c-api/init.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
12281228
12291229
.. versionadded:: 3.8
12301230
1231-
.. c:type:: PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, PyFrameObject *frame, int throwflag)
1231+
.. c:type:: PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
12321232
12331233
Type of a frame evaluation function.
12341234
@@ -1238,6 +1238,9 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
12381238
.. versionchanged:: 3.9
12391239
The function now takes a *tstate* parameter.
12401240
1241+
.. versionchanged:: 3.11
1242+
The *frame* parameter changed from ``PyFrameObject*`` to ``_PyInterpreterFrame*``.
1243+
12411244
.. c:function:: _PyFrameEvalFunction _PyInterpreterState_GetEvalFrameFunc(PyInterpreterState *interp)
12421245
12431246
Get the frame evaluation function.

Doc/c-api/list.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ List Objects
5353
5454
.. c:function:: Py_ssize_t PyList_GET_SIZE(PyObject *list)
5555
56-
Macro form of :c:func:`PyList_Size` without error checking.
56+
Similar to :c:func:`PyList_Size`, but without error checking.
5757
5858
5959
.. c:function:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index)
@@ -66,7 +66,7 @@ List Objects
6666
6767
.. c:function:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i)
6868
69-
Macro form of :c:func:`PyList_GetItem` without error checking.
69+
Similar to :c:func:`PyList_GetItem`, but without error checking.
7070
7171
7272
.. c:function:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item)

Doc/c-api/structures.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,38 +62,38 @@ the definition of all other Python objects.
6262
See documentation of :c:type:`PyVarObject` above.
6363

6464

65-
.. c:function:: int Py_Is(const PyObject *x, const PyObject *y)
65+
.. c:function:: int Py_Is(PyObject *x, PyObject *y)
6666
6767
Test if the *x* object is the *y* object, the same as ``x is y`` in Python.
6868
6969
.. versionadded:: 3.10
7070
7171
72-
.. c:function:: int Py_IsNone(const PyObject *x)
72+
.. c:function:: int Py_IsNone(PyObject *x)
7373
7474
Test if an object is the ``None`` singleton,
7575
the same as ``x is None`` in Python.
7676
7777
.. versionadded:: 3.10
7878
7979
80-
.. c:function:: int Py_IsTrue(const PyObject *x)
80+
.. c:function:: int Py_IsTrue(PyObject *x)
8181
8282
Test if an object is the ``True`` singleton,
8383
the same as ``x is True`` in Python.
8484
8585
.. versionadded:: 3.10
8686
8787
88-
.. c:function:: int Py_IsFalse(const PyObject *x)
88+
.. c:function:: int Py_IsFalse(PyObject *x)
8989
9090
Test if an object is the ``False`` singleton,
9191
the same as ``x is False`` in Python.
9292
9393
.. versionadded:: 3.10
9494
9595
96-
.. c:function:: PyTypeObject* Py_TYPE(const PyObject *o)
96+
.. c:function:: PyTypeObject* Py_TYPE(PyObject *o)
9797
9898
Get the type of the Python object *o*.
9999
@@ -103,6 +103,7 @@ the definition of all other Python objects.
103103
104104
.. versionchanged:: 3.11
105105
:c:func:`Py_TYPE()` is changed to an inline static function.
106+
The parameter type is no longer :c:type:`const PyObject*`.
106107
107108
108109
.. c:function:: int Py_IS_TYPE(PyObject *o, PyTypeObject *type)
@@ -120,12 +121,15 @@ the definition of all other Python objects.
120121
.. versionadded:: 3.9
121122
122123
123-
.. c:function:: Py_ssize_t Py_REFCNT(const PyObject *o)
124+
.. c:function:: Py_ssize_t Py_REFCNT(PyObject *o)
124125
125126
Get the reference count of the Python object *o*.
126127
127128
Use the :c:func:`Py_SET_REFCNT()` function to set an object reference count.
128129
130+
.. versionchanged:: 3.11
131+
The parameter type is no longer :c:type:`const PyObject*`.
132+
129133
.. versionchanged:: 3.10
130134
:c:func:`Py_REFCNT()` is changed to the inline static function.
131135
@@ -137,14 +141,15 @@ the definition of all other Python objects.
137141
.. versionadded:: 3.9
138142
139143
140-
.. c:function:: Py_ssize_t Py_SIZE(const PyVarObject *o)
144+
.. c:function:: Py_ssize_t Py_SIZE(PyVarObject *o)
141145
142146
Get the size of the Python object *o*.
143147
144148
Use the :c:func:`Py_SET_SIZE` function to set an object size.
145149
146150
.. versionchanged:: 3.11
147151
:c:func:`Py_SIZE()` is changed to an inline static function.
152+
The parameter type is no longer :c:type:`const PyVarObject*`.
148153
149154
150155
.. c:function:: void Py_SET_SIZE(PyVarObject *o, Py_ssize_t size)

Doc/c-api/sys.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ Operating System Utilities
9696
9797
Return true when the interpreter runs out of stack space. This is a reliable
9898
check, but is only available when :const:`USE_STACKCHECK` is defined (currently
99-
on Windows using the Microsoft Visual C++ compiler). :const:`USE_STACKCHECK`
100-
will be defined automatically; you should never change the definition in your
101-
own code.
99+
on certain versions of Windows using the Microsoft Visual C++ compiler).
100+
:const:`USE_STACKCHECK` will be defined automatically; you should never
101+
change the definition in your own code.
102102
103103
104104
.. c:function:: PyOS_sighandler_t PyOS_getsig(int i)

Doc/c-api/tuple.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Tuple Objects
9191
9292
.. note::
9393
94-
This macro "steals" a reference to *o*, and, unlike
94+
This function "steals" a reference to *o*, and, unlike
9595
:c:func:`PyTuple_SetItem`, does *not* discard a reference to any item that
9696
is being replaced; any reference in the tuple at position *pos* will be
9797
leaked.
@@ -215,7 +215,8 @@ type.
215215
216216
.. c:function:: void PyStructSequence_SET_ITEM(PyObject *p, Py_ssize_t *pos, PyObject *o)
217217
218-
Macro equivalent of :c:func:`PyStructSequence_SetItem`.
218+
Similar to :c:func:`PyStructSequence_SetItem`, but implemented as a static
219+
inlined function.
219220
220221
.. note::
221222

Doc/c-api/unicode.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ Python:
8484
is exposed to Python code as ``str``.
8585

8686

87-
The following APIs are really C macros and can be used to do fast checks and to
88-
access internal read-only data of Unicode objects:
87+
The following APIs are C macros and static inlined functions for fast checks and
88+
access to internal read-only data of Unicode objects:
8989

9090
.. c:function:: int PyUnicode_Check(PyObject *o)
9191
@@ -168,20 +168,21 @@ access internal read-only data of Unicode objects:
168168
.. versionadded:: 3.3
169169
170170
171-
.. c:function:: void PyUnicode_WRITE(int kind, void *data, Py_ssize_t index, \
172-
Py_UCS4 value)
171+
.. c:function:: void PyUnicode_WRITE(unsigned int kind, void *data, \
172+
Py_ssize_t index, Py_UCS4 value)
173173
174174
Write into a canonical representation *data* (as obtained with
175-
:c:func:`PyUnicode_DATA`). This macro does not do any sanity checks and is
175+
:c:func:`PyUnicode_DATA`). This function performs no sanity checks, and is
176176
intended for usage in loops. The caller should cache the *kind* value and
177-
*data* pointer as obtained from other macro calls. *index* is the index in
177+
*data* pointer as obtained from other calls. *index* is the index in
178178
the string (starts at 0) and *value* is the new code point value which should
179179
be written to that location.
180180
181181
.. versionadded:: 3.3
182182
183183
184-
.. c:function:: Py_UCS4 PyUnicode_READ(int kind, void *data, Py_ssize_t index)
184+
.. c:function:: Py_UCS4 PyUnicode_READ(unsigned int kind, void *data, \
185+
Py_ssize_t index)
185186
186187
Read a code point from a canonical representation *data* (as obtained with
187188
:c:func:`PyUnicode_DATA`). No checks or ready calls are performed.
@@ -198,7 +199,7 @@ access internal read-only data of Unicode objects:
198199
.. versionadded:: 3.3
199200
200201
201-
.. c:macro:: PyUnicode_MAX_CHAR_VALUE(o)
202+
.. c:function:: Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *o)
202203
203204
Return the maximum code point that is suitable for creating another string
204205
based on *o*, which must be in the "canonical" representation. This is
@@ -239,7 +240,7 @@ access internal read-only data of Unicode objects:
239240
a Unicode object (not checked).
240241
241242
.. versionchanged:: 3.3
242-
This macro is now inefficient -- because in many cases the
243+
This function is now inefficient -- because in many cases the
243244
:c:type:`Py_UNICODE` representation does not exist and needs to be created
244245
-- and can fail (return ``NULL`` with an exception set). Try to port the
245246
code to use the new :c:func:`PyUnicode_nBYTE_DATA` macros or use
@@ -642,8 +643,8 @@ APIs:
642643
.. c:function:: Py_UCS4 PyUnicode_ReadChar(PyObject *unicode, Py_ssize_t index)
643644
644645
Read a character from a string. This function checks that *unicode* is a
645-
Unicode object and the index is not out of bounds, in contrast to the macro
646-
version :c:func:`PyUnicode_READ_CHAR`.
646+
Unicode object and the index is not out of bounds, in contrast to
647+
:c:func:`PyUnicode_READ_CHAR`, which performs no error checking.
647648
648649
.. versionadded:: 3.3
649650

Doc/c-api/weakref.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,4 @@ as much as it can.
6666
6767
.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
6868
69-
Similar to :c:func:`PyWeakref_GetObject`, but implemented as a macro that does no
70-
error checking.
69+
Similar to :c:func:`PyWeakref_GetObject`, but does no error checking.

Doc/howto/curses.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ The :meth:`~curses.window.addstr` method takes a Python string or
299299
bytestring as the value to be displayed. The contents of bytestrings
300300
are sent to the terminal as-is. Strings are encoded to bytes using
301301
the value of the window's :attr:`encoding` attribute; this defaults to
302-
the default system encoding as returned by
303-
:func:`locale.getpreferredencoding`.
302+
the default system encoding as returned by :func:`locale.getencoding`.
304303

305304
The :meth:`~curses.window.addch` methods take a character, which can be
306305
either a string of length 1, a bytestring of length 1, or an integer.

Doc/includes/sqlite3/blob.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
con = sqlite3.connect(":memory:")
44
con.execute("create table test(blob_col blob)")
5-
con.execute("insert into test(blob_col) values (zeroblob(10))")
5+
con.execute("insert into test(blob_col) values (zeroblob(13))")
66

77
# Write to our blob, using two write operations:
88
with con.blobopen("test", "blob_col", 1) as blob:
9-
blob.write(b"Hello")
10-
blob.write(b"World")
9+
blob.write(b"hello, ")
10+
blob.write(b"world.")
11+
# Modify the first and last bytes of our blob
12+
blob[0] = b"H"
13+
blob[-1] = b"!"
1114

1215
# Read the contents of our blob
1316
with con.blobopen("test", "blob_col", 1) as blob:
1417
greeting = blob.read()
1518

16-
print(greeting) # outputs "b'HelloWorld'"
19+
print(greeting) # outputs "b'Hello, world!'"

0 commit comments

Comments
 (0)