Skip to content

Commit 779123c

Browse files
committed
update to python 3.12.9
1 parent 6f3d57b commit 779123c

File tree

125 files changed

+683
-453
lines changed

Some content is hidden

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

125 files changed

+683
-453
lines changed

.github/workflows/CI_build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ jobs:
4343
if: matrix.build_configuration == 'Release'
4444
working-directory: installer
4545
run: |
46-
$env:PYTHONBUILDDIR_X64='${{ github.workspace }}\packages\python.3.12.8\tools'
47-
$env:PYTHONBUILDDIR='${{ github.workspace }}\packages\pythonx86.3.12.8\tools'
46+
$env:PYTHONBUILDDIR_X64='${{ github.workspace }}\packages\python.3.12.9\tools'
47+
$env:PYTHONBUILDDIR='${{ github.workspace }}\packages\pythonx86.3.12.9\tools'
4848
Rename-Item -Path ".\buildPaths.bat.orig" -NewName "buildPaths.bat"
4949
dotnet tool install --global wix
5050
.\buildAll.bat ${{ matrix.build_platform }}

PythonLib/full/_pydatetime.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,6 @@ def __reduce__(self):
23132313

23142314
def _isoweek1monday(year):
23152315
# Helper to calculate the day number of the Monday starting week 1
2316-
# XXX This could be done more efficiently
23172316
THURSDAY = 3
23182317
firstday = _ymd2ord(year, 1, 1)
23192318
firstweekday = (firstday + 6) % 7 # See weekday() above

PythonLib/full/_pydecimal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class DecimalException(ArithmeticError):
9797
9898
Used exceptions derive from this.
9999
If an exception derives from another exception besides this (such as
100-
Underflow (Inexact, Rounded, Subnormal) that indicates that it is only
100+
Underflow (Inexact, Rounded, Subnormal)) that indicates that it is only
101101
called if the others are present. This isn't actually used for
102102
anything, though.
103103
@@ -145,7 +145,7 @@ class InvalidOperation(DecimalException):
145145
x ** (+-)INF
146146
An operand is invalid
147147
148-
The result of the operation after these is a quiet positive NaN,
148+
The result of the operation after this is a quiet positive NaN,
149149
except when the cause is a signaling NaN, in which case the result is
150150
also a quiet NaN, but with the original sign, and an optional
151151
diagnostic information.

PythonLib/full/_strptime.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ def __init__(self, locale_time=None):
300300
'V': r"(?P<V>5[0-3]|0[1-9]|[1-4]\d|\d)",
301301
# W is set below by using 'U'
302302
'y': r"(?P<y>\d\d)",
303-
#XXX: Does 'Y' need to worry about having less or more than
304-
# 4 digits?
305303
'Y': r"(?P<Y>\d\d\d\d)",
306304
'z': r"(?P<z>[+-]\d\d:?[0-5]\d(:?[0-5]\d(\.\d{1,6})?)?|(?-i:Z))",
307305
'A': self.__seqToRE(self.locale_time.f_weekday, 'A'),

PythonLib/full/ast.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,9 +1246,14 @@ def visit_JoinedStr(self, node):
12461246
fallback_to_repr = True
12471247
break
12481248
quote_types = new_quote_types
1249-
elif "\n" in value:
1250-
quote_types = [q for q in quote_types if q in _MULTI_QUOTES]
1251-
assert quote_types
1249+
else:
1250+
if "\n" in value:
1251+
quote_types = [q for q in quote_types if q in _MULTI_QUOTES]
1252+
assert quote_types
1253+
1254+
new_quote_types = [q for q in quote_types if q not in value]
1255+
if new_quote_types:
1256+
quote_types = new_quote_types
12521257
new_fstring_parts.append(value)
12531258

12541259
if fallback_to_repr:

PythonLib/full/asyncio/base_events.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,12 @@ def create_task(self, coro, *, name=None, context=None):
466466

467467
tasks._set_task_name(task, name)
468468

469-
return task
469+
try:
470+
return task
471+
finally:
472+
# gh-128552: prevent a refcycle of
473+
# task.exception().__traceback__->BaseEventLoop.create_task->task
474+
del task
470475

