Skip to content

Commit 258c0aa

Browse files
Merge branch 'main' into mrocache
2 parents 7416272 + 0828782 commit 258c0aa

25 files changed

Lines changed: 487 additions & 123 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

Doc/whatsnew/3.15.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,19 @@ http.server
12071207
(Contributed by Anton I. Sipos in :gh:`135057`.)
12081208

12091209

1210+
importlib.metadata
1211+
------------------
1212+
1213+
* Previously, when accessing a distribution metadata directory not
1214+
containing a metadata file, ``metadata()`` and ``Distribution.metadata()``
1215+
would return an empty ``PackageMetadata`` object as if the file
1216+
was present but empty. Now, a ``MetadataNotFound`` exception is raised.
1217+
See `importlib_metadata#493 <https://github.com/python/importlib_metadata/issues/493>`_
1218+
for background and rationale and and :gh:`143387` for rationale on the
1219+
compatibility concerns.
1220+
(Contributed by Jason R. Coombs.)
1221+
1222+
12101223
inspect
12111224
-------
12121225

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ Known values:
298298
Python 3.15a8 3665 (Add FOR_ITER_VIRTUAL and GET_ITER specializations)
299299
Python 3.15b1 3666 (Add SEND_VIRTUAL and SEND_ASYNC_GEN specializations)
300300
Python 3.16a0 3700 (Initial version)
301+
Python 3.16a0 3701 (Add CONSTANT_EMPTY_TUPLE to LOAD_COMMON_CONSTANT)
301302
302303
303304
Python 3.17 will start with 3750
@@ -311,7 +312,7 @@ PC/launcher.c must also be updated.
311312
312313
*/
313314

314-
#define PYC_MAGIC_NUMBER 3700
315+
#define PYC_MAGIC_NUMBER 3701
315316
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
316317
(little-endian) and then appending b'\r\n'. */
317318
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_opcode_utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ extern "C" {
8181
#define CONSTANT_FALSE 10
8282
#define CONSTANT_MINUS_ONE 11
8383
#define CONSTANT_BUILTIN_FROZENSET 12
84-
#define NUM_COMMON_CONSTANTS 13
84+
#define CONSTANT_EMPTY_TUPLE 13
85+
#define NUM_COMMON_CONSTANTS 14
8586

8687
/* Values used in the oparg for RESUME */
8788
#define RESUME_AT_FUNC_START 0

Include/internal/pycore_optimizer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ extern "C" {
3131
* 4. A push followed by a matching return is net-zero on frame-specific
3232
* fitness, excluding per-slot costs.
3333
*/
34-
#define MAX_TARGET_LENGTH (UOP_MAX_TRACE_LENGTH / 2)
3534
#define OPTIMIZER_EFFECTIVENESS 2
36-
#define FITNESS_INITIAL (MAX_TARGET_LENGTH * OPTIMIZER_EFFECTIVENESS)
35+
#define MAX_TARGET_LENGTH (FITNESS_INITIAL / OPTIMIZER_EFFECTIVENESS)
3736

3837
/* Exit quality thresholds: trace stops when fitness < exit_quality.
3938
* Higher = trace is more willing to stop here. */

Include/internal/pycore_uop.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ typedef struct _PyUOpInstruction{
3636
#endif
3737
} _PyUOpInstruction;
3838

39-
// This is the length of the trace we translate initially.
39+
// Fitness is the target length of the trace we translate initially. The uop
40+
// buffer has a small amount of extra space for entry/loop-closing overhead.
4041
#if defined(Py_DEBUG) && defined(_Py_JIT)
4142
// With asserts, the stencils are a lot larger
42-
#define UOP_MAX_TRACE_LENGTH 1000
43+
#define FITNESS_INITIAL 1000
4344
#else
44-
#define UOP_MAX_TRACE_LENGTH 2500
45+
#define FITNESS_INITIAL 2500
4546
#endif
4647

48+
#define UOP_TRACE_BUFFER_OVERHEAD 10
49+
#define UOP_MAX_TRACE_LENGTH (FITNESS_INITIAL + UOP_TRACE_BUFFER_OVERHEAD)
50+
4751
/* Bloom filter with m = 256
4852
* https://en.wikipedia.org/wiki/Bloom_filter */
4953
#ifdef HAVE_GCC_UINT128_T

Lib/dis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,8 @@ def _get_const_value(op, arg, co_consts):
698698
if op == LOAD_SMALL_INT:
699699
return arg
700700
if op == LOAD_COMMON_CONSTANT:
701-
# Opargs 0-6 are callables; 7-11 are literal values.
702-
if 7 <= arg <= 11:
701+
# Opargs 0-6 and 12 are callables; 7-11 and 13 are literal values.
702+
if 7 <= arg <= 11 or arg == 13:
703703
return _common_constants[arg]
704704
return UNKNOWN
705705
argval = UNKNOWN

Lib/opcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
builtins.set,
4545
# Append-only — must match CONSTANT_* in
4646
# Include/internal/pycore_opcode_utils.h.
47-
None, "", True, False, -1, builtins.frozenset]
47+
None, "", True, False, -1, builtins.frozenset, ()]
4848
_nb_ops = _opcode.get_nb_ops()
4949

