Skip to content

Commit 3b9c5dc

Browse files
authored
Merge branch '3.13' into backport-9d63ae5-3.13
2 parents 537e6f6 + de27372 commit 3b9c5dc

37 files changed

+433
-116
lines changed

Doc/c-api/module.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,6 @@ state:
523523
524524
On success, return ``0``. On error, raise an exception and return ``-1``.
525525
526-
Return ``-1`` if *value* is ``NULL``. It must be called with an exception
527-
raised in this case.
528-
529526
Example usage::
530527
531528
static int
@@ -540,6 +537,10 @@ state:
540537
return res;
541538
}
542539
540+
To be convenient, the function accepts ``NULL`` *value* with an exception
541+
set. In this case, return ``-1`` and just leave the raised exception
542+
unchanged.
543+
543544
The example can also be written without checking explicitly if *obj* is
544545
``NULL``::
545546

Doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
'changes',
2929
'glossary_search',
3030
'lexers',
31+
'misc_news',
3132
'pyspecific',
3233
'sphinx.ext.coverage',
3334
'sphinx.ext.doctest',

Doc/library/exceptions.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,13 @@ The following exceptions are the exceptions that are usually raised.
562562

563563
Raised when the interpreter finds an internal error, but the situation does not
564564
look so serious to cause it to abandon all hope. The associated value is a
565-
string indicating what went wrong (in low-level terms).
565+
string indicating what went wrong (in low-level terms). In :term:`CPython`,
566+
this could be raised by incorrectly using Python's C API, such as returning
567+
a ``NULL`` value without an exception set.
566568

567-
You should report this to the author or maintainer of your Python interpreter.
569+
If you're confident that this exception wasn't your fault, or the fault of
570+
a package you're using, you should report this to the author or maintainer
571+
of your Python interpreter.
568572
Be sure to report the version of the Python interpreter (``sys.version``; it is
569573
also printed at the start of an interactive Python session), the exact error
570574
message (the exception's associated value) and if possible the source of the

Doc/license.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ Project, https://www.wide.ad.jp/. ::
374374
may be used to endorse or promote products derived from this software
375375
without specific prior written permission.
376376

377-
THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
377+
THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS "AS IS" AND
378378
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
379379
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
380380
ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
@@ -583,7 +583,7 @@ interface::
583583
notice, this list of conditions and the following disclaimer in the
584584
documentation and/or other materials provided with the distribution.
585585

586-
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
586+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
587587
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
588588
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
589589
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
@@ -884,7 +884,7 @@ sources unless the build is configured ``--with-system-libffi``::
884884

885885
Permission is hereby granted, free of charge, to any person obtaining
886886
a copy of this software and associated documentation files (the
887-
``Software''), to deal in the Software without restriction, including
887+
"Software"), to deal in the Software without restriction, including
888888
without limitation the rights to use, copy, modify, merge, publish,
889889
distribute, sublicense, and/or sell copies of the Software, and to
890890
permit persons to whom the Software is furnished to do so, subject to
@@ -893,7 +893,7 @@ sources unless the build is configured ``--with-system-libffi``::
893893
The above copyright notice and this permission notice shall be included
894894
in all copies or substantial portions of the Software.
895895

896-
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
896+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
897897
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
898898
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
899899
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
@@ -1122,7 +1122,7 @@ The file is distributed under the 2-Clause BSD License::
11221122
notice, this list of conditions and the following disclaimer in the
11231123
documentation and/or other materials provided with the distribution.
11241124

1125-
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1125+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
11261126
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
11271127
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11281128
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,

Doc/make.bat

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,14 @@ goto end
127127
:build
128128
if not exist "%BUILDDIR%" mkdir "%BUILDDIR%"
129129

