Skip to content

Commit 412a028

Browse files
Merge branch 'main' into deprecations
2 parents 18a45c1 + 7241f27 commit 412a028

30 files changed

Lines changed: 321 additions & 321 deletions

Doc/deprecations/pending-removal-in-3.16.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Pending removal in Python 3.16
9191

9292
* :mod:`symtable`:
9393

94-
* The :meth:`Class.get_methods <symtable.Class.get_methods>` method
94+
* The :meth:`!symtable.Class.get_methods` method
9595
has been deprecated since Python 3.14.
9696

9797
* :mod:`sys`:

Doc/library/symtable.rst

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -187,57 +187,6 @@ Examining Symbol Tables
187187

188188
A namespace of a class. This class inherits from :class:`SymbolTable`.
189189

190-
.. method:: get_methods()
191-
192-
Return a tuple containing the names of method-like functions declared
193-
in the class.
194-
195-
Here, the term 'method' designates *any* function defined in the class
196-
body via :keyword:`def` or :keyword:`async def`.
197-
198-
Functions defined in a deeper scope (e.g., in an inner class) are not
199-
picked up by :meth:`get_methods`.
200-
201-
For example:
202-
203-
.. testsetup:: symtable.Class.get_methods
204-
205-
import warnings
206-
context = warnings.catch_warnings()
207-
context.__enter__()
208-
warnings.simplefilter("ignore", category=DeprecationWarning)
209-
210-
.. testcleanup:: symtable.Class.get_methods
211-
212-
context.__exit__()
213-
214-
.. doctest:: symtable.Class.get_methods
215-
216-
>>> import symtable
217-
>>> st = symtable.symtable('''
218-
... def outer(): pass
219-
...
220-
... class A:
221-
... def f():
222-
... def w(): pass
223-
...
224-
... def g(self): pass
225-
...
226-
... @classmethod
227-
... async def h(cls): pass
228-
...
229-
... global outer
230-
... def outer(self): pass
231-
... ''', 'test', 'exec')
232-
>>> class_A = st.get_children()[2]
233-
>>> class_A.get_methods()
234-
('f', 'g', 'h')
235-
236-
Although ``A().f()`` raises :exc:`TypeError` at runtime, ``A.f`` is still
237-
considered as a method-like function.
238-
239-
.. deprecated-removed:: 3.14 3.16
240-
241190

242191
.. class:: Symbol
243192

Doc/tools/removed-ids.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ c-api/file.html: deprecated-api
88
library/asyncio-task.html: terminating-a-task-group
99
deprecations/index.html: pending-removal-in-python-3-15
1010
deprecations/index.html: c-api-pending-removal-in-python-3-15
11+
12+
# Removed APIs
13+
library/symtable.html: symtable.Class.get_methods

Doc/whatsnew/3.14.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2718,7 +2718,7 @@ New deprecations
27182718
(Contributed by Tian Gao in :gh:`124369` and :gh:`125951`.)
27192719

27202720
* :mod:`symtable`:
2721-
Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest,
2721+
Deprecate :meth:`!symtable.Class.get_methods` due to the lack of interest,
27222722
scheduled for removal in Python 3.16.
27232723
(Contributed by Bénédikt Tran in :gh:`119698`.)
27242724

Doc/whatsnew/3.16.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ annotationlib
114114
Use :meth:`annotationlib.ForwardRef.evaluate`
115115
or :func:`typing.evaluate_forward_ref` instead.
116116

117+
functools
118+
---------
119+
120+
* Calling the Python implementation of :func:`functools.reduce` with *function*
121+
or *sequence* as keyword arguments has been deprecated since Python 3.14.
122+
123+
symtable
124+
--------
125+
126+
* The :meth:`!symtable.Class.get_methods` method
127+
which has been deprecated since Python 3.14.
128+
117129
sysconfig
118130
---------
119131

Lib/asyncio/windows_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ def fileno(self):
111111

112112
def close(self, *, CloseHandle=_winapi.CloseHandle):
113113
if self._handle is not None:
114-
CloseHandle(self._handle)
114+
handle = self._handle
115115
self._handle = None
116+
CloseHandle(handle)
116117

117118
def __del__(self, _warn=warnings.warn):
118119
if self._handle is not None:

Lib/functools.py

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ def __ge__(self, other):
232232
### reduce() sequence to a single item
233233
################################################################################
234234

235-
_initial_missing = object()
235+
_initial_missing = sentinel('_initial_missing')
236236