471476
def set_task_factory(self, factory):
472477
"""Set a task factory that will be used by loop.create_task().
@@ -1550,7 +1555,9 @@ async def create_server(
15501555
if reuse_address:
15511556
sock.setsockopt(
15521557
socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
1553-
if reuse_port:
1558+
# Since Linux 6.12.9, SO_REUSEPORT is not allowed
1559+
# on other address families than AF_INET/AF_INET6.
1560+
if reuse_port and af in (socket.AF_INET, socket.AF_INET6):
15541561
_set_reuseport(sock)
15551562
# Disable IPv4/IPv6 dual stack support (enabled by
15561563
# default on Linux) which makes a single socket

PythonLib/full/asyncio/locks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ class Barrier(mixins._LoopBoundMixin):
454454
def __init__(self, parties):
455455
"""Create a barrier, initialised to 'parties' tasks."""
456456
if parties < 1:
457-
raise ValueError('parties must be > 0')
457+
raise ValueError('parties must be >= 1')
458458

459459
self._cond = Condition() # notify all tasks when state changes
460460

PythonLib/full/asyncio/runners.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def run(main, *, debug=None, loop_factory=None):
168168
running in the same thread.
169169
170170
If debug is True, the event loop will be run in debug mode.
171+
If loop_factory is passed, it is used for new event loop creation.
171172
172173
This function always creates a new event loop and closes it at the end.
173174
It should be used as a main entry point for asyncio programs, and should

PythonLib/full/asyncio/selector_events.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,15 +1183,19 @@ def writelines(self, list_of_data):
11831183
# If the entire buffer couldn't be written, register a write handler
11841184
if self._buffer:
11851185
self._loop._add_writer(self._sock_fd, self._write_ready)
1186+
self._maybe_pause_protocol()
11861187

11871188
def can_write_eof(self):
11881189
return True
11891190

11901191
def _call_connection_lost(self, exc):
1191-
super()._call_connection_lost(exc)
1192-
if self._empty_waiter is not None:
1193-
self._empty_waiter.set_exception(
1194-
ConnectionError("Connection is closed by peer"))
1192+
try:
1193+
super()._call_connection_lost(exc)
1194+
finally:
1195+
self._write_ready = None
1196+
if self._empty_waiter is not None:
1197+
self._empty_waiter.set_exception(
1198+
ConnectionError("Connection is closed by peer"))
11951199

11961200
def _make_empty_waiter(self):
11971201
if self._empty_waiter is not None:
@@ -1206,7 +1210,6 @@ def _reset_empty_waiter(self):
12061210

12071211
def close(self):
12081212
self._read_ready_cb = None
1209-
self._write_ready = None
12101213
super().close()
12111214

12121215

PythonLib/full/asyncio/staggered.py

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,27 @@ async def staggered_race(coro_fns, delay, *, loop=None):
6666
enum_coro_fns = enumerate(coro_fns)
6767
winner_result = None
6868
winner_index = None
69+
unhandled_exceptions = []
6970
exceptions = []
70-
running_tasks = []
71+
running_tasks = set()
72+
on_completed_fut = None
73+
74+
def task_done(task):
75+
running_tasks.discard(task)
76+
if (
77+
on_completed_fut is not None
78+
and not on_completed_fut.done()
79+
and not running_tasks
80+
):
81+
on_completed_fut.set_result(None)
82+
83+
if task.cancelled():
84+
return
85+
86+
exc = task.exception()
87+
if exc is None:
88+
return
89+
unhandled_exceptions.append(exc)
7190

7291
async def run_one_coro(ok_to_start, previous_failed) -> None:
7392
# in eager tasks this waits for the calling task to append this task
@@ -91,11 +110,11 @@ async def run_one_coro(ok_to_start, previous_failed) -> None:
91110
this_failed = locks.Event()
92111
next_ok_to_start = locks.Event()
93112
next_task = loop.create_task(run_one_coro(next_ok_to_start, this_failed))
94-
running_tasks.append(next_task)
113+
running_tasks.add(next_task)
114+
next_task.add_done_callback(task_done)
95115
# next_task has been appended to running_tasks so next_task is ok to
96116
# start.
97117
next_ok_to_start.set()
98-
assert len(running_tasks) == this_index + 2
99118
# Prepare place to put this coroutine's exceptions if not won
100119
exceptions.append(None)
101120
assert len(exceptions) == this_index + 1
@@ -120,31 +139,36 @@ async def run_one_coro(ok_to_start, previous_failed) -> None:
120139
# up as done() == True, cancelled() == False, exception() ==
121140
# asyncio.CancelledError. This behavior is specified in
122141
# https://bugs.python.org/issue30048
123-
for i, t in enumerate(running_tasks):
124-
if i != this_index:
142+
current_task = tasks.current_task(loop)
143+
for t in running_tasks:
144+
if t is not current_task:
125145
t.cancel()
126146

127-
ok_to_start = locks.Event()
128-
first_task = loop.create_task(run_one_coro(ok_to_start, None))
129-
running_tasks.append(first_task)
130-
# first_task has been appended to running_tasks so first_task is ok to start.
131-
ok_to_start.set()
147+
propagate_cancellation_error = None
132148
try:
133-
# Wait for a growing list of tasks to all finish: poor man's version of
134-
# curio's TaskGroup or trio's nursery
135-
done_count = 0
136-
while done_count != len(running_tasks):
137-
done, _ = await tasks.wait(running_tasks)
138-
done_count = len(done)
149+
ok_to_start = locks.Event()
150+
first_task = loop.create_task(run_one_coro(ok_to_start, None))
151+
running_tasks.add(first_task)
152+
first_task.add_done_callback(task_done)
153+
# first_task has been appended to running_tasks so first_task is ok to start.
154+
ok_to_start.set()
155+
propagate_cancellation_error = None
156+
# Make sure no tasks are left running if we leave this function
157+
while running_tasks:
158+
on_completed_fut = loop.create_future()
159+
try:
160+
await on_completed_fut
161+
except exceptions_mod.CancelledError as ex:
162+
propagate_cancellation_error = ex
163+
for task in running_tasks:
164+
task.cancel(*ex.args)
165+
on_completed_fut = None
166+
if __debug__ and unhandled_exceptions:
139167
# If run_one_coro raises an unhandled exception, it's probably a
140168
# programming error, and I want to see it.
141-
if __debug__:
142-
for d in done:
143-
if d.done() and not d.cancelled() and d.exception():
144-
raise d.exception()
169+
raise ExceptionGroup("staggered race failed", unhandled_exceptions)
170+
if propagate_cancellation_error is not None:
171+
raise propagate_cancellation_error
145172
return winner_result, winner_index, exceptions
146173
finally:
147-
del exceptions
148-
# Make sure no tasks are left running if we leave this function
149-
for t in running_tasks:
150-
t.cancel()
174+
del exceptions, propagate_cancellation_error, unhandled_exceptions

0 commit comments

Comments
 (0)