130-
rem PY_MISC_NEWS_DIR is also used by our Sphinx extension in tools/extensions/pyspecific.py
131-
if not defined PY_MISC_NEWS_DIR set PY_MISC_NEWS_DIR=%BUILDDIR%\%1
132-
if not exist "%PY_MISC_NEWS_DIR%" mkdir "%PY_MISC_NEWS_DIR%"
130+
if not exist build mkdir build
133131
if exist ..\Misc\NEWS (
134-
echo.Copying Misc\NEWS to %PY_MISC_NEWS_DIR%\NEWS
135-
copy ..\Misc\NEWS "%PY_MISC_NEWS_DIR%\NEWS" > nul
132+
echo.Copying existing Misc\NEWS file to Doc\build\NEWS
133+
copy ..\Misc\NEWS build\NEWS > nul
136134
) else if exist ..\Misc\NEWS.D (
137135
if defined BLURB (
138136
echo.Merging Misc/NEWS with %BLURB%
139-
%BLURB% merge -f "%PY_MISC_NEWS_DIR%\NEWS"
137+
%BLURB% merge -f build\NEWS
140138
) else (
141139
echo.No Misc/NEWS file and Blurb is not available.
142140
exit /B 1

Doc/tools/extensions/availability.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from docutils import nodes
88
from sphinx import addnodes
9+
from sphinx.locale import _ as sphinx_gettext
910
from sphinx.util import logging
1011
from sphinx.util.docutils import SphinxDirective
1112

@@ -55,7 +56,7 @@ class Availability(SphinxDirective):
5556
final_argument_whitespace = True
5657

5758
def run(self) -> list[nodes.container]:
58-
title = "Availability"
59+
title = sphinx_gettext("Availability")
5960
refnode = addnodes.pending_xref(
6061
title,
6162
nodes.inline(title, title, classes=["xref", "std", "std-ref"]),

Doc/tools/extensions/misc_news.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
"""Support for including Misc/NEWS."""
2+
3+
from __future__ import annotations
4+
5+
import re
6+
from pathlib import Path
7+
from typing import TYPE_CHECKING
8+
9+
from docutils import nodes
10+
from sphinx.locale import _ as sphinx_gettext
11+
from sphinx.util.docutils import SphinxDirective
12+
13+
if TYPE_CHECKING:
14+
from typing import Final
15+
16+
from docutils.nodes import Node
17+
from sphinx.application import Sphinx
18+
from sphinx.util.typing import ExtensionMetadata
19+
20+
21+
BLURB_HEADER = """\
22+
+++++++++++
23+
Python News
24+
+++++++++++
25+
"""
26+
27+
bpo_issue_re: Final[re.Pattern[str]] = re.compile(
28+
"(?:issue #|bpo-)([0-9]+)", re.ASCII
29+
)
30+
gh_issue_re: Final[re.Pattern[str]] = re.compile(
31+
"gh-(?:issue-)?([0-9]+)", re.ASCII | re.IGNORECASE
32+
)
33+
whatsnew_re: Final[re.Pattern[str]] = re.compile(
34+
r"^what's new in (.*?)\??$", re.ASCII | re.IGNORECASE | re.MULTILINE
35+
)
36+
37+
38+
class MiscNews(SphinxDirective):
39+
has_content = False
40+
required_arguments = 1
41+
optional_arguments = 0
42+
final_argument_whitespace = False
43+
option_spec = {}
44+
45+
def run(self) -> list[Node]:
46+
# Get content of NEWS file
47+
source, _ = self.get_source_info()
48+
news_file = Path(source).resolve().parent / self.arguments[0]
49+
self.env.note_dependency(news_file)
50+
try:
51+
news_text = news_file.read_text(encoding="utf-8")
52+
except (OSError, UnicodeError):
53+
text = sphinx_gettext("The NEWS file is not available.")
54+
return [nodes.strong(text, text)]
55+
56+
# remove first 3 lines as they are the main heading
57+
news_text = news_text.removeprefix(BLURB_HEADER)
58+
59+
news_text = bpo_issue_re.sub(r":issue:`\1`", news_text)
60+
# Fallback handling for GitHub issues
61+
news_text = gh_issue_re.sub(r":gh:`\1`", news_text)
62+
news_text = whatsnew_re.sub(r"\1", news_text)
63+
64+
self.state_machine.insert_input(news_text.splitlines(), str(news_file))
65+
return []
66+
67+
68+
def setup(app: Sphinx) -> ExtensionMetadata:
69+
app.add_directive("miscnews", MiscNews)
70+
71+
return {
72+
"version": "1.0",
73+
"parallel_read_safe": True,
74+
"parallel_write_safe": True,
75+
}

Doc/tools/extensions/pyspecific.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -147,46 +147,6 @@ def run(self):
147147
return PyMethod.run(self)
148148

149149

150-
# Support for including Misc/NEWS
151-
152-
issue_re = re.compile('(?:[Ii]ssue #|bpo-)([0-9]+)', re.I)
153-
gh_issue_re = re.compile('(?:gh-issue-|gh-)([0-9]+)', re.I)
154-
whatsnew_re = re.compile(r"(?im)^what's new in (.*?)\??$")
155-
156-
157-
class MiscNews(SphinxDirective):
158-
has_content = False
159-
required_arguments = 1
160-
optional_arguments = 0
161-
final_argument_whitespace = False
162-
option_spec = {}
163-
164-
def run(self):
165-
fname = self.arguments[0]
166-
source = self.state_machine.input_lines.source(
167-
self.lineno - self.state_machine.input_offset - 1)
168-
source_dir = getenv('PY_MISC_NEWS_DIR')
169-
if not source_dir:
170-
source_dir = path.dirname(path.abspath(source))
171-
fpath = path.join(source_dir, fname)
172-
self.env.note_dependency(path.abspath(fpath))
173-
try:
174-
with io.open(fpath, encoding='utf-8') as fp:
175-
content = fp.read()
176-
except Exception:
177-
text = 'The NEWS file is not available.'
178-
node = nodes.strong(text, text)
179-
return [node]
180-
content = issue_re.sub(r':issue:`\1`', content)
181-
# Fallback handling for the GitHub issue
182-
content = gh_issue_re.sub(r':gh:`\1`', content)
183-
content = whatsnew_re.sub(r'\1', content)
184-
# remove first 3 lines as they are the main heading
185-
lines = ['.. default-role:: obj', ''] + content.splitlines()[3:]
186-
self.state_machine.insert_input(lines, fname)
187-
return []
188-
189-
190150
# Support for building "topic help" for pydoc
191151

192152
pydoc_topic_labels = [
@@ -338,6 +298,5 @@ def setup(app):
338298
app.add_directive_to_domain('py', 'awaitablefunction', PyAwaitableFunction)
339299
app.add_directive_to_domain('py', 'awaitablemethod', PyAwaitableMethod)
340300
app.add_directive_to_domain('py', 'abstractmethod', PyAbstractMethod)
341-
app.add_directive('miscnews', MiscNews)
342301
app.connect('env-check-consistency', patch_pairindextypes)
343302
return {'version': '1.0', 'parallel_read_safe': True}

Doc/tools/templates/dummy.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
{% trans %}Deprecated since version {deprecated}, will be removed in version {removed}{% endtrans %}
88
{% trans %}Deprecated since version {deprecated}, removed in version {removed}{% endtrans %}
99

10+
In extensions/availability.py:
11+
12+
{% trans %}Availability{% endtrans %}
13+
1014
In extensions/c_annotations.py:
1115

1216
{% trans %}Part of the{% endtrans %}

Doc/whatsnew/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. _changelog:
22

3+
.. default-role:: py:obj
4+
35
+++++++++
46
Changelog
57
+++++++++

0 commit comments

Comments
 (0)