Skip to content

Commit b578c9d

Browse files
Merge branch 'main' into urllib-parse-allow-none
2 parents 5846bf2 + cc6b62a commit b578c9d

File tree

89 files changed

+1994
-325
lines changed

Some content is hidden

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

89 files changed

+1994
-325
lines changed

Doc/c-api/concrete.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Other Objects
109109
descriptor.rst
110110
slice.rst
111111
memoryview.rst
112+
picklebuffer.rst
112113
weakref.rst
113114
capsule.rst
114115
frame.rst

Doc/c-api/picklebuffer.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
.. highlight:: c
2+
3+
.. _picklebuffer-objects:
4+
5+
.. index::
6+
pair: object; PickleBuffer
7+
8+
Pickle buffer objects
9+
---------------------
10+
11+
.. versionadded:: 3.8
12+
13+
A :class:`pickle.PickleBuffer` object wraps a :ref:`buffer-providing object
14+
<bufferobjects>` for out-of-band data transfer with the :mod:`pickle` module.
15+
16+
17+
.. c:var:: PyTypeObject PyPickleBuffer_Type
18+
19+
This instance of :c:type:`PyTypeObject` represents the Python pickle buffer type.
20+
This is the same object as :class:`pickle.PickleBuffer` in the Python layer.
21+
22+
23+
.. c:function:: int PyPickleBuffer_Check(PyObject *op)
24+
25+
Return true if *op* is a pickle buffer instance.
26+
This function always succeeds.
27+
28+
29+
.. c:function:: PyObject *PyPickleBuffer_FromObject(PyObject *obj)
30+
31+
Create a pickle buffer from the object *obj*.
32+
33+
This function will fail if *obj* doesn't support the :ref:`buffer protocol <bufferobjects>`.
34+
35+
On success, return a new pickle buffer instance.
36+
On failure, set an exception and return ``NULL``.
37+
38+
Analogous to calling :class:`pickle.PickleBuffer` with *obj* in Python.
39+
40+
41+
.. c:function:: const Py_buffer *PyPickleBuffer_GetBuffer(PyObject *picklebuf)
42+
43+
Get a pointer to the underlying :c:type:`Py_buffer` that the pickle buffer wraps.
44+
45+
The returned pointer is valid as long as *picklebuf* is alive and has not been
46+
released. The caller must not modify or free the returned :c:type:`Py_buffer`.
47+
If the pickle buffer has been released, raise :exc:`ValueError`.
48+
49+
On success, return a pointer to the buffer view.
50+
On failure, set an exception and return ``NULL``.
51+
52+
53+
.. c:function:: int PyPickleBuffer_Release(PyObject *picklebuf)
54+
55+
Release the underlying buffer held by the pickle buffer.
56+
57+
Return ``0`` on success. On failure, set an exception and return ``-1``.
58+
59+
Analogous to calling :meth:`pickle.PickleBuffer.release` in Python.

