Skip to content

Commit e4652a7

Browse files
authored
Merge branch 'main' into issue-85162
2 parents 64c3070 + a29a9c0 commit e4652a7

35 files changed

+868
-512
lines changed

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
'pydoc_topics',
3233
'pyspecific',
3334
'sphinx.ext.coverage',

Doc/data/stable_abi.dat

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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
@@ -141,46 +141,6 @@ def run(self):
141141
return PyMethod.run(self)
142142

143143

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

186146
opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?')
@@ -268,6 +228,5 @@ def setup(app):
268228
app.add_directive_to_domain('py', 'awaitablefunction', PyAwaitableFunction)
269229
app.add_directive_to_domain('py', 'awaitablemethod', PyAwaitableMethod)
270230
app.add_directive_to_domain('py', 'abstractmethod', PyAbstractMethod)
271-
app.add_directive('miscnews', MiscNews)
272231
app.connect('env-check-consistency', patch_pairindextypes)
273232
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/3.14.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,11 @@ Limited C API changes
13431343
implementation details.
13441344
(Contributed by Victor Stinner in :gh:`120600` and :gh:`124127`.)
13451345

1346+
* Remove :c:func:`PySequence_Fast` from the limited C API, since this function
1347+
has to be used with :c:macro:`PySequence_Fast_GET_ITEM` which never worked
1348+
in the limited C API.
1349+
(Contributed by Victor Stinner in :gh:`91417`.)
1350+
13461351

13471352
Porting to Python 3.14
13481353
----------------------

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
+++++++++

Include/abstract.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -726,31 +726,6 @@ PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o);
726726
This is equivalent to the Python expression: list(o) */
727727
PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o);
728728

729-
/* Return the sequence 'o' as a list, unless it's already a tuple or list.
730-
731-
Use PySequence_Fast_GET_ITEM to access the members of this list, and
732-
PySequence_Fast_GET_SIZE to get its length.
733-
734-
Returns NULL on failure. If the object does not support iteration, raises a
735-
TypeError exception with 'm' as the message text. */
736-
PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
737-
738-
/* Return the size of the sequence 'o', assuming that 'o' was returned by
739-
PySequence_Fast and is not NULL. */
740-
#define PySequence_Fast_GET_SIZE(o) \
741-
(PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
742-
743-
/* Return the 'i'-th element of the sequence 'o', assuming that o was returned
744-
by PySequence_Fast, and that i is within bounds. */
745-
#define PySequence_Fast_GET_ITEM(o, i)\
746-
(PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i)))
747-
748-
/* Return a pointer to the underlying item array for
749-
an object returned by PySequence_Fast */
750-
#define PySequence_Fast_ITEMS(sf) \
751-
(PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
752-
: ((PyTupleObject *)(sf))->ob_item)
753-
754729
/* Return the number of occurrences on value on 'o', that is, return
755730
the number of keys for which o[key] == value.
756731

0 commit comments

Comments
 (0)