Skip to content

Commit cd26833

Browse files
authored
Merge branch 'main' into thread_name_fix
2 parents 25085bf + a2ba0a7 commit cd26833

File tree

131 files changed

+2868
-1344
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+2868
-1344
lines changed

.devcontainer/devcontainer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
"dnf",
66
"install",
77
"-y",
8-
"which",
9-
"zsh",
10-
"fish",
118
// For umask fix below.
129
"/usr/bin/setfacl"
1310
],

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ jobs:
130130
- name: Build CPython
131131
run: |
132132
make -j4 regen-all
133-
make regen-stdlib-module-names regen-sbom regen-unicodedata
133+
make regen-stdlib-module-names regen-sbom
134134
- name: Check for changes
135135
run: |
136136
git add -u

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ repos:
1414
name: Run Ruff (lint) on Tools/build/
1515
args: [--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]
1616
files: ^Tools/build/
17+
- id: ruff
18+
name: Run Ruff (lint) on Tools/i18n/
19+
args: [--exit-non-zero-on-fix, --config=Tools/i18n/.ruff.toml]
20+
files: ^Tools/i18n/
1721
- id: ruff
1822
name: Run Ruff (lint) on Argument Clinic
1923
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ Pending removal in Python 3.15
107107

108108
* :mod:`zipimport`:
109109

110-
* :meth:`~zipimport.zipimporter.load_module` has been deprecated since
110+
* :meth:`!zipimport.zipimporter.load_module` has been deprecated since
111111
Python 3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead.
112-
(Contributed by Jiahao Li in :gh:`125746`.)
112+
(:gh:`125746`.)

Doc/howto/descriptor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ Here are three practical data validation utilities:
420420

421421
def validate(self, value):
422422
if not isinstance(value, str):
423-
raise TypeError(f'Expected {value!r} to be an str')
423+
raise TypeError(f'Expected {value!r} to be a str')
424424
if self.minsize is not None and len(value) < self.minsize:
425425
raise ValueError(
426426
f'Expected {value!r} to be no smaller than {self.minsize!r}'

Doc/library/exceptions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,9 @@ The following exceptions are used as warning categories; see the
897897

898898
Base class for warnings about dubious syntax.
899899

900+
This warning is typically emitted when compiling Python source code, and usually won't be reported
901+
when running already compiled code.
902+
900903

901904
.. exception:: RuntimeWarning
902905

Doc/library/shutil.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ In the final archive, :file:`please_add.txt` should be included, but
860860
... root_dir='tmp/root',
861861
... base_dir='structure/content',
862862
... )
863-
'/Users/tarek/my_archive.tar'
863+
'/Users/tarek/myarchive.tar'
864864

865865
Listing the files in the resulting archive gives us:
866866

Doc/library/ssl.rst

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,19 +1684,33 @@ to speed up repeated connections from the same clients.
16841684

16851685
.. method:: SSLContext.set_ciphers(ciphers)
16861686

1687-
Set the available ciphers for sockets created with this context.
1688-
It should be a string in the `OpenSSL cipher list format
1687+
Set the allowed ciphers for sockets created with this context when
1688+
connecting using TLS 1.2 and earlier. The *ciphers* argument should
1689+
be a string in the `OpenSSL cipher list format
16891690
<https://docs.openssl.org/master/man1/ciphers/>`_.
1691+
To set allowed TLS 1.3 ciphers, use :meth:`SSLContext.set_ciphersuites`.
1692+
16901693
If no cipher can be selected (because compile-time options or other
16911694
configuration forbids use of all the specified ciphers), an
16921695
:class:`SSLError` will be raised.
16931696

16941697
.. note::
1695-
when connected, the :meth:`SSLSocket.cipher` method of SSL sockets will
1696-
give the currently selected cipher.
1698+
When connected, the :meth:`SSLSocket.cipher` method of SSL sockets will
1699+
return details about the negotiated cipher.
1700+
1701+
.. method:: SSLContext.set_ciphersuites(ciphersuites)
1702+
1703+
Set the allowed ciphers for sockets created with this context when
1704+
connecting using TLS 1.3. The *ciphersuites* argument should be a
1705+
colon-separate string of TLS 1.3 cipher names. If no cipher can be
1706+
selected (because compile-time options or other configuration forbids
1707+
use of all the specified ciphers), an :class:`SSLError` will be raised.
1708+
1709+
.. note::
1710+
When connected, the :meth:`SSLSocket.cipher` method of SSL sockets will
1711+
return details about the negotiated cipher.
16971712

1698-
TLS 1.3 cipher suites cannot be disabled with
1699-
:meth:`~SSLContext.set_ciphers`.
1713+
.. versionadded:: next
17001714

17011715
.. method:: SSLContext.set_groups(groups)
17021716