237-
def reduce(function, sequence, initial=_initial_missing):
237+
def reduce(function, sequence, /, initial=_initial_missing):
238238
"""
239239
reduce(function, iterable, /[, initial]) -> value
240240
@@ -264,6 +264,11 @@ def reduce(function, sequence, initial=_initial_missing):
264264

265265
return value
266266

267+
try:
268+
from _functools import reduce
269+
except ImportError:
270+
pass
271+
267272

268273
################################################################################
269274
### partial() argument application
@@ -1178,31 +1183,3 @@ def __get__(self, instance, owner=None):
11781183
return val
11791184

11801185
__class_getitem__ = classmethod(GenericAlias)
1181-
1182-
def _warn_python_reduce_kwargs(py_reduce):
1183-
@wraps(py_reduce)
1184-
def wrapper(*args, **kwargs):
1185-
if 'function' in kwargs or 'sequence' in kwargs:
1186-
import os
1187-
import warnings
1188-
warnings.warn(
1189-
'Calling functools.reduce with keyword arguments '
1190-
'"function" or "sequence" '
1191-
'is deprecated in Python 3.14 and will be '
1192-
'forbidden in Python 3.16.',
1193-
DeprecationWarning,
1194-
skip_file_prefixes=(os.path.dirname(__file__),))
1195-
return py_reduce(*args, **kwargs)
1196-
return wrapper
1197-
1198-
reduce = _warn_python_reduce_kwargs(reduce)
1199-
del _warn_python_reduce_kwargs
1200-
1201-
# The import of the C accelerated version of reduce() has been moved
1202-
# here due to gh-121676. In Python 3.16, _warn_python_reduce_kwargs()
1203-
# should be removed and the import block should be moved back right
1204-
# after the definition of reduce().
1205-
try:
1206-
from _functools import reduce
1207-
except ImportError:
1208-
pass

Lib/profiling/sampling/_heatmap_assets/heatmap.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function showNavigationMenu(button, items, title) {
8484

8585
item.appendChild(funcDiv);
8686
item.appendChild(createElement('div', 'callee-menu-file', linkData.file));
87-
item.addEventListener('click', () => window.location.href = linkData.link);
87+
item.addEventListener('click', () => navigateToLine(linkData.link));
8888
menu.appendChild(item);
8989
});
9090

@@ -105,7 +105,7 @@ function handleNavigationClick(button, e) {
105105

106106
const navData = button.getAttribute('data-nav');
107107
if (navData) {
108-
window.location.href = JSON.parse(navData).link;
108+
navigateToLine(JSON.parse(navData).link);
109109
return;
110110
}
111111

@@ -117,11 +117,29 @@ function handleNavigationClick(button, e) {
117117
}
118118
}
119119

120+
function restartLineHighlight(target) {
121+
target.style.animation = 'none';
122+
// Force style recalculation so restoring the animation restarts it.
123+
void target.offsetWidth;
124+
target.style.animation = '';
125+
}
126+
127+
function navigateToLine(link) {
128+
const url = new URL(link, window.location.href);
129+
130+
if (url.href === window.location.href) {
131+
scrollToTargetLine();
132+
} else {
133+
window.location.href = link;
134+
}
135+
}
136+
120137
function scrollToTargetLine() {
121138
if (!window.location.hash) return;
122139
const target = document.querySelector(window.location.hash);
123140
if (target) {
124141
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
142+
restartLineHighlight(target);
125143
}
126144
}
127145

Lib/profiling/sampling/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ def _build_child_profiler_args(args):
167167
child_args.extend(["--mode", mode])
168168

169169
# Format options (skip pstats as it's the default)
170-
if args.format != "pstats":
170+
if args.format == "diff_flamegraph":
171+
child_args.extend(["--diff-flamegraph", args.diff_baseline])
172+
elif args.format != "pstats":
171173
child_args.append(f"--{args.format}")
172174

173175
return child_args

Lib/profiling/sampling/stack_collector.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,8 @@ def _add_elided_metadata(self, node, baseline_stats, scale, path):
698698
func_key = self._extract_func_key(node, self._baseline_collector._string_table)
699699
current_path = path + (func_key,) if func_key else path
700700

701+
baseline_self = 0
702+
baseline_total = 0
701703
if func_key and current_path in baseline_stats:
702704
baseline_data = baseline_stats[current_path]
703705
baseline_self = baseline_data["self"] * scale

0 commit comments

Comments
 (0)