Skip to content

Commit 89e46c7

Browse files
Merge branch 'main' into asyncio-perf
2 parents c84e757 + 5b969fd commit 89e46c7

Some content is hidden

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

43 files changed

+619
-310
lines changed

Doc/c-api/float.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ There are two problems on non-IEEE platforms:
124124
* What this does is undefined if *x* is a NaN or infinity.
125125
* ``-0.0`` and ``+0.0`` produce the same bytes string.
126126
127-
.. c:function:: int PyFloat_Pack2(double x, unsigned char *p, int le)
127+
.. c:function:: int PyFloat_Pack2(double x, char *p, int le)
128128
129129
Pack a C double as the IEEE 754 binary16 half-precision format.
130130
131-
.. c:function:: int PyFloat_Pack4(double x, unsigned char *p, int le)
131+
.. c:function:: int PyFloat_Pack4(double x, char *p, int le)
132132
133133
Pack a C double as the IEEE 754 binary32 single precision format.
134134
135-
.. c:function:: int PyFloat_Pack8(double x, unsigned char *p, int le)
135+
.. c:function:: int PyFloat_Pack8(double x, char *p, int le)
136136
137137
Pack a C double as the IEEE 754 binary64 double precision format.
138138
@@ -154,14 +154,14 @@ Return value: The unpacked double. On error, this is ``-1.0`` and
154154
Note that on a non-IEEE platform this will refuse to unpack a bytes string that
155155
represents a NaN or infinity.
156156
157-
.. c:function:: double PyFloat_Unpack2(const unsigned char *p, int le)
157+
.. c:function:: double PyFloat_Unpack2(const char *p, int le)
158158
159159
Unpack the IEEE 754 binary16 half-precision format as a C double.
160160
161-
.. c:function:: double PyFloat_Unpack4(const unsigned char *p, int le)
161+
.. c:function:: double PyFloat_Unpack4(const char *p, int le)
162162
163163
Unpack the IEEE 754 binary32 single precision format as a C double.
164164
165-
.. c:function:: double PyFloat_Unpack8(const unsigned char *p, int le)
165+
.. c:function:: double PyFloat_Unpack8(const char *p, int le)
166166
167167
Unpack the IEEE 754 binary64 double precision format as a C double.

Doc/c-api/init_config.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,7 @@ PyPreConfig
975975
Set to ``0`` or ``1`` by the :option:`-X utf8 <-X>` command line option
976976
and the :envvar:`PYTHONUTF8` environment variable.
977977
978-
Also set to ``1`` if the ``LC_CTYPE`` locale is ``C`` or ``POSIX``.
979-
980-
Default: ``-1`` in Python config and ``0`` in isolated config.
978+
Default: ``1``.
981979
982980
983981
.. _c-preinit:

Doc/library/email.parser.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ methods.
4848
FeedParser API
4949
^^^^^^^^^^^^^^
5050