@@ -2845,10 +2859,15 @@ TLS 1.3
28452859
The TLS 1.3 protocol behaves slightly differently than previous version
28462860
of TLS/SSL. Some new TLS 1.3 features are not yet available.
28472861

2848-
- TLS 1.3 uses a disjunct set of cipher suites. All AES-GCM and
2849-
ChaCha20 cipher suites are enabled by default. The method
2850-
:meth:`SSLContext.set_ciphers` cannot enable or disable any TLS 1.3
2851-
ciphers yet, but :meth:`SSLContext.get_ciphers` returns them.
2862+
- TLS 1.3 uses a disjunct set of cipher suites. All AES-GCM and ChaCha20
2863+
cipher suites are enabled by default. To restrict which TLS 1.3 ciphers
2864+
are allowed, the :meth:`SSLContext.set_ciphersuites` method should be
2865+
called instead of :meth:`SSLContext.set_ciphers`, which only affects
2866+
ciphers in older TLS versions. The :meth:`SSLContext.get_ciphers` method
2867+
returns information about ciphers for both TLS 1.3 and earlier versions
2868+
and the method :meth:`SSLSocket.cipher` returns information about the
2869+
negotiated cipher for both TLS 1.3 and earlier versions once a connection
2870+
is established.
28522871
- Session tickets are no longer sent as part of the initial handshake and
28532872
are handled differently. :attr:`SSLSocket.session` and :class:`SSLSession`
28542873
are not compatible with TLS 1.3.

Doc/library/stdtypes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,14 @@ expression support in the :mod:`re` module).
19111911
Return the lowest index in the string where substring *sub* is found within
19121912
the slice ``s[start:end]``. Optional arguments *start* and *end* are
19131913
interpreted as in slice notation. Return ``-1`` if *sub* is not found.
1914+
For example::
1915+
1916+
>>> 'spam, spam, spam'.find('sp')
1917+
0
1918+
>>> 'spam, spam, spam'.find('sp', 5)
1919+
6
1920+
1921+
See also :meth:`rfind` and :meth:`index`.
19141922

19151923
.. note::
19161924

Doc/library/unicodedata.rst

Lines changed: 68 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,80 +25,133 @@ Standard Annex #44, `"Unicode Character Database"
2525
<https://www.unicode.org/reports/tr44/>`_. It defines the
2626
following functions:
2727

28+
.. seealso::
29+
30+
The :ref:`unicode-howto` for more information about Unicode and how to use
31+
this module.
32+
2833

2934
.. function:: lookup(name)
3035

3136
Look up character by name. If a character with the given name is found, return
3237
the corresponding character. If not found, :exc:`KeyError` is raised.
38+
For example::
39+
40+
>>> unicodedata.lookup('LEFT CURLY BRACKET')
41+
'{'
42+
43+
The characters returned by this function are the same as those produced by
44+
``\N`` escape sequence in string literals. For example::
45+
46+
>>> unicodedata.lookup('MIDDLE DOT') == '\N{MIDDLE DOT}'
47+
True
3348