5050
hascompare = [opmap["COMPARE_OP"]]

Lib/test/test_capi/test_opt.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5924,6 +5924,44 @@ def __next__(self):
59245924
"""), PYTHON_JIT="1", PYTHON_JIT_STRESS="1")
59255925
self.assertEqual(result[0].rc, 0, result)
59265926

5927+
def test_149335_trace_buffer_guard(self):
5928+
# https://github.com/python/cpython/issues/149335
5929+
5930+
result = script_helper.run_python_until_end('-c', textwrap.dedent("""
5931+
import sys
5932+
5933+
def f1():
5934+
for i_3178 in 0, 2, 10:
5935+
mv162 = 162
5936+
5937+
mv3 = mv1 = mv_165 = mv16 = \
5938+
mv167 = mv168 = \
5939+
mv169 = \
5940+
mv_1403_170 = \
5941+
169
5942+
5943+
mv_1403_170
5944+
5945+
mv_172 = mv_3 = mv_4 = mv175 = mv176 = mv17 = mv178 = mv179 = mv0 = mv1 = mv182 = (
5946+
mv3
5947+
) = mv4 = mv185 = mv186 = mv187 = mv18 = mv189 = mv0 = mv1 = mv192 = mv3 = mv4 = (
5948+
mv195
5949+
) = mv196 = mv197 = mv_198 = mv19 = mv0 = mv1 = mv2 = mv3 = mv4 = mv05 = mv06 = (
5950+
mv07
5951+
) = mv08 = mv09 = mv0 = mv1 = mv2 = mv3 = mv4 = mv15 = mv16 = mv17 = mv18 = mv19 = (
5952+
mv0
5953+
) = mv1 = mv_2 = mv3 = mv4 = mv_25 = mv_26 = mv_27 = mv_28 = mv_29 = mv0 = mv1 = (
5954+
mv2
5955+
) = mv_1403 = mv4 = mv35 = mv36 = mv37 = mv38 = mv39 = mv0 = -sys.maxsize / 3
5956+
5957+
mv1 = mv_12 = mv3 = mv_14 = mv45 = sys.float_info.epsilon
5958+
mv46 = sys.float_info.epsilon
5959+
5960+
for i in range(15000):
5961+
f1()
5962+
"""), PYTHON_JIT="1")
5963+
self.assertEqual(result[0].rc, 0, result)
5964+
59275965
def test_144068_daemon_thread_jit_cleanup(self):
59285966
result = script_helper.run_python_until_end('-c', textwrap.dedent("""
59295967
import threading

Lib/test/test_crossinterp.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ def ignore_byteswarning():
157157
{},
158158
{1: 7, 2: 8, 3: 9},
159159
{1: [1], 2: (2,), 3: {3: 4}},
160+
# frozendict
161+
frozendict(),
162+
frozendict({1: 7, 2: 8, 3: 9}),
163+
frozendict({1: [1], 2: (2,), 3: {3: 4}, 4: frozendict({5: 6})}),
160164
# set
161165
set(),
162166
{1, 2, 3},

0 commit comments

Comments
 (0)