Skip to content

Commit 7e7cba2

Browse files
Merge branch 'main' into bugfix-150107-asyncio-ignore-0-offset
2 parents a8f0c9c + 87a879f commit 7e7cba2

24 files changed

Lines changed: 972 additions & 143 deletions

Doc/library/unicodedata.rst

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,52 @@ this database is compiled from the `UCD version 17.0.0
1818

1919
The module uses the same names and symbols as defined by Unicode
2020
Standard Annex #44, `"Unicode Character Database"
21-
<https://www.unicode.org/reports/tr44/>`_. It defines the
22-
following functions:
21+
<https://www.unicode.org/reports/tr44/>`_.
2322

2423
.. seealso::
2524

2625
The :ref:`unicode-howto` for more information about Unicode and how to use
2726
this module.
2827

2928

29+
============================================================ ===========================================================
30+
**Lookup**
31+
-------------------------------------------------------------------------------------------------------------------------
32+
:func:`lookup(name) <lookup>` Look up character by name
33+
:func:`name(chr) <name>` Return the name assigned to a character
34+
35+
**Numeric values**
36+
-------------------------------------------------------------------------------------------------------------------------
37+
:func:`decimal(chr) <decimal>` Decimal value of a character
38+
:func:`digit(chr) <digit>` Digit value of a character
39+
:func:`numeric(chr) <numeric>` Numeric value of a character
40+
41+
**Properties**
42+
-------------------------------------------------------------------------------------------------------------------------
43+
:func:`bidirectional(chr) <bidirectional>` Bidirectional class of a character
44+
:func:`block(chr) <block>` Unicode block of a character
45+
:func:`category(chr) <category>` General category of a character
46+
:func:`combining(chr) <combining>` Canonical combining class of a character
47+
:func:`decomposition(chr) <decomposition>` Character decomposition mapping
48+
:func:`east_asian_width(chr) <east_asian_width>` East Asian width of a character
49+
:func:`extended_pictographic(chr) <extended_pictographic>` Check if a character has the Extended_Pictographic property
50+
:func:`grapheme_cluster_break(chr) <grapheme_cluster_break>` Grapheme_Cluster_Break property of a character
51+
:func:`indic_conjunct_break(chr) <indic_conjunct_break>` Indic_Conjunct_Break property of a character
52+
:func:`isxidcontinue(chr) <isxidcontinue>` Check if a character is a valid identifier continuation
53+
:func:`isxidstart(chr) <isxidstart>` Check if a character is a valid identifier start
54+
:func:`mirrored(chr) <mirrored>` Mirrored property of a character
55+
56+
**Normalization**
57+
-------------------------------------------------------------------------------------------------------------------------
58+
:func:`normalize(form, unistr) <normalize>` Return the normalized form of a string
59+
:func:`is_normalized(form, unistr) <is_normalized>` Check if a Unicode string is normalized
60+
61+
**Text segmentation**
62+
-------------------------------------------------------------------------------------------------------------------------
63+
:func:`iter_graphemes(unistr) <iter_graphemes>` Iterate over grapheme clusters in a string
64+
============================================================ ===========================================================
65+
66+
3067
.. function:: lookup(name, /)
3168

3269
Look up character by name. If a character with the given name is found, return
@@ -273,7 +310,7 @@ following functions:
273310
.. versionadded:: 3.15
274311

275312

276-
In addition, the module exposes the following constant:
313+
In addition, the module exposes the following constants:
277314

278315
.. data:: unidata_version
279316

Lib/profiling/sampling/jsonl_collector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def export(self, filename):
164164
self._iter_final_agg_entries(),
165165
)
166166
self._write_message(output, self._build_end_record())
167+
print(f"JSONL profile written to {filename}")
167168