3449
.. versionchanged:: 3.3
3550
Support for name aliases [#]_ and named sequences [#]_ has been added.
3651

3752

38-
.. function:: name(chr[, default])
53+
.. function:: name(chr, default=None, /)
3954

4055
Returns the name assigned to the character *chr* as a string. If no
4156
name is defined, *default* is returned, or, if not given, :exc:`ValueError` is
42-
raised.
57+
raised. For example::
58+
59+
>>> unicodedata.name('½')
60+
'VULGAR FRACTION ONE HALF'
61+
>>> unicodedata.name('\uFFFF', 'fallback')
62+
'fallback'
4363

4464

45-
.. function:: decimal(chr[, default])
65+
.. function:: decimal(chr, default=None, /)
4666

4767
Returns the decimal value assigned to the character *chr* as integer.
4868
If no such value is defined, *default* is returned, or, if not given,
49-
:exc:`ValueError` is raised.
69+
:exc:`ValueError` is raised. For example::
5070

71+
>>> unicodedata.decimal('\N{ARABIC-INDIC DIGIT NINE}')
72+
9
73+
>>> unicodedata.decimal('\N{SUPERSCRIPT NINE}', -1)
74+
-1
5175

52-
.. function:: digit(chr[, default])
76+
77+
.. function:: digit(chr, default=None, /)
5378

5479
Returns the digit value assigned to the character *chr* as integer.
5580
If no such value is defined, *default* is returned, or, if not given,
56-
:exc:`ValueError` is raised.
81+
:exc:`ValueError` is raised::
82+
83+
>>> unicodedata.digit('\N{SUPERSCRIPT NINE}')
84+
9
5785

5886

59-
.. function:: numeric(chr[, default])
87+
.. function:: numeric(chr, default=None, /)
6088

6189
Returns the numeric value assigned to the character *chr* as float.
6290
If no such value is defined, *default* is returned, or, if not given,
63-
:exc:`ValueError` is raised.
91+
:exc:`ValueError` is raised::
92+
93+
>>> unicodedata.numeric('½')
94+
0.5
6495

6596

6697
.. function:: category(chr)
6798

6899
Returns the general category assigned to the character *chr* as
69-
string.
100+
string. General category names consist of two letters.
101+
See the `General Category Values section of the Unicode Character
102+
Database documentation <https://www.unicode.org/reports/tr44/#General_Category_Values>`_
103+
for a list of category codes. For example::
104+
105+
>>> unicodedata.category('A') # 'L'etter, 'u'ppercase
106+
'Lu'
70107

71108

72109
.. function:: bidirectional(chr)
73110

74111
Returns the bidirectional class assigned to the character *chr* as
75112
string. If no such value is defined, an empty string is returned.
113+
See the `Bidirectional Class Values section of the Unicode Character
114+
Database <https://www.unicode.org/reports/tr44/#Bidi_Class_Values>`_
115+
documentation for a list of bidirectional codes. For example::
116+
117+
>>> unicodedata.bidirectional('\N{ARABIC-INDIC DIGIT SEVEN}') # 'A'rabic, 'N'umber
118+
'AN'
76119

77120

78121
.. function:: combining(chr)
79122

80123
Returns the canonical combining class assigned to the character *chr*
81124
as integer. Returns ``0`` if no combining class is defined.
125+
See the `Canonical Combining Class Values section of the Unicode Character
126+
Database <www.unicode.org/reports/tr44/#Canonical_Combining_Class_Values>`_
127+
for more information.
82128

83129

84130
.. function:: east_asian_width(chr)
85131

86132
Returns the east asian width assigned to the character *chr* as
87-
string.
133+
string. For a list of widths and or more information, see the
134+
`Unicode Standard Annex #11 <https://www.unicode.org/reports/tr11/>`_.
88135

89136

90137
.. function:: mirrored(chr)
91138

92139
Returns the mirrored property assigned to the character *chr* as
93140
integer. Returns ``1`` if the character has been identified as a "mirrored"
94-
character in bidirectional text, ``0`` otherwise.
141+
character in bidirectional text, ``0`` otherwise. For example::
142+
143+
>>> unicodedata.mirrored('>')
144+
1
95145

96146

97147
.. function:: decomposition(chr)
98148

99149
Returns the character decomposition mapping assigned to the character
100150
*chr* as string. An empty string is returned in case no such mapping is
101-
defined.
151+
defined. For example::
152+
153+
>>> unicodedata.decomposition('Ã')
154+
'0041 0303'
102155

103156

104157
.. function:: normalize(form, unistr)
@@ -122,9 +175,9 @@ following functions:
122175
normally would be unified with other characters. For example, U+2160 (ROMAN
123176
NUMERAL ONE) is really the same thing as U+0049 (LATIN CAPITAL LETTER I).
124177
However, it is supported in Unicode for compatibility with existing character
125-
sets (e.g. gb2312).
178+
sets (for example, gb2312).
126179

127-
The normal form KD (NFKD) will apply the compatibility decomposition, i.e.
180+
The normal form KD (NFKD) will apply the compatibility decomposition, that is,
128181
replace all compatibility characters with their equivalents. The normal form KC
129182
(NFKC) first applies the compatibility decomposition, followed by the canonical
130183
composition.
@@ -133,6 +186,7 @@ following functions:
133186
a human reader, if one has combining characters and the other
134187
doesn't, they may not compare equal.
135188

189+
136190
.. function:: is_normalized(form, unistr)
137191

138192
Return whether the Unicode string *unistr* is in the normal form *form*. Valid
@@ -154,24 +208,6 @@ In addition, the module exposes the following constant:
154208
Unicode database version 3.2 instead, for applications that require this
155209
specific version of the Unicode database (such as IDNA).
156210

157-
Examples:
158-
159-
>>> import unicodedata
160-
>>> unicodedata.lookup('LEFT CURLY BRACKET')
161-
'{'
162-
>>> unicodedata.name('/')
163-
'SOLIDUS'
164-
>>> unicodedata.decimal('9')
165-
9
166-
>>> unicodedata.decimal('a')
167-
Traceback (most recent call last):
168-
File "<stdin>", line 1, in <module>
169-
ValueError: not a decimal
170-
>>> unicodedata.category('A') # 'L'etter, 'u'ppercase
171-
'Lu'
172-
>>> unicodedata.bidirectional('\u0660') # 'A'rabic, 'N'umber
173-
'AN'
174-
175211

176212
.. rubric:: Footnotes
177213

0 commit comments

Comments
 (0)