Skip to content

Commit 59e2238

Browse files
committed
Merge remote-tracking branch 'upstream/main' into fix-structseq-unnamed
2 parents 50a2e22 + b86a41c commit 59e2238

8 files changed

Lines changed: 104 additions & 54 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,14 @@ PCbuild/*-pgo
124124
PCbuild/*.VC.db
125125
PCbuild/*.VC.opendb
126126
PCbuild/amd64/
127+
PCbuild/amd64t/
127128
PCbuild/arm32/
129+
PCbuild/arm32t/
128130
PCbuild/arm64/
131+
PCbuild/arm64t/
129132
PCbuild/obj/
130133
PCbuild/win32/
134+
PCbuild/win32t/
131135
Tools/unicode/data/
132136
/autom4te.cache
133137
/build/

Doc/library/ctypes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,10 @@ like ``find_library("c")`` will fail and return ``None``.
18661866

18671867
.. availability:: Windows
18681868

1869+
.. soft-deprecated:: 3.16
1870+
This function now always returns ``None``, as there are no more
1871+
VC runtime DLLs that are a single file and supported by Microsoft.
1872+
18691873

18701874
.. _ctypes-listing-loaded-shared-libraries:
18711875

Doc/license.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,3 +1216,52 @@ license::
12161216
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
12171217
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
12181218
DAMAGE.
1219+
1220+
1221+
Unicode Character Database
1222+
--------------------------
1223+
1224+
An extract of the `Unicode Character Database <https://www.unicode.org/ucd/>`__,
1225+
converted to an internal format, is used by the :mod:`unicodedata` module and
1226+
for the Unicode support of the :class:`str` type. The original Unicode data
1227+
files are distributed under the `Unicode License <https://www.unicode.org/license.txt>`__::
1228+
1229+
UNICODE LICENSE V3
1230+
1231+
COPYRIGHT AND PERMISSION NOTICE
1232+
1233+
Copyright © 1991-2026 Unicode, Inc.
1234+
1235+
NOTICE TO USER: Carefully read the following legal agreement. BY
1236+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
1237+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
1238+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
1239+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
1240+
1241+
Permission is hereby granted, free of charge, to any person obtaining a
1242+
copy of data files and any associated documentation (the "Data Files") or
1243+
software and any associated documentation (the "Software") to deal in the
1244+
Data Files or Software without restriction, including without limitation
1245+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
1246+
copies of the Data Files or Software, and to permit persons to whom the
1247+
Data Files or Software are furnished to do so, provided that either (a)
1248+
this copyright and permission notice appear with all copies of the Data
1249+
Files or Software, or (b) this copyright and permission notice appear in
1250+
associated Documentation.
1251+
1252+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
1253+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1254+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
1255+
THIRD PARTY RIGHTS.
1256+
1257+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
1258+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
1259+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
1260+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
1261+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
1262+
FILES OR SOFTWARE.
1263+
1264+
Except as contained in this notice, the name of a copyright holder shall
1265+
not be used in advertising or otherwise to promote the sale, use or other
1266+
dealings in these Data Files or Software without prior written
1267+
authorization of the copyright holder.

Lib/asyncio/protocols.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,19 @@ def process_exited(self):
199199

200200
def _feed_data_to_buffered_proto(proto, data):
201201
data_len = len(data)
202+
start = 0
202203
while data_len:
203204
buf = proto.get_buffer(data_len)
204205
buf_len = len(buf)
205206
if not buf_len:
206207
raise RuntimeError('get_buffer() returned an empty buffer')
207208

208209
if buf_len >= data_len:
209-
buf[:data_len] = data
210+
buf[:data_len] = data[start:] if start else data
210211
proto.buffer_updated(data_len)
211212
return
212213
else:
213-
buf[:buf_len] = data[:buf_len]
214+
buf[:buf_len] = data[start:start + buf_len]
214215
proto.buffer_updated(buf_len)
215-
data = data[buf_len:]
216-
data_len = len(data)
216+
start += buf_len
217+
data_len -= buf_len

Lib/ctypes/util.py

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,19 @@
1313

1414
# find_library(name) returns the pathname of a library, or None.
1515
if os.name == "nt":
16-
17-
def _get_build_version():
18-
"""Return the version of MSVC that was used to build Python.
19-
20-
For Python 2.3 and up, the version number is included in
21-
sys.version. For earlier versions, assume the compiler is MSVC 6.
22-
"""
23-
# This function was copied from Lib/distutils/msvccompiler.py
24-
prefix = "MSC v."
25-
i = sys.version.find(prefix)
26-
if i == -1:
27-
return 6
28-
i = i + len(prefix)
29-
s, rest = sys.version[i:].split(" ", 1)
30-
majorVersion = int(s[:-2]) - 6
31-
if majorVersion >= 13:
32-
majorVersion += 1
33-
minorVersion = int(s[2:3]) / 10.0
34-
# I don't think paths are affected by minor version in version 6
35-
if majorVersion == 6:
36-
minorVersion = 0
37-
if majorVersion >= 6:
38-
return majorVersion + minorVersion
39-
# else we don't know what version of the compiler this is
40-
return None
41-
4216
def find_msvcrt():
43-
"""Return the name of the VC runtime dll"""
44-
version = _get_build_version()
45-
if version is None:
46-
# better be safe than sorry
47-
return None
48-
if version <= 6:
49-
clibname = 'msvcrt'
50-
elif version <= 13:
51-
clibname = 'msvcr%d' % (version * 10)
52-
else:
53-
# CRT is no longer directly loadable. See issue23606 for the
54-
# discussion about alternative approaches.
55-
return None
56-
57-
# If python was built with in debug mode
58-
import importlib.machinery
59-
if '_d.pyd' in importlib.machinery.EXTENSION_SUFFIXES:
60-
clibname += 'd'
61-
return clibname+'.dll'
17+
"""Return the name of the VC runtime dll.
18+
This is soft deprecated as of Python 3.16."""
19+
# See gh-154199. In short, this function wasn't able to return
20+
# newer msvcrt versions (because there was no single msvcrt DLL),
21+
# and the versions that are a single DLL are no longer supported
22+
# by Microsoft.
23+
return None
6224

6325
def find_library(name):
6426
if name in ('c', 'm'):
65-
return find_msvcrt()
27+
# See gh-67794; there is no single VC runtime DLL anymore.
28+
return None
6629
# See MSDN for the REAL search order.
6730
for directory in os.environ['PATH'].split(os.pathsep):
6831
fname = os.path.join(directory, name)

Lib/test/test_asyncio/test_protocols.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest import mock
33

44
import asyncio
5+
from asyncio import protocols
56

67

78
def tearDownModule():
@@ -63,5 +64,32 @@ def test_subprocess_protocol(self):
6364
self.assertNotHasAttr(sp, '__dict__')
6465

6566

66-
if __name__ == '__main__':
67+
class FeedDataToBufferedProtoTests(unittest.TestCase):
68+
def _make_proto(self, bufsize):
69+
received = bytearray()
70+
buf = bytearray(bufsize)
71+
72+
class P(asyncio.BufferedProtocol):
73+
def get_buffer(self, sizehint):
74+
return buf
75+
76+
def buffer_updated(self, nbytes):
77+
received.extend(buf[:nbytes])
78+
79+
return P(), received
80+
81+
def test_large_multi_iteration(self):
82+
proto, received = self._make_proto(64)
83+
data = bytes(range(256)) * 16
84+
protocols._feed_data_to_buffered_proto(proto, data)
85+
self.assertEqual(bytes(received), data)
86+
87+
def test_memoryview_input(self):
88+
proto, received = self._make_proto(64)
89+
payload = b"y" * 200
90+
protocols._feed_data_to_buffered_proto(proto, memoryview(payload))
91+
self.assertEqual(bytes(received), payload)
92+
93+
94+
if __name__ == "__main__":
6795
unittest.main()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make :func:`ctypes.util.find_msvcrt` always return ``None`` for
2+
compatibility reasons.

Modules/mathintegermodule.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,9 @@ that the bound `(a - 1)**2 < (n >> s) < (a + 1)**2` is maintained from one
180180
iteration to the next. A sketch of the proof of this is given below.
181181
182182
In addition to the proof sketch, a formal, computer-verified proof
183-
of correctness (using Lean) of an equivalent recursive algorithm can be found
184-
here:
183+
of correctness (using Lean) of the algorithm can be found here:
185184
186-
https://github.com/mdickinson/snippets/blob/master/proofs/isqrt/src/isqrt.lean
185+
https://github.com/mdickinson/snippets/tree/41ce2d256fef06fb32f24fe7014cfa95173ac5e0/proofs/isqrt
187186
188187
189188
Here's Python code equivalent to the C implementation below:

0 commit comments

Comments
 (0)