Doc/c-api/structures.rst

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,25 @@ definition with the same method name.
447447
slot. This is helpful because calls to PyCFunctions are optimized more
448448
than wrapper object calls.
449449
450+
451+
.. c:var:: PyTypeObject PyCMethod_Type
452+
453+
The type object corresponding to Python C method objects. This is
454+
available as :class:`types.BuiltinMethodType` in the Python layer.
455+
456+
457+
.. c:function:: int PyCMethod_Check(PyObject *op)
458+
459+
Return true if *op* is an instance of the :c:type:`PyCMethod_Type` type
460+
or a subtype of it. This function always succeeds.
461+
462+
463+
.. c:function:: int PyCMethod_CheckExact(PyObject *op)
464+
465+
This is the same as :c:func:`PyCMethod_Check`, but does not account for
466+
subtypes.
467+
468+
450469
.. c:function:: PyObject * PyCMethod_New(PyMethodDef *ml, PyObject *self, PyObject *module, PyTypeObject *cls)
451470
452471
Turn *ml* into a Python :term:`callable` object.
@@ -472,6 +491,24 @@ definition with the same method name.
472491
.. versionadded:: 3.9
473492
474493
494+
.. c:var:: PyTypeObject PyCFunction_Type
495+
496+
The type object corresponding to Python C function objects. This is
497+
available as :class:`types.BuiltinFunctionType` in the Python layer.
498+
499+
500+
.. c:function:: int PyCFunction_Check(PyObject *op)
501+
502+
Return true if *op* is an instance of the :c:type:`PyCFunction_Type` type
503+
or a subtype of it. This function always succeeds.
504+
505+
506+
.. c:function:: int PyCFunction_CheckExact(PyObject *op)
507+
508+
This is the same as :c:func:`PyCFunction_Check`, but does not account for
509+
subtypes.
510+
511+
475512
.. c:function:: PyObject * PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module)
476513
477514
Equivalent to ``PyCMethod_New(ml, self, module, NULL)``.
@@ -482,6 +519,62 @@ definition with the same method name.
482519
Equivalent to ``PyCMethod_New(ml, self, NULL, NULL)``.
483520
484521
522+
.. c:function:: int PyCFunction_GetFlags(PyObject *func)
523+
524+
Get the function's flags on *func* as they were passed to
525+
:c:member:`~PyMethodDef.ml_flags`.
526+
527+
If *func* is not a C function object, this fails with an exception.
528+
*func* must not be ``NULL``.
529+
530+
This function returns the function's flags on success, and ``-1`` with an
531+
exception set on failure.
532+
533+
534+
.. c:function:: int PyCFunction_GET_FLAGS(PyObject *func)
535+
536+
This is the same as :c:func:`PyCFunction_GetFlags`, but without error
537+
or type checking.
538+
539+
540+
.. c:function:: PyCFunction PyCFunction_GetFunction(PyObject *func)
541+
542+
Get the function pointer on *func* as it was passed to
543+
:c:member:`~PyMethodDef.ml_meth`.
544+
545+
If *func* is not a C function object, this fails with an exception.
546+
*func* must not be ``NULL``.
547+
548+
This function returns the function pointer on success, and ``NULL`` with an
549+
exception set on failure.
550+
551+
552+
.. c:function:: int PyCFunction_GET_FUNCTION(PyObject *func)
553+
554+
This is the same as :c:func:`PyCFunction_GetFunction`, but without error
555+
or type checking.
556+
557+
558+
.. c:function:: PyObject *PyCFunction_GetSelf(PyObject *func)
559+
560+
Get the "self" object on *func*. This is the object that would be passed
561+
to the first argument of a :c:type:`PyCFunction`. For C function objects
562+
created through a :c:type:`PyMethodDef` on a :c:type:`PyModuleDef`, this
563+
is the resulting module object.
564+
565+
If *func* is not a C function object, this fails with an exception.
566+
*func* must not be ``NULL``.
567+
568+
This function returns a :term:`borrowed reference` to the "self" object
569+
on success, and ``NULL`` with an exception set on failure.
570+
571+
572+
.. c:function:: PyObject *PyCFunction_GET_SELF(PyObject *func)
573+
574+
This is the same as :c:func:`PyCFunction_GetSelf`, but without error or
575+
type checking.
576+
577+
485578
Accessing attributes of extension types
486579
---------------------------------------
487580

Doc/library/cmdline.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ The following modules have a command-line interface.
1616
* :ref:`dis <dis-cli>`
1717
* :ref:`doctest <doctest-cli>`
1818
* :mod:`!encodings.rot_13`
19-
* :mod:`ensurepip`
19+
* :ref:`ensurepip <ensurepip-cli>`
2020
* :mod:`filecmp`
2121
* :mod:`fileinput`
2222
* :mod:`ftplib`
2323
* :ref:`gzip <gzip-cli>`
2424
* :ref:`http.server <http-server-cli>`
25-
* :mod:`!idlelib`
25+
* :ref:`idlelib <idlelib-cli>`
2626
* :ref:`inspect <inspect-module-cli>`
2727
* :ref:`json <json-commandline>`
2828
* :ref:`mimetypes <mimetypes-cli>`
29-
* :mod:`pdb`
29+
* :ref:`pdb <pdb-cli>`
3030
* :ref:`pickle <pickle-cli>`
3131
* :ref:`pickletools <pickletools-cli>`
3232
* :ref:`platform <platform-cli>`
@@ -52,8 +52,8 @@ The following modules have a command-line interface.
5252
* :mod:`turtledemo`
5353
* :ref:`unittest <unittest-command-line-interface>`
5454
* :ref:`uuid <uuid-cli>`
55-
* :mod:`venv`
56-
* :mod:`webbrowser`
55+
* :ref:`venv <venv-cli>`
56+
* :ref:`webbrowser <webbrowser-cli>`
5757
* :ref:`zipapp <zipapp-command-line-interface>`
5858
* :ref:`zipfile <zipfile-commandline>`
5959

