Skip to content

Commit 1eca2ac

Browse files
authored
Merge branch 'python:main' into perf-dataclass-order
2 parents 0827c65 + deb385a commit 1eca2ac

27 files changed

+463
-328
lines changed

.well-known/funding-manifest-urls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://www.python.org/funding.json

Doc/library/difflib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,9 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
351351

352352
.. seealso::
353353

354-
`Pattern Matching: The Gestalt Approach <https://www.drdobbs.com/database/pattern-matching-the-gestalt-approach/184407970>`_
354+
`Pattern Matching: The Gestalt Approach <https://jacobfilipp.com/DrDobbs/articles/DDJ/1988/8807/8807c/8807c.htm>`_
355355
Discussion of a similar algorithm by John W. Ratcliff and D. E. Metzener. This
356-
was published in `Dr. Dobb's Journal <https://www.drdobbs.com/>`_ in July, 1988.
356+
was published in Dr. Dobb's Journal in July, 1988.
357357

358358

359359
.. _sequence-matcher:

Doc/library/time.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ These constants are used as parameters for :func:`clock_getres` and
935935

936936
.. data:: CLOCK_TAI
937937

938-
`International Atomic Time <https://www.nist.gov/pml/time-and-frequency-division/nist-time-frequently-asked-questions-faq#tai>`_
938+
`International Atomic Time <https://www.nist.gov/pml/time-and-frequency-division/how-utcnist-related-coordinated-universal-time-utc-international>`_
939939

940940
The system must have a current leap second table in order for this to give
941941
the correct answer. PTP or NTP software can maintain a leap second table.

