Skip to content

Commit

Permalink
Merge branch 'main' into icompexc
Browse files Browse the repository at this point in the history
* main:
  pythongh-108520: Fix bad fork detection in nested multiprocessing use case (python#108568)
  pythongh-108590: Revert pythongh-108657 (commit 400a1ce) (python#108686)
  pythongh-108494: Argument Clinic: Document how to generate code that uses the limited C API (python#108584)
  Document Python build requirements (python#108646)
  pythongh-101100: Fix Sphinx warnings in the Logging Cookbook (python#108678)
  Fix typo in multiprocessing docs (python#108666)
  pythongh-108669: unittest: Fix documentation for TestResult.collectedDurations (python#108670)
  pythongh-108590: Fix sqlite3.iterdump for invalid Unicode in TEXT columns (python#108657)
  Revert "pythongh-103224: Use the realpath of the Python executable in `test_venv` (pythonGH-103243)" (pythonGH-108667)
  pythongh-106320: Remove private _Py_ForgetReference() (python#108664)
  Mention Ellipsis pickling in the docs (python#103660)
  Revert "Use non alternate name for Kyiv (pythonGH-108533)" (pythonGH-108649)
  pythongh-108278: Deprecate passing the first param of sqlite3.Connection callback APIs by keyword (python#108632)
  pythongh-108455: peg_generator: install two stubs packages before running mypy (python#108637)
  pythongh-107801: Improve the accuracy of io.IOBase.seek docs (python#108268)
  • Loading branch information
carljm committed Aug 30, 2023
2 parents 8e8b41f + add8d45 commit 37377e6
Show file tree
Hide file tree
Showing 29 changed files with 351 additions and 72 deletions.
23 changes: 22 additions & 1 deletion Doc/howto/clinic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ process a single source file, like this:
The CLI supports the following options:

.. program:: ./Tools/clinic/clinic.py [-h] [-f] [-o OUTPUT] [-v] \
[--converters] [--make] [--srcdir SRCDIR] [FILE ...]
[--converters] [--make] [--srcdir SRCDIR] [--limited] [FILE ...]

.. option:: -h, --help

Expand Down Expand Up @@ -193,6 +193,11 @@ The CLI supports the following options:
A file to exclude in :option:`--make` mode.
This option can be given multiple times.

.. option:: --limited

Use the :ref:`Limited API <limited-c-api>` to parse arguments in the generated C code.
See :ref:`clinic-howto-limited-capi`.

.. option:: FILE ...

The list of files to process.
Expand Down Expand Up @@ -1905,6 +1910,22 @@ blocks embedded in Python files look slightly different. They look like this:
#/*[python checksum:...]*/
.. _clinic-howto-limited-capi:

How to use the Limited C API
----------------------------

If Argument Clinic :term:`input` is located within a C source file
that contains ``#define Py_LIMITED_API``, Argument Clinic will generate C code
that uses the :ref:`Limited API <limited-c-api>` to parse arguments. The
advantage of this is that the generated code will not use private functions.
However, this *can* result in Argument Clinic generating less efficient code
in some cases. The extent of the performance penalty will depend
on the parameters (types, number, etc.).

.. versionadded:: 3.13


.. _clinic-howto-override-signature:

How to override the generated signature
Expand Down
15 changes: 11 additions & 4 deletions Doc/howto/logging-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ printed on the console; on the server side, you should see something like:
Note that there are some security issues with pickle in some scenarios. If
these affect you, you can use an alternative serialization scheme by overriding
the :meth:`~handlers.SocketHandler.makePickle` method and implementing your
the :meth:`~SocketHandler.makePickle` method and implementing your
alternative there, as well as adapting the above script to use your alternative
serialization.

Expand Down Expand Up @@ -835,6 +835,8 @@ To test these files, do the following in a POSIX environment:
You may need to tweak the configuration files in the unlikely event that the
configured ports clash with something else in your test environment.

.. currentmodule:: logging

.. _context-info:

Adding contextual information to your logging output
Expand Down Expand Up @@ -1546,7 +1548,7 @@ Sometimes you want to let a log file grow to a certain size, then open a new
file and log to that. You may want to keep a certain number of these files, and
when that many files have been created, rotate the files so that the number of
files and the size of the files both remain bounded. For this usage pattern, the
logging package provides a :class:`~handlers.RotatingFileHandler`::
logging package provides a :class:`RotatingFileHandler`::

import glob
import logging
Expand Down Expand Up @@ -1594,6 +1596,8 @@ and each time it reaches the size limit it is renamed with the suffix
Obviously this example sets the log length much too small as an extreme
example. You would want to set *maxBytes* to an appropriate value.

.. currentmodule:: logging

.. _format-styles:

Use of alternative formatting styles
Expand Down Expand Up @@ -1840,6 +1844,7 @@ However, it should be borne in mind that each link in the chain adds run-time
overhead to all logging operations, and the technique should only be used when
the use of a :class:`Filter` does not provide the desired result.

.. currentmodule:: logging.handlers

.. _zeromq-handlers:

Expand Down Expand Up @@ -1917,6 +1922,8 @@ of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::
:ref:`A more advanced logging tutorial <logging-advanced-tutorial>`


.. currentmodule:: logging

An example dictionary-based configuration
-----------------------------------------

Expand Down Expand Up @@ -3918,8 +3925,8 @@ that in other languages such as Java and C#, loggers are often static class
attributes. However, this pattern doesn't make sense in Python, where the
module (and not the class) is the unit of software decomposition.

Adding handlers other than :class:`NullHandler` to a logger in a library
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Adding handlers other than :class:`~logging.NullHandler` to a logger in a library
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Configuring logging by adding handlers, formatters and filters is the
responsibility of the application developer, not the library developer. If you
Expand Down
26 changes: 14 additions & 12 deletions Doc/library/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -403,20 +403,19 @@ I/O Base Classes
Note that it's already possible to iterate on file objects using ``for
line in file: ...`` without calling :meth:`!file.readlines`.

.. method:: seek(offset, whence=SEEK_SET, /)
.. method:: seek(offset, whence=os.SEEK_SET, /)

Change the stream position to the given byte *offset*. *offset* is
interpreted relative to the position indicated by *whence*. The default
value for *whence* is :data:`!SEEK_SET`. Values for *whence* are:
Change the stream position to the given byte *offset*,
interpreted relative to the position indicated by *whence*,
and return the new absolute position.
Values for *whence* are:

* :data:`!SEEK_SET` or ``0`` -- start of the stream (the default);
* :data:`os.SEEK_SET` or ``0`` -- start of the stream (the default);
*offset* should be zero or positive
* :data:`!SEEK_CUR` or ``1`` -- current stream position; *offset* may
be negative
* :data:`!SEEK_END` or ``2`` -- end of the stream; *offset* is usually
negative

Return the new absolute position.
* :data:`os.SEEK_CUR` or ``1`` -- current stream position;
*offset* may be negative
* :data:`os.SEEK_END` or ``2`` -- end of the stream;
*offset* is usually negative

.. versionadded:: 3.1
The :data:`!SEEK_*` constants.
Expand Down Expand Up @@ -1061,14 +1060,17 @@ Text I/O
Any other argument combinations are invalid,
and may raise exceptions.

.. seealso::

:data:`os.SEEK_SET`, :data:`os.SEEK_CUR`, and :data:`os.SEEK_END`.

.. method:: tell()

Return the stream position as an opaque number.
The return value of :meth:`!tell` can be given as input to :meth:`seek`,
to restore a previous stream position.



.. class:: StringIO(initial_value='', newline='\n')

A text stream using an in-memory text buffer. It inherits
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2988,7 +2988,7 @@ Global variables
Safe importing of main module

Make sure that the main module can be safely imported by a new Python
interpreter without causing unintended side effects (such a starting a new
interpreter without causing unintended side effects (such as starting a new
process).

For example, using the *spawn* or *forkserver* start method
Expand Down
3 changes: 2 additions & 1 deletion Doc/library/pickle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ What can be pickled and unpickled?

The following types can be pickled:

* ``None``, ``True``, and ``False``;
* built-in constants (``None``, ``True``, ``False``, ``Ellipsis``, and
``NotImplemented``);

* integers, floating-point numbers, complex numbers;

Expand Down
27 changes: 21 additions & 6 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,10 @@ Connection objects
... print(row)
('acbd18db4cc2f85cedef654fccc4a4d8',)

.. versionchanged:: 3.13
.. versionchanged:: 3.13

Passing *name*, *narg*, and *func* as keyword arguments is deprecated.
These parameters will become positional-only in Python 3.15.
Passing *name*, *narg*, and *func* as keyword arguments is deprecated.
These parameters will become positional-only in Python 3.15.


.. method:: create_aggregate(name, n_arg, aggregate_class)
Expand Down Expand Up @@ -822,10 +822,10 @@ Connection objects

3

.. versionchanged:: 3.13
.. versionchanged:: 3.13

Passing *name*, *n_arg*, and *aggregate_class* as keyword arguments is deprecated.
These parameters will become positional-only in Python 3.15.
Passing *name*, *n_arg*, and *aggregate_class* as keyword arguments is deprecated.
These parameters will become positional-only in Python 3.15.


.. method:: create_window_function(name, num_params, aggregate_class, /)
Expand Down Expand Up @@ -991,6 +991,11 @@ Connection objects
.. versionchanged:: 3.11
Added support for disabling the authorizer using ``None``.

.. versionchanged:: 3.13

Passing *authorizer_callback* as a keyword argument to is deprecated.
The parameter will become positional-only in Python 3.15.


.. method:: set_progress_handler(progress_handler, n)

Expand All @@ -1006,6 +1011,11 @@ Connection objects
currently executing query and cause it to raise a :exc:`DatabaseError`
exception.

.. versionchanged:: 3.13

Passing *progress_handler* as a keyword argument to is deprecated.
The parameter will become positional-only in Python 3.15.


.. method:: set_trace_callback(trace_callback)

Expand All @@ -1030,6 +1040,11 @@ Connection objects

.. versionadded:: 3.3

.. versionchanged:: 3.13

Passing *trace_callback* as a keyword argument to is deprecated.
The parameter will become positional-only in Python 3.15.


.. method:: enable_load_extension(enabled, /)

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/unittest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ Loading and running tests

.. attribute:: collectedDurations

A list containing 2-tuples of :class:`TestCase` instances and floats
A list containing 2-tuples of test case names and floats
representing the elapsed time of each test which was run.

.. versionadded:: 3.12
Expand Down
1 change: 0 additions & 1 deletion Doc/tools/.nitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Doc/glossary.rst
Doc/howto/descriptor.rst
Doc/howto/enum.rst
Doc/howto/isolating-extensions.rst
Doc/howto/logging-cookbook.rst
Doc/howto/logging.rst
Doc/howto/urllib2.rst
Doc/library/__future__.rst
Expand Down
27 changes: 22 additions & 5 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,42 @@ Configure Python
Build Requirements
==================

Features required to build CPython:
Features and minimum versions required to build CPython:

* A `C11 <https://en.cppreference.com/w/c/11>`_ compiler. `Optional C11
features
<https://en.wikipedia.org/wiki/C11_(C_standard_revision)#Optional_features>`_
are not required.

* On Windows, Microsoft Visual Studio 2017 or later is required.

* Support for `IEEE 754 <https://en.wikipedia.org/wiki/IEEE_754>`_ floating
point numbers and `floating point Not-a-Number (NaN)
<https://en.wikipedia.org/wiki/NaN#Floating_point>`_.

* Support for threads.

* OpenSSL 1.1.1 or newer for the :mod:`ssl` and :mod:`hashlib` modules.
* OpenSSL 1.1.1 is the minimum version and OpenSSL 3.0.9 is the recommended
minimum version for the :mod:`ssl` and :mod:`hashlib` extension modules.

* On Windows, Microsoft Visual Studio 2017 or later is required.
* SQLite 3.15.2 for the :mod:`sqlite3` extension module.

* Tcl/Tk 8.5.12 for the :mod:`tkinter` module.

* Autoconf 2.71 and aclocal 1.16.4 are required to regenerate the
:file:`configure` script.

.. versionchanged:: 3.13:
Autoconf 2.71, aclocal 1.16.4 and SQLite 3.15.2 are now required.

.. versionchanged:: 3.11
C11 compiler, IEEE 754 and NaN support are now required.
On Windows, Visual Studio 2017 or later is required.
Tcl/Tk version 8.5.12 is now required for the :mod:`tkinter` module.

.. versionchanged:: 3.10
OpenSSL 1.1.1 is now required.
Require SQLite 3.7.15.

.. versionchanged:: 3.7
Thread support and OpenSSL 1.0.2 are now required.
Expand All @@ -37,7 +50,11 @@ Features required to build CPython:
inline`` functions.

.. versionchanged:: 3.5
On Windows, Visual Studio 2015 or later is required.
On Windows, Visual Studio 2015 or later is now required.
Tcl/Tk version 8.4 is now required.

.. versionchanged:: 3.1
Tcl/Tk version 8.3.1 is now required.

See also :pep:`7` "Style Guide for C Code" and :pep:`11` "CPython platform
support".
Expand All @@ -48,7 +65,7 @@ support".
Configure Options
=================

List all ``./configure`` script options using::
List all :file:`configure` script options using::

./configure --help

Expand Down
9 changes: 8 additions & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ Deprecated
* :meth:`~sqlite3.Connection.create_function`
* :meth:`~sqlite3.Connection.create_aggregate`

Deprecate passing the callback callable by keyword for the following
:class:`sqlite3.Connection` APIs:

* :meth:`~sqlite3.Connection.set_authorizer`
* :meth:`~sqlite3.Connection.set_progress_handler`
* :meth:`~sqlite3.Connection.set_trace_callback`

The affected parameters will become positional-only in Python 3.15.

(Contributed by Erlend E. Aasland in :gh:`107948` and :gh:`108278`.)
Expand Down Expand Up @@ -815,7 +822,7 @@ Build Changes
=============

* Autoconf 2.71 and aclocal 1.16.4 is now required to regenerate
:file:`!configure`.
the :file:`configure` script.
(Contributed by Christian Heimes in :gh:`89886`.)

* SQLite 3.15.2 or newer is required to build the :mod:`sqlite3` extension module.
Expand Down
5 changes: 0 additions & 5 deletions Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
PyAPI_FUNC(void) _Py_NewReference(PyObject *op);
PyAPI_FUNC(void) _Py_NewReferenceNoTotal(PyObject *op);

#ifdef Py_TRACE_REFS
/* Py_TRACE_REFS is such major surgery that we call external routines. */
PyAPI_FUNC(void) _Py_ForgetReference(PyObject *);
#endif

#ifdef Py_REF_DEBUG
/* These are useful as debugging aids when chasing down refleaks. */
PyAPI_FUNC(Py_ssize_t) _Py_GetGlobalRefTotal(void);
Expand Down
5 changes: 5 additions & 0 deletions Include/internal/pycore_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ extern void _PyDebugAllocatorStats(FILE *out, const char *block_name,

extern void _PyObject_DebugTypeStats(FILE *out);

#ifdef Py_TRACE_REFS
/* Py_TRACE_REFS is such major surgery that we call external routines. */
PyAPI_FUNC(void) _Py_ForgetReference(PyObject *);
#endif

// Export for shared _testinternalcapi extension
PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);

Expand Down
Loading

0 comments on commit 37377e6

Please sign in to comment.