51-
The :class:`BytesFeedParser`, imported from the :mod:`email.parser.FeedParser`
52-
module, provides an API that is conducive to incremental parsing of email messages,
51+
The :class:`BytesFeedParser`, imported from the :mod:`email.feedparser` module,
52+
provides an API that is conducive to incremental parsing of email messages,
5353
such as would be necessary when reading the text of an email message from a
5454
source that can block (such as a socket). The :class:`BytesFeedParser` can of
5555
course be used to parse an email message fully contained in a :term:`bytes-like
@@ -155,7 +155,7 @@ message body, instead setting the payload to the raw body.
155155

156156
Read all the data from the binary file-like object *fp*, parse the
157157
resulting bytes, and return the message object. *fp* must support
158-
both the :meth:`~io.IOBase.readline` and the :meth:`~io.TextIOBase.read`
158+
both the :meth:`~io.IOBase.readline` and the :meth:`~io.IOBase.read`
159159
methods.
160160

161161
The bytes contained in *fp* must be formatted as a block of :rfc:`5322`

Doc/library/os.rst

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ Python UTF-8 Mode
108108
.. versionadded:: 3.7
109109
See :pep:`540` for more details.
110110

111+
.. versionchanged:: next
112+
113+
Python UTF-8 mode is now enabled by default (:pep:`686`).
114+
It may be disabled with by setting :envvar:`PYTHONUTF8=0 <PYTHONUTF8>` as
115+
an environment variable or by using the :option:`-X utf8=0 <-X>` command line option.
116+
111117
The Python UTF-8 Mode ignores the :term:`locale encoding` and forces the usage
112118
of the UTF-8 encoding:
113119

@@ -139,31 +145,22 @@ level APIs also exhibit different default behaviours:
139145
default so that attempting to open a binary file in text mode is likely
140146
to raise an exception rather than producing nonsense data.
141147

142-
The :ref:`Python UTF-8 Mode <utf8-mode>` is enabled if the LC_CTYPE locale is
143-
``C`` or ``POSIX`` at Python startup (see the :c:func:`PyConfig_Read`
144-
function).
145-
146-
It can be enabled or disabled using the :option:`-X utf8 <-X>` command line
147-
option and the :envvar:`PYTHONUTF8` environment variable.
148-
149-
If the :envvar:`PYTHONUTF8` environment variable is not set at all, then the
150-
interpreter defaults to using the current locale settings, *unless* the current
151-
locale is identified as a legacy ASCII-based locale (as described for
152-
:envvar:`PYTHONCOERCECLOCALE`), and locale coercion is either disabled or
153-
fails. In such legacy locales, the interpreter will default to enabling UTF-8
154-
mode unless explicitly instructed not to do so.
155-
156-
The Python UTF-8 Mode can only be enabled at the Python startup. Its value
148+
The :ref:`Python UTF-8 Mode <utf8-mode>` is enabled by default.
149+
It can be disabled using the :option:`-X utf8=0 <-X>` command line
150+
option or the :envvar:`PYTHONUTF8=0 <PYTHONUTF8>` environment variable.
151+
The Python UTF-8 Mode can only be disabled at Python startup. Its value
157152
can be read from :data:`sys.flags.utf8_mode <sys.flags>`.
158153

154+
If the UTF-8 mode is disabled, the interpreter defaults to using
155+
the current locale settings, *unless* the current locale is identified
156+
as a legacy ASCII-based locale (as described for :envvar:`PYTHONCOERCECLOCALE`),
157+
and locale coercion is either disabled or fails.
158+
In such legacy locales, the interpreter will default to enabling UTF-8 mode
159+
unless explicitly instructed not to do so.
160+
159161
See also the :ref:`UTF-8 mode on Windows <win-utf8-mode>`
160162
and the :term:`filesystem encoding and error handler`.
161163

162-
.. seealso::
163-
164-
:pep:`686`
165-
Python 3.15 will make :ref:`utf8-mode` default.
166-
167164

168165
.. _os-procinfo:
169166

Doc/library/test.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,13 @@ The :mod:`test.support.threading_helper` module provides support for threading t
13841384
.. versionadded:: 3.8
13851385

13861386

1387+
.. function:: run_concurrently(worker_func, nthreads, args=(), kwargs={})
1388+
1389+
Run the worker function concurrently in multiple threads.
1390+
Re-raises an exception if any thread raises one, after all threads have
1391+
finished.
1392+
1393+
13871394
:mod:`test.support.os_helper` --- Utilities for os tests
13881395
========================================================================
13891396

Doc/tools/.nitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Doc/extending/extending.rst
1515
Doc/library/ast.rst
1616
Doc/library/asyncio-extending.rst
1717
Doc/library/email.charset.rst
18+
Doc/library/email.parser.rst
1819
Doc/library/http.cookiejar.rst
1920
Doc/library/http.server.rst
2021
Doc/library/importlib.rst

Doc/using/windows.rst

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,9 @@ UTF-8 mode
10061006
==========
10071007

10081008
.. versionadded:: 3.7
1009+
.. versionchanged:: next
1010+
1011+
Python UTF-8 mode is now enabled by default (:pep:`686`).
10091012

10101013
Windows still uses legacy encodings for the system encoding (the ANSI Code
10111014
Page). Python uses it for the default encoding of text files (e.g.
@@ -1014,20 +1017,22 @@ Page). Python uses it for the default encoding of text files (e.g.
10141017
This may cause issues because UTF-8 is widely used on the internet
10151018
and most Unix systems, including WSL (Windows Subsystem for Linux).
10161019

1017-
You can use the :ref:`Python UTF-8 Mode <utf8-mode>` to change the default text
1018-
encoding to UTF-8. You can enable the :ref:`Python UTF-8 Mode <utf8-mode>` via
1019-
the ``-X utf8`` command line option, or the ``PYTHONUTF8=1`` environment
1020-
variable. See :envvar:`PYTHONUTF8` for enabling UTF-8 mode, and
1021-
:ref:`setting-envvars` for how to modify environment variables.
1022-
1023-
When the :ref:`Python UTF-8 Mode <utf8-mode>` is enabled, you can still use the
1020+
The :ref:`Python UTF-8 Mode <utf8-mode>`, enabled by default, can help by
1021+
changing the default text encoding to UTF-8.
1022+
When the :ref:`UTF-8 mode <utf8-mode>` is enabled, you can still use the
10241023
system encoding (the ANSI Code Page) via the "mbcs" codec.
10251024

1026-
Note that adding ``PYTHONUTF8=1`` to the default environment variables
1027-
will affect all Python 3.7+ applications on your system.
1028-
If you have any Python 3.7+ applications which rely on the legacy
1029-
system encoding, it is recommended to set the environment variable
1030-
temporarily or use the ``-X utf8`` command line option.
1025+
You can disable the :ref:`Python UTF-8 Mode <utf8-mode>` via
1026+
the ``-X utf8=0`` command line option, or the ``PYTHONUTF8=0`` environment
1027+
variable. See :envvar:`PYTHONUTF8` for disabling UTF-8 mode, and
1028+
:ref:`setting-envvars` for how to modify environment variables.
1029+
1030+
.. hint::
1031+
Adding ``PYTHONUTF8={0,1}`` to the default environment variables
1032+
will affect all Python 3.7+ applications on your system.
1033+
If you have any Python 3.7+ applications which rely on the legacy
1034+
system encoding, it is recommended to set the environment variable
1035+
temporarily or use the ``-X utf8`` command line option.
10311036

10321037
.. note::
10331038
Even when UTF-8 mode is disabled, Python uses UTF-8 by default

Doc/whatsnew/3.15.rst

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,35 @@ production systems where traditional profiling approaches would be too intrusive
172172
Other language changes
173173
======================
174174

175+
* Python now uses UTF-8_ as the default encoding, independent of the system's
176+
environment. This means that I/O operations without an explicit encoding,
177+
e.g. ``open('flying-circus.txt')``, will use UTF-8.
178+
UTF-8 is a widely-supported Unicode_ character encoding that has become a
179+
*de facto* standard for representing text, including nearly every webpage
180+
on the internet, many common file formats, programming languages, and more.
181+
182+
This only applies when no ``encoding`` argument is given. For best
183+
compatibility between versions of Python, ensure that an explicit ``encoding``
184+
argument is always provided. The :ref:`opt-in encoding warning <io-encoding-warning>`
185+
can be used to identify code that may be affected by this change.
186+
The special special ``encoding='locale'`` argument uses the current locale
187+
encoding, and has been supported since Python 3.10.
188+
189+
To retain the previous behaviour, Python's UTF-8 mode may be disabled with
190+
the :envvar:`PYTHONUTF8=0 <PYTHONUTF8>` environment variable or the
191+
:option:`-X utf8=0 <-X>` command line option.
192+
193+
.. seealso:: :pep:`686` for further details.
194+
195+
.. _UTF-8: https://en.wikipedia.org/wiki/UTF-8
196+
.. _Unicode: https://home.unicode.org/
197+
198+
(Contributed by Adam Turner in :gh:`133711`; PEP 686 written by Inada Naoki.)
199+
175200
* Several error messages incorrectly using the term "argument" have been corrected.
176201
(Contributed by Stan Ulbrych in :gh:`133382`.)
177202

178203

179-
180204
New modules
181205
===========
182206

@@ -278,6 +302,14 @@ tarfile
278302
and :cve:`2025-4435`.)
279303

280304

305+
unittest
306+
--------
307+
308+
* :func:`unittest.TestCase.assertLogs` will now accept a formatter
309+
to control how messages are formatted.
310+
(Contributed by Garry Cairns in :gh:`134567`.)
311+
312+
281313
zlib
282314
----
283315

@@ -388,15 +420,6 @@ typing
388420
(Contributed by Bénédikt Tran in :gh:`133823`.)
389421

390422

391-
unittest
392-
--------
393-
394-
* Lets users specify formatter in TestCase.assertLogs.
395-
:func:`unittest.TestCase.assertLogs` will now accept a formatter
396-
to control how messages are formatted.
397-
(Contributed by Garry Cairns in :gh:`134567`.)
398-
399-
400423
wave
401424
----
402425

Include/cpython/initconfig.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,14 @@ typedef struct PyPreConfig {
102102

103103
/* Enable UTF-8 mode? (PEP 540)
104104
105-
Disabled by default (equals to 0).
105+
If equal to 1, use the UTF-8 encoding and use "surrogateescape" for the
106+
stdin & stdout error handlers.
106107
107-
Set to 1 by "-X utf8" and "-X utf8=1" command line options.
108-
Set to 1 by PYTHONUTF8=1 environment variable.
108+
Enabled by default (equal to 1; PEP 686), or if Py_UTF8Mode=1,
109+
or if "-X utf8=1" or PYTHONUTF8=1.
109110
110-
Set to 0 by "-X utf8=0" and PYTHONUTF8=0.
111-
112-
If equals to -1, it is set to 1 if the LC_CTYPE locale is "C" or
113-
"POSIX", otherwise it is set to 0. Inherit Py_UTF8Mode value value. */
111+
Set to 0 by "-X utf8=0" or PYTHONUTF8=0.
112+
*/
114113
int utf8_mode;
115114

116115
/* If non-zero, enable the Python Development Mode.

Include/fileutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# define S_IFMT 0170000
1717
#endif
1818
#ifndef S_IFLNK
19-
// Windows doesn't define S_IFLNK, but posixmodule.c maps
19+
// Windows doesn't define S_IFLNK, but fileutils.c maps
2020
// IO_REPARSE_TAG_SYMLINK to S_IFLNK.
2121
# define S_IFLNK 0120000
2222
#endif

0 commit comments

Comments
 (0)