Doc/library/ensurepip.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ when creating a virtual environment) or after explicitly uninstalling
4242

4343
.. include:: ../includes/wasm-mobile-notavail.rst
4444

45-
Command line interface
45+
.. _ensurepip-cli:
46+
47+
Command-line interface
4648
----------------------
4749

4850
.. program:: ensurepip

Doc/library/gzip.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Example of how to GZIP compress a binary string::
283283

284284
.. _gzip-cli:
285285

286-
Command Line Interface
286+
Command-line interface
287287
----------------------
288288

289289
The :mod:`gzip` module provides a simple command line interface to compress or
@@ -296,7 +296,7 @@ Once executed the :mod:`gzip` module keeps the input file(s).
296296
Add a new command line interface with a usage.
297297
By default, when you will execute the CLI, the default compression level is 6.
298298

299-
Command line options
299+
Command-line options
300300
^^^^^^^^^^^^^^^^^^^^
301301

302302
.. option:: file

Doc/library/idle.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,9 @@ looked for in the user's home directory. Statements in this file will be
661661
executed in the Tk namespace, so this file is not useful for importing
662662
functions to be used from IDLE's Python shell.
663663

664-
Command line usage
664+
.. _idlelib-cli:
665+
666+
Command-line usage
665667
^^^^^^^^^^^^^^^^^^
666668

667669
.. program:: idle

Doc/library/inspect.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ Buffer flags
17881788

17891789
.. _inspect-module-cli:
17901790

1791-
Command Line Interface
1791+
Command-line interface
17921792
----------------------
17931793

17941794
The :mod:`inspect` module also provides a basic introspection capability

Doc/library/pdb.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ The debugger's prompt is ``(Pdb)``, which is the indicator that you are in debug
7676

7777

7878
.. _pdb-cli:
79+
80+
Command-line interface
81+
----------------------
82+
7983
.. program:: pdb
8084

8185
You can also invoke :mod:`pdb` from the command line to debug other scripts. For
@@ -334,7 +338,7 @@ access further features, you have to do this yourself:
334338

335339
.. _debugger-commands:
336340

337-
Debugger Commands
341+
Debugger commands
338342
-----------------
339343

340344
The commands recognized by the debugger are listed below. Most commands can be

Doc/library/profile.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ Profile with real-time sampling statistics::
265265

266266
Sample all threads in the process instead of just the main thread
267267

268+
.. option:: --native
269+
270+
Include artificial ``<native>`` frames to denote calls to non-Python code.
271+
272+
.. option:: --no-gc
273+
274+
Don't include artificial ``<GC>`` frames to denote active garbage collection.
275+
268276
.. option:: --realtime-stats
269277

270278
Print real-time sampling statistics during profiling
@@ -349,7 +357,7 @@ This section documents the programmatic interface for the :mod:`!profiling.sampl
349357
For command-line usage, see :ref:`sampling-profiler-cli`. For conceptual information
350358
about statistical profiling, see :ref:`statistical-profiling`
351359

352-
.. function:: sample(pid, *, sort=2, sample_interval_usec=100, duration_sec=10, filename=None, all_threads=False, limit=None, show_summary=True, output_format="pstats", realtime_stats=False)
360+
.. function:: sample(pid, *, sort=2, sample_interval_usec=100, duration_sec=10, filename=None, all_threads=False, limit=None, show_summary=True, output_format="pstats", realtime_stats=False, native=False, gc=True)
353361

354362
Sample a Python process and generate profiling data.
355363

@@ -367,6 +375,8 @@ about statistical profiling, see :ref:`statistical-profiling`
367375
:param bool show_summary: Whether to show summary statistics (default: True)
368376
:param str output_format: Output format - 'pstats' or 'collapsed' (default: 'pstats')
369377
:param bool realtime_stats: Whether to display real-time statistics (default: False)
378+
:param bool native: Whether to include ``<native>`` frames (default: False)
379+
:param bool gc: Whether to include ``<GC>`` frames (default: True)
370380

371381
:raises ValueError: If output_format is not 'pstats' or 'collapsed'
372382

0 commit comments

Comments
 (0)