Include/internal/pycore_interp_structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ struct _ceval_runtime_state {
8888
struct trampoline_api_st trampoline_api;
8989
FILE *map_file;
9090
Py_ssize_t persist_after_fork;
91+
_PyFrameEvalFunction prev_eval_frame;
9192
#else
9293
int _not_used;
9394
#endif

Include/internal/pycore_pyatomic_ft_wrappers.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ extern "C" {
111111
_Py_atomic_load_ullong_relaxed(&value)
112112
#define FT_ATOMIC_ADD_SSIZE(value, new_value) \
113113
(void)_Py_atomic_add_ssize(&value, new_value)
114+
#define FT_MUTEX_LOCK(lock) PyMutex_Lock(lock)
115+
#define FT_MUTEX_UNLOCK(lock) PyMutex_Unlock(lock)
114116

115117
#else
116118
#define FT_ATOMIC_LOAD_PTR(value) value
@@ -159,6 +161,8 @@ extern "C" {
159161
#define FT_ATOMIC_LOAD_ULLONG_RELAXED(value) value
160162
#define FT_ATOMIC_STORE_ULLONG_RELAXED(value, new_value) value = new_value
161163
#define FT_ATOMIC_ADD_SSIZE(value, new_value) (void)(value += new_value)
164+
#define FT_MUTEX_LOCK(lock) do {} while (0)
165+
#define FT_MUTEX_UNLOCK(lock) do {} while (0)
162166

163167
#endif
164168

Lib/asyncio/streams.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ def connection_lost(self, exc):
271271
self._closed.set_exception(exc)
272272
super().connection_lost(exc)
273273
self._stream_reader_wr = None
274-
self._stream_writer = None
275274
self._task = None
276275
self._transport = None
277276

Lib/test/test_collections.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ def validate_abstract_methods(self, abc, *names):
736736
stubs = methodstubs.copy()
737737
del stubs[name]
738738
C = type('C', (abc,), stubs)
739-
self.assertRaises(TypeError, C, name)
739+
self.assertRaises(TypeError, C)
740740

741741
def validate_isinstance(self, abc, name):
742742
stub = lambda s, *args: 0
@@ -963,7 +963,7 @@ class AnextOnly:
963963
async def __anext__(self):
964964
raise StopAsyncIteration
965965
self.assertNotIsInstance(AnextOnly(), AsyncIterator)
966-
self.validate_abstract_methods(AsyncIterator, '__anext__', '__aiter__')
966+
self.validate_abstract_methods(AsyncIterator, '__anext__')
967967

968968
def test_Iterable(self):
969969
# Check some non-iterables
@@ -1159,7 +1159,7 @@ def test_Iterator(self):
11591159
for x in samples:
11601160
self.assertIsInstance(x, Iterator)
11611161
self.assertIsSubclass(type(x), Iterator)
1162-
self.validate_abstract_methods(Iterator, '__next__', '__iter__')
1162+
self.validate_abstract_methods(Iterator, '__next__')
11631163

11641164
# Issue 10565
11651165
class NextOnly:
@@ -1843,8 +1843,7 @@ def test_Mapping(self):
18431843
for sample in [dict]:
18441844
self.assertIsInstance(sample(), Mapping)
18451845
self.assertIsSubclass(sample, Mapping)
1846-
self.validate_abstract_methods(Mapping, '__contains__', '__iter__', '__len__',
1847-
'__getitem__')
1846+
self.validate_abstract_methods(Mapping, '__iter__', '__len__', '__getitem__')
18481847
class MyMapping(Mapping):
18491848
def __len__(self):
18501849
return 0
@@ -1859,7 +1858,7 @@ def test_MutableMapping(self):
18591858
for sample in [dict]:
18601859
self.assertIsInstance(sample(), MutableMapping)
18611860
self.assertIsSubclass(sample, MutableMapping)
1862-
self.validate_abstract_methods(MutableMapping, '__contains__', '__iter__', '__len__',
1861+
self.validate_abstract_methods(MutableMapping, '__iter__', '__len__',
18631862
'__getitem__', '__setitem__', '__delitem__')
18641863

18651864
def test_MutableMapping_subclass(self):
@@ -1898,8 +1897,7 @@ def test_Sequence(self):
18981897
self.assertIsInstance(memoryview(b""), Sequence)
18991898
self.assertIsSubclass(memoryview, Sequence)
19001899
self.assertIsSubclass(str, Sequence)
1901-
self.validate_abstract_methods(Sequence, '__contains__', '__iter__', '__len__',
1902-
'__getitem__')
1900+
self.validate_abstract_methods(Sequence, '__len__', '__getitem__')
19031901

19041902
def test_Sequence_mixins(self):
19051903
class SequenceSubclass(Sequence):
@@ -1954,8 +1952,8 @@ def test_MutableSequence(self):
19541952
self.assertIsSubclass(sample, MutableSequence)
19551953
self.assertIsSubclass(array.array, MutableSequence)
19561954
self.assertNotIsSubclass(str, MutableSequence)
1957-
self.validate_abstract_methods(MutableSequence, '__contains__', '__iter__',
1958-
'__len__', '__getitem__', '__setitem__', '__delitem__', 'insert')
1955+
self.validate_abstract_methods(MutableSequence, '__len__', '__getitem__',
1956+
'__setitem__', '__delitem__', 'insert')
19591957

19601958
def test_MutableSequence_mixins(self):
19611959
# Test the mixins of MutableSequence by creating a minimal concrete

Lib/test/test_hashlib.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,17 @@
2727
from http.client import HTTPException
2828

2929

30-
default_builtin_hashes = {'md5', 'sha1', 'sha256', 'sha512', 'sha3', 'blake2'}
30+
default_builtin_hashes = {'md5', 'sha1', 'sha2', 'sha3', 'blake2'}
3131
# --with-builtin-hashlib-hashes override
3232
builtin_hashes = sysconfig.get_config_var("PY_BUILTIN_HASHLIB_HASHES")
3333
if builtin_hashes is None:
3434
builtin_hashes = default_builtin_hashes
3535
else:
36-
builtin_hashes = {
37-
m.strip() for m in builtin_hashes.strip('"').lower().split(",")
38-
}
36+
builtin_hash_names = builtin_hashes.strip('"').lower().split(",")
37+
builtin_hashes = set(map(str.strip, builtin_hash_names))
3938

40-
# hashlib with and without OpenSSL backend for PBKDF2
41-
# only import builtin_hashlib when all builtin hashes are available.
42-
# Otherwise import prints noise on stderr
39+
# Public 'hashlib' module with OpenSSL backend for PBKDF2.
4340
openssl_hashlib = import_fresh_module('hashlib', fresh=['_hashlib'])
44-
if builtin_hashes == default_builtin_hashes:
45-
builtin_hashlib = import_fresh_module('hashlib', blocked=['_hashlib'])
46-
else:
47-
builtin_hashlib = None
4841

4942
try:
5043
from _hashlib import HASH, HASHXOF, openssl_md_meth_names, get_fips_mode

Lib/test/test_perf_profiler.py

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -162,48 +162,55 @@ def baz():
162162

163163
@unittest.skipIf(support.check_bolt_optimized(), "fails on BOLT instrumented binaries")
164164
def test_sys_api(self):
165-
code = """if 1:
166-
import sys
167-
def foo():
168-
pass
169-
170-
def spam():
171-
pass
165+
for define_eval_hook in (False, True):
166+
code = """if 1:
167+
import sys
168+
def foo():
169+
pass
172170
173-
def bar():
174-
sys.deactivate_stack_trampoline()
175-
foo()
176-
sys.activate_stack_trampoline("perf")
177-
spam()
171+
def spam():
172+
pass
178173
179-
def baz():
180-
bar()
174+
def bar():
175+
sys.deactivate_stack_trampoline()
176+
foo()
177+
sys.activate_stack_trampoline("perf")
178+
spam()
181179
182-
sys.activate_stack_trampoline("perf")
183-
baz()
184-
"""
185-
with temp_dir() as script_dir:
186-
script = make_script(script_dir, "perftest", code)
187-
env = {**os.environ, "PYTHON_JIT": "0"}
188-
with subprocess.Popen(
189-
[sys.executable, script],
190-
text=True,
191-
stderr=subprocess.PIPE,
192-
stdout=subprocess.PIPE,
193-
env=env,
194-
) as process:
195-
stdout, stderr = process.communicate()
180+
def baz():
181+
bar()
196182
197-
self.assertEqual(stderr, "")
198-
self.assertEqual(stdout, "")
183+
sys.activate_stack_trampoline("perf")
184+
baz()
185+
"""
186+
if define_eval_hook:
187+
set_eval_hook = """if 1:
188+
import _testinternalcapi
189+
_testinternalcapi.set_eval_frame_record([])
190+
"""
191+
code = set_eval_hook + code
192+
with temp_dir() as script_dir:
193+
script = make_script(script_dir, "perftest", code)
194+
env = {**os.environ, "PYTHON_JIT": "0"}
195+
with subprocess.Popen(
196+
[sys.executable, script],
197+
text=True,
198+
stderr=subprocess.PIPE,
199+
stdout=subprocess.PIPE,
200+
env=env,
201+
) as process:
202+
stdout, stderr = process.communicate()
199203

200-
perf_file = pathlib.Path(f"/tmp/perf-{process.pid}.map")
201-
self.assertTrue(perf_file.exists())
202-
perf_file_contents = perf_file.read_text()
203-
self.assertNotIn(f"py::foo:{script}", perf_file_contents)
204-
self.assertIn(f"py::spam:{script}", perf_file_contents)
205-
self.assertIn(f"py::bar:{script}", perf_file_contents)
206-
self.assertIn(f"py::baz:{script}", perf_file_contents)
204+
self.assertEqual(stderr, "")
205+
self.assertEqual(stdout, "")
206+
207+
perf_file = pathlib.Path(f"/tmp/perf-{process.pid}.map")
208+
self.assertTrue(perf_file.exists())
209+
perf_file_contents = perf_file.read_text()
210+
self.assertNotIn(f"py::foo:{script}", perf_file_contents)
211+
self.assertIn(f"py::spam:{script}", perf_file_contents)
212+
self.assertIn(f"py::bar:{script}", perf_file_contents)
213+
self.assertIn(f"py::baz:{script}", perf_file_contents)
207214

208215
def test_sys_api_with_existing_trampoline(self):
209216
code = """if 1:

0 commit comments

Comments
 (0)