168169
def _build_meta_record(self):
169170
record = {

Lib/profiling/sampling/sample.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,33 @@ def _print_unwinder_stats(self):
327327
print(f" Hits: {code_hits:n} ({ANSIColors.GREEN}{fmt(code_hits_pct)}%{ANSIColors.RESET})")
328328
print(f" Misses: {code_misses:n} ({ANSIColors.RED}{fmt(code_misses_pct)}%{ANSIColors.RESET})")
329329

330+
batched_attempts = stats.get('batched_read_attempts', 0)
331+
batched_successes = stats.get('batched_read_successes', 0)
332+
batched_misses = stats.get('batched_read_misses', 0)
333+
segments_requested = stats.get('batched_read_segments_requested', 0)
334+
segments_completed = stats.get('batched_read_segments_completed', 0)
335+
if batched_attempts > 0:
336+
batched_success_rate = stats.get('batched_read_success_rate', 0.0)
337+
batched_miss_rate = 100.0 - batched_success_rate
338+
segment_completion_rate = stats.get(
339+
'batched_read_segment_completion_rate', 0.0
340+
)
341+
342+
print(f" {ANSIColors.CYAN}Batched Reads:{ANSIColors.RESET}")
343+
print(f" Attempts: {batched_attempts:n}")
344+
print(
345+
f" Successes: {batched_successes:n} "
346+
f"({ANSIColors.GREEN}{fmt(batched_success_rate)}%{ANSIColors.RESET})"
347+
)
348+
print(
349+
f" Misses: {batched_misses:n} "
350+
f"({ANSIColors.RED}{fmt(batched_miss_rate)}%{ANSIColors.RESET})"
351+
)
352+
print(
353+
f" Segments read: {segments_completed:n}/{segments_requested:n} "
354+
f"({ANSIColors.GREEN}{fmt(segment_completion_rate)}%{ANSIColors.RESET})"
355+
)
356+
330357
# Memory operations
331358
memory_reads = stats.get('memory_reads', 0)
332359
memory_bytes = stats.get('memory_bytes_read', 0)

Lib/test/test_dict.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,10 +1903,35 @@ def test_hash(self):
19031903
self.assertEqual(hash(frozendict(x=1, y=2)),
19041904
hash(frozendict(y=2, x=1)))
19051905

1906+
# Check that hash() computes the hash of (key, value) pairs
1907+
cases = [
1908+
frozendict(a=False, b=True, c=True),
1909+
frozendict(a=True, b=False, c=True),
1910+
frozendict(a=True, b=True, c=False),
1911+
frozendict({False: "a", "b": True, "c": True}),
1912+
frozendict({"a": "b", False: True, True: "c"}),
1913+
]
1914+
hashes = {hash(fd) for fd in cases}
1915+
self.assertEqual(len(hashes), len(cases))
1916+
19061917
fd = frozendict(x=[1], y=[2])
19071918
with self.assertRaisesRegex(TypeError, "unhashable type: 'list'"):
19081919
hash(fd)
19091920

1921+
@support.cpython_only
1922+
def test_hash_cpython(self):
1923+
# Check that hash(frozendict) implementation is:
1924+
# hash(frozenset(fd.items()))
1925+
for fd in (
1926+
frozendict(),
1927+
frozendict(x=1, y=2),
1928+
frozendict(y=2, x=1),
1929+
frozendict(a=False, b=True, c=True),
1930+
frozendict.fromkeys('abc'),
1931+
):
1932+
with self.subTest(fd=fd):
1933+
self.assertEqual(hash(fd), hash(frozenset(fd.items())))
1934+
19101935
def test_fromkeys(self):
19111936
self.assertEqual(frozendict.fromkeys('abc'),
19121937
frozendict(a=None, b=None, c=None))

Lib/test/test_external_inspection.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,6 +3767,13 @@ def test_get_stats(self):
37673767
"frames_read_from_cache",
37683768
"frames_read_from_memory",
37693769
"frame_cache_hit_rate",
3770+
"batched_read_attempts",
3771+
"batched_read_successes",
3772+
"batched_read_misses",
3773+
"batched_read_segments_requested",
3774+
"batched_read_segments_completed",
3775+
"batched_read_success_rate",
3776+
"batched_read_segment_completion_rate",
37703777
]
37713778
for key in expected_keys:
37723779
self.assertIn(key, stats)

Lib/test/test_genericalias.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@
5555
from unittest.case import _AssertRaisesContext
5656
from queue import Queue, SimpleQueue
5757
from weakref import WeakSet, ReferenceType, ref
58-
import typing
59-
from typing import Unpack
6058
try:
6159
from tkinter import Event
6260
except ImportError:
6361
Event = None
6462
from string.templatelib import Template, Interpolation
6563

66-
from typing import TypeVar
64+
import typing
65+
from typing import TypeVar, Unpack
6766
T = TypeVar('T')
6867
K = TypeVar('K')
6968
V = TypeVar('V')
@@ -621,6 +620,14 @@ def test_nested_paramspec_specialization(self):
621620
self.assertEqual(deeply_nested_specialized.__args__, ([str, [float], int], float))
622621
self.assertEqual(deeply_nested_specialized.__parameters__, ())
623622

623+
def test_gh150146(self):
624+
# It used to crash:
625+
for container in [memoryview, list, tuple]:
626+
with self.subTest(container=container):
627+
x = container[TypeVar("")]
628+
with self.assertRaises(TypeError):
629+
x[*typing.Mapping[..., ...]]
630+
624631

625632
class TypeIterationTests(unittest.TestCase):
626633
_UNITERABLE_TYPES = (list, tuple)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
On Linux when Python is linked to the musl C library, use a thread stack
2+
size of at least 1 MiB instead of musl default which is 128 kiB. Patch by
3+
Victor Stinner.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix ``hash(frozendict)``: compute the hash of each ``(key, value)`` pair
2+
correctly. Patch by Victor Stinner.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fix a crash on a complex type variable substitution.
2+
3+
``from typing import TypeVar; memoryview[TypeVar("")][*typing.Mapping[...,
4+
...]]`` used to fail due to missing ``NULL`` check on ``_unpack_args`` C
5+
function call.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix excessive overhead in the Tachyon profiler when inspecting a remote
2+
process by avoiding repeated remote page-cache scans, batching predicted
3+
remote reads, and reusing cached profiler result objects. Patch by Pablo
4+
Galindo and Maurycy Pawłowski-Wieroński.

0 commit comments

Comments
 (0)