aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/howto/regex.rst5
-rw-r--r--Doc/library/cmdline.rst2
-rw-r--r--Doc/library/curses.rst29
-rw-r--r--Doc/library/fnmatch.rst2
-rw-r--r--Doc/library/glob.rst2
-rw-r--r--Doc/library/io.rst3
-rw-r--r--Doc/library/platform.rst44
-rw-r--r--Doc/library/re.rst12
-rw-r--r--Doc/whatsnew/3.14.rst71
9 files changed, 145 insertions, 25 deletions
diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst
index 5e2f9a9d183..e543f6d5657 100644
--- a/Doc/howto/regex.rst
+++ b/Doc/howto/regex.rst
@@ -738,9 +738,12 @@ given location, they can obviously be matched an infinite number of times.
different: ``\A`` still matches only at the beginning of the string, but ``^``
may match at any location inside the string that follows a newline character.
-``\Z``
+``\z``
Matches only at the end of the string.
+``\Z``
+ The same as ``\z``. For compatibility with old Python versions.
+
``\b``
Word boundary. This is a zero-width assertion that matches only at the
beginning or end of a word. A word is defined as a sequence of alphanumeric
diff --git a/Doc/library/cmdline.rst b/Doc/library/cmdline.rst
index 85e82f6292a..f7ae2133a70 100644
--- a/Doc/library/cmdline.rst
+++ b/Doc/library/cmdline.rst
@@ -27,7 +27,7 @@ The following modules have a command-line interface.
* :mod:`pdb`
* :ref:`pickle <pickle-cli>`
* :ref:`pickletools <pickletools-cli>`
-* :mod:`platform`
+* :ref:`platform <platform-cli>`
* :mod:`poplib`
* :ref:`profile <profile-cli>`
* :mod:`pstats`
diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst
index 6c7fc721a3e..4bccfdde664 100644
--- a/Doc/library/curses.rst
+++ b/Doc/library/curses.rst
@@ -68,6 +68,21 @@ The module :mod:`curses` defines the following exception:
The module :mod:`curses` defines the following functions:
+.. function:: assume_default_colors(fg, bg)
+
+ Allow use of default values for colors on terminals supporting this feature.
+ Use this to support transparency in your application.
+
+ * Assign terminal default foreground/background colors to color number ``-1``.
+ So ``init_pair(x, COLOR_RED, -1)`` will initialize pair *x* as red
+ on default background and ``init_pair(x, -1, COLOR_BLUE)`` will
+ initialize pair *x* as default foreground on blue.
+
+ * Change the definition of the color-pair ``0`` to ``(fg, bg)``.
+
+ .. versionadded:: next
+
+
.. function:: baudrate()
Return the output speed of the terminal in bits per second. On software
@@ -290,9 +305,11 @@ The module :mod:`curses` defines the following functions:
Change the definition of a color-pair. It takes three arguments: the number of
the color-pair to be changed, the foreground color number, and the background
color number. The value of *pair_number* must be between ``1`` and
- ``COLOR_PAIRS - 1`` (the ``0`` color pair is wired to white on black and cannot
- be changed). The value of *fg* and *bg* arguments must be between ``0`` and
- ``COLORS - 1``, or, after calling :func:`use_default_colors`, ``-1``.
+ ``COLOR_PAIRS - 1`` (the ``0`` color pair can only be changed by
+ :func:`use_default_colors` and :func:`assume_default_colors`).
+ The value of *fg* and *bg* arguments must be between ``0`` and
+ ``COLORS - 1``, or, after calling :func:`!use_default_colors` or
+ :func:`!assume_default_colors`, ``-1``.
If the color-pair was previously initialized, the screen is
refreshed and all occurrences of that color-pair are changed to the new
definition.
@@ -678,11 +695,7 @@ The module :mod:`curses` defines the following functions:
.. function:: use_default_colors()
- Allow use of default values for colors on terminals supporting this feature. Use
- this to support transparency in your application. The default color is assigned
- to the color number ``-1``. After calling this function, ``init_pair(x,
- curses.COLOR_RED, -1)`` initializes, for instance, color pair *x* to a red
- foreground color on the default background.
+ Equivalent to ``assume_default_colors(-1, -1)``.
.. function:: wrapper(func, /, *args, **kwargs)
diff --git a/Doc/library/fnmatch.rst b/Doc/library/fnmatch.rst
index 8674e855b8e..12e61bc36f5 100644
--- a/Doc/library/fnmatch.rst
+++ b/Doc/library/fnmatch.rst
@@ -111,7 +111,7 @@ functions: :func:`fnmatch`, :func:`fnmatchcase`, :func:`.filter`.
>>>
>>> regex = fnmatch.translate('*.txt')
>>> regex
- '(?s:.*\\.txt)\\Z'
+ '(?s:.*\\.txt)\\z'
>>> reobj = re.compile(regex)
>>> reobj.match('foobar.txt')
<re.Match object; span=(0, 10), match='foobar.txt'>
diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst
index 684466d354a..59ad1b07f27 100644
--- a/Doc/library/glob.rst
+++ b/Doc/library/glob.rst
@@ -134,7 +134,7 @@ The :mod:`glob` module defines the following functions:
>>>
>>> regex = glob.translate('**/*.txt', recursive=True, include_hidden=True)
>>> regex
- '(?s:(?:.+/)?[^/]*\\.txt)\\Z'
+ '(?s:(?:.+/)?[^/]*\\.txt)\\z'
>>> reobj = re.compile(regex)
>>> reobj.match('foo/bar/baz.txt')
<re.Match object; span=(0, 15), match='foo/bar/baz.txt'>
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index fcd7afea354..3aa2f35f05e 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -965,7 +965,8 @@ Text I/O
:class:`TextIOBase`.
*encoding* gives the name of the encoding that the stream will be decoded or
- encoded with. It defaults to :func:`locale.getencoding`.
+ encoded with. In :ref:`UTF-8 Mode <utf8-mode>`, this defaults to UTF-8.
+ Otherwise, it defaults to :func:`locale.getencoding`.
``encoding="locale"`` can be used to specify the current locale's encoding
explicitly. See :ref:`io-text-encoding` for more information.
diff --git a/Doc/library/platform.rst b/Doc/library/platform.rst
index cfe1e7ba48d..5c999054323 100644
--- a/Doc/library/platform.rst
+++ b/Doc/library/platform.rst
@@ -17,7 +17,7 @@
section.
-Cross Platform
+Cross platform
--------------
@@ -188,7 +188,7 @@ Cross Platform
:attr:`processor` is resolved late instead of immediately.
-Java Platform
+Java platform
-------------
@@ -206,7 +206,7 @@ Java Platform
and was only useful for Jython support.
-Windows Platform
+Windows platform
----------------
@@ -240,7 +240,7 @@ Windows Platform
.. versionadded:: 3.8
-macOS Platform
+macOS platform
--------------
.. function:: mac_ver(release='', versioninfo=('','',''), machine='')
@@ -252,7 +252,7 @@ macOS Platform
Entries which cannot be determined are set to ``''``. All tuple entries are
strings.
-iOS Platform
+iOS platform
------------
.. function:: ios_ver(system='', release='', model='', is_simulator=False)
@@ -271,7 +271,7 @@ iOS Platform
parameters.
-Unix Platforms
+Unix platforms
--------------
.. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=16384)
@@ -287,7 +287,7 @@ Unix Platforms
The file is read and scanned in chunks of *chunksize* bytes.
-Linux Platforms
+Linux platforms
---------------
.. function:: freedesktop_os_release()
@@ -325,7 +325,7 @@ Linux Platforms
.. versionadded:: 3.10
-Android Platform
+Android platform
----------------
.. function:: android_ver(release="", api_level=0, manufacturer="", \
@@ -360,6 +360,34 @@ Android Platform
.. versionadded:: 3.13
+.. _platform-cli:
+
+Command-line usage
+------------------
+
+:mod:`platform` can also be invoked directly using the :option:`-m`
+switch of the interpreter::
+
+ python -m platform [--terse] [--nonaliased] [{nonaliased,terse} ...]
+
+The following options are accepted:
+
+.. program:: platform
+
+.. option:: --terse
+
+ Print terse information about the platform. This is equivalent to
+ calling :func:`platform.platform` with the *terse* argument set to ``True``.
+
+.. option:: --nonaliased
+
+ Print platform information without system/OS name aliasing. This is
+ equivalent to calling :func:`platform.platform` with the *aliased* argument
+ set to ``True``.
+
+You can also pass one or more positional arguments (``terse``, ``nonaliased``)
+to explicitly control the output format. These behave similarly to their
+corresponding options.
Miscellaneous
-------------
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index a91bac53fb4..0ee2d68bcbe 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -266,7 +266,7 @@ The special characters are:
not a word boundary as outside a set, and numeric escapes
such as ``\1`` are always octal escapes, not group references.
Special sequences which do not match a single character such as ``\A``
- and ``\Z`` are not allowed.
+ and ``\z`` are not allowed.
.. index:: single: ^ (caret); in regular expressions
@@ -661,11 +661,17 @@ character ``'$'``.
matches characters which are neither alphanumeric in the current locale
nor the underscore.
-.. index:: single: \Z; in regular expressions
+.. index:: single: \z; in regular expressions
+ single: \Z; in regular expressions
-``\Z``
+``\z``
Matches only at the end of the string.
+ .. versionadded:: next
+
+``\Z``
+ The same as ``\z``. For compatibility with old Python versions.
+
.. index::
single: \a; in regular expressions
single: \b; in regular expressions
diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst
index 2f8b652d47e..87c31d32e22 100644
--- a/Doc/whatsnew/3.14.rst
+++ b/Doc/whatsnew/3.14.rst
@@ -71,7 +71,12 @@ Summary -- release highlights
* :ref:`PEP 761: Discontinuation of PGP signatures <whatsnew314-pep761>`
* :ref:`PEP 765: Disallow return/break/continue that exit a finally block <whatsnew314-pep765>`
* :ref:`PEP 768: Safe external debugger interface for CPython <whatsnew314-pep768>`
-* :ref:`A new type of interpreter <whatsnew314-tail-call>`
+* :ref:`A new type of interpreter <whatsnew314-tail-call>`
+* :ref:`Syntax highlighting in PyREPL <whatsnew314-pyrepl-highlighting>`,
+ and color output in :ref:`unittest <whatsnew314-color-unittest>`,
+ :ref:`argparse <whatsnew314-color-argparse>`,
+ :ref:`json <whatsnew314-color-json>` and
+ :ref:`calendar <whatsnew314-color-calendar>` CLIs
Incompatible changes
@@ -474,6 +479,36 @@ Improved error messages
Traceback (most recent call last):
SyntaxError: invalid syntax. Is this intended to be part of the string?
+* When strings have incompatible prefixes, the error now shows
+ which prefixes are incompatible. (Contributed by
+ Nikita Sobolev in :gh:`133197`.)
+
+ .. code-block:: pycon
+
+ >>> ub'abc'
+ File "<python-input-0>", line 1
+ ub'abc'
+ ^^
+ SyntaxError: 'u' and 'b' prefixes are incompatible
+
+* Improved error messages when using ``as`` with incompatible targets in:
+
+ - Imports: ``import ... as ...``
+ - From imports: ``from ... import ... as ...``
+ - Except handlers: ``except ... as ...``
+ - Pattern-match cases: ``case ... as ...``
+
+ (Contributed by Nikita Sobolev in :gh:`123539`,
+ :gh:`123562`, and :gh:`123440`.)
+
+ .. code-block:: pycon
+
+ >>> import ast as arr[0]
+ File "<python-input-1>", line 1
+ import ast as arr[0]
+ ^^^^^^
+ SyntaxError: cannot use subscript as import target
+
.. _whatsnew314-pep741:
@@ -560,6 +595,9 @@ For further information on how to build Python, see
(Contributed by Ken Jin in :gh:`128563`, with ideas on how to implement this
in CPython by Mark Shannon, Garrett Gu, Haoran Xu, and Josh Haberman.)
+
+.. _whatsnew314-pyrepl-highlighting:
+
Syntax highlighting in PyREPL
-----------------------------
@@ -624,6 +662,11 @@ Other language changes
ASCII :class:`bytes` and :term:`bytes-like objects <bytes-like object>`.
(Contributed by Daniel Pope in :gh:`129349`.)
+* Support ``\z`` as a synonym for ``\Z`` in :mod:`regular expressions <re>`.
+ It is interpreted unambiguously in many other regular expression engines,
+ unlike ``\Z``, which has subtly different behavior.
+ (Contributed by Serhiy Storchaka in :gh:`133306`.)
+
* ``\B`` in :mod:`regular expression <re>` now matches empty input string.
Now it is always the opposite of ``\b``.
(Contributed by Serhiy Storchaka in :gh:`124130`.)
@@ -698,6 +741,17 @@ argparse
and subparser names if mistyped by the user.
(Contributed by Savannah Ostrowski in :gh:`124456`.)
+ .. _whatsnew314-color-argparse:
+
+* Introduced the optional *color* parameter to
+ :class:`argparse.ArgumentParser`, enabling color for help text.
+ This can be controlled via the :envvar:`PYTHON_COLORS` environment
+ variable as well as the canonical |NO_COLOR|_
+ and |FORCE_COLOR|_ environment variables.
+ See also :ref:`using-on-controlling-color`.
+ (Contributed by Hugo van Kemenade in :gh:`130645`.)
+
+
ast
---
@@ -723,6 +777,9 @@ bdb
* The :mod:`bdb` module now supports the :mod:`sys.monitoring` backend.
(Contributed by Tian Gao in :gh:`124533`.)
+
+ .. _whatsnew314-color-calendar:
+
calendar
--------
@@ -834,6 +891,14 @@ ctypes
making it a :term:`generic type`.
(Contributed by Brian Schubert in :gh:`132168`.)
+curses
+------
+
+* Add the :func:`~curses.assume_default_colors` function,
+ a refinement of the :func:`~curses.use_default_colors` function which
+ allows to change the color pair ``0``.
+ (Contributed by Serhiy Storchaka in :gh:`133139`.)
+
datetime
--------
@@ -1021,6 +1086,8 @@ json
See the :ref:`JSON command-line interface <json-commandline>` documentation.
(Contributed by Trey Hunner in :gh:`122873`.)
+ .. _whatsnew314-color-json:
+
* By default, the output of the :ref:`JSON command-line interface <json-commandline>`
is highlighted in color. This can be controlled via the
:envvar:`PYTHON_COLORS` environment variable as well as the canonical
@@ -1467,6 +1534,8 @@ unicodedata
* The Unicode database has been updated to Unicode 16.0.0.
+.. _whatsnew314-color-unittest:
+
unittest
--------