Jeong, YunWon
259ce8ce66
Fix the itertools.tee leak and race, the contextvars and generator races, _asyncio's InvalidStateError lookup, and _imp's frozen data ( #8518 )
...
* _imp: read get_frozen_object's data as a whole marshal value
The data argument went through deserialize_code(), which reads a code body
without the type byte in front of it, so nothing marshal.dumps() produces was
accepted. Read it with marshal.loads() and require a code object back.
Assisted-by: Claude
* _imp: bind find_frozen's arguments with FromArgs
The arity check was done by hand on a FuncArgs. Take the arguments through a
FromArgs struct instead, which makes withdata keyword-only, and fill in the
data it asks for: the frozen encoding is not marshal, so the code is
re-serialized into what get_frozen_object() reads back.
Assisted-by: Claude
* itertools: give tee's shared buffer a Python type
The buffer was a PyRc<PyItertoolsTeeData>, which is not a Python object, so the
collector could not walk into it and any cycle running through a tee was
uncollectable. Make it the _tee_dataobject type with a traverse, held by
PyRef, and split the rest along the same lines: tee() is a function, _tee is
the iterator type it builds, and _tee takes a single iterable rather than
returning a tuple from __new__. _tee is weak-referenceable, tee() rejects a
negative n with ValueError and reserves its tuple fallibly.
test_itertools.test_tee passes now; its expectedFailure marker is removed.
Assisted-by: Claude
* contextvars: hold the shared context state under locks
The variable map was a RefCell, the enter flag, the context index, the token's
used flag and the variable hash were Cells, and each carried an unsafe impl
Sync. A Context or ContextVar shared between threads overlapped their borrows
and panicked. The map and the per-variable cache are now PyMutex, the flags and
the index are atomics, entering a context is a compare_exchange, and the three
unsafe impl Sync are gone.
The cache also stopped being read through AtomicCell::as_ptr, which raced a
concurrent store on a value holding a PyObjectRef.
Values displaced from the map or the cache are dropped after the lock is
released: __del__ can come straight back into the same context, and the locks
are not reentrant.
Assisted-by: Claude
* generator: read the frame state under the running claim
send(), send_none(), throw() and close() read `closed` and `frame.lasti()`
before `running` was compare_exchanged, so the frame they went on to resume
could be one another thread had already advanced. A resume that decided from
`lasti() == 0` that the generator had not started pushes no value onto the
value stack, and the code after the yield pops one, which underflows the stack.
The compare_exchange now hands back a guard, taken before those reads and
released after maybe_close(), so the generator is retired while it is still
claimed.
Assisted-by: Claude
* itertools: claim a tee's position and its buffer as one step
`_tee::next` read `index` and moved it on afterwards, and
`_tee_dataobject::get_item` released `running` before the value it fetched
from the source was cached.
Two callers on one `_tee` then read the same index, hand out the same value
twice and advance past a value that was never cached, which leaves `index`
past `values.len()` and indexes the buffer out of bounds. Two callers at the
same index on separate tees each fetch a value from the source, and one of the
two is dropped without reaching a caller.
Both claims now cover the read and the update.
Assisted-by: Claude
* _asyncio: require InvalidStateError to be a type
new_invalid_state_error() called whatever `asyncio.exceptions.InvalidStateError`
names and unwrapped the downcast of the result, so a future asked for a result
it does not have panicked once that attribute was rebound to something that is
not an exception:
asyncio.InvalidStateError = lambda *args: 42
_asyncio.Future(loop=object()).result()
The type is looked up the way get_cancelled_error_type() looks its own up, and
raised with new_exception_msg; a lookup that does not produce an exception type
falls back to RuntimeError, as the other arms already did.
Assisted-by: Claude
2026-08-14 16:05:30 +09:00
..
2025-08-01 22:39:00 +09:00
2026-02-17 21:33:54 +09:00
2026-03-01 11:36:46 +09:00
2026-02-15 14:30:45 +09:00
2025-08-04 20:08:17 +09:00
2025-08-23 19:45:53 +03:00
2025-07-25 19:04:49 +09:00
2025-08-23 19:45:53 +03:00
2022-08-15 16:09:32 +09:00
2026-06-15 11:19:01 +09:00
2026-01-13 22:05:32 +09:00
2026-01-21 20:44:26 +09:00
2025-08-24 10:36:07 +03:00
2026-06-12 23:49:47 +09:00
2026-08-05 02:15:27 +09:00
2026-08-03 01:38:44 +09:00
2026-03-10 12:57:29 +09:00
2026-05-17 20:54:56 +09:00
2026-06-23 22:47:10 +09:00
2026-03-03 18:01:18 +09:00
2026-07-24 01:00:17 +09:00
2026-07-06 23:52:33 +09:00
2026-06-12 23:50:07 +09:00
2026-06-02 18:06:36 +09:00
2026-07-28 10:20:04 +09:00
2026-06-12 23:49:47 +09:00
2026-07-15 23:36:43 +09:00
2026-06-02 00:35:17 +09:00
2026-01-31 23:09:10 +09:00
2026-01-31 23:09:10 +09:00
2026-02-13 22:15:19 +09:00
2026-05-19 13:20:00 +09:00
2026-07-28 10:20:04 +09:00
2026-06-26 18:22:08 +09:00
2026-08-01 11:28:59 +09:00
2026-01-31 21:00:06 -05:00
2026-06-15 11:20:13 +09:00
2026-05-19 13:20:00 +09:00
2026-07-28 10:20:04 +09:00
2026-05-12 20:52:20 +09:00
2026-06-15 11:20:13 +09:00
2026-07-15 23:36:43 +09:00
2026-01-30 19:24:33 +09:00
2023-02-28 17:11:41 +09:00
2025-08-23 19:45:53 +03:00
2026-02-11 09:39:04 +09:00
2023-04-20 15:36:28 +09:00
2026-01-06 21:35:21 +09:00
2023-03-02 15:01:12 +09:00
2026-01-10 22:10:35 -05:00
2026-03-16 15:25:29 +09:00
2026-03-11 22:20:37 +09:00
2026-03-25 14:02:38 +09:00
2026-05-30 20:16:10 +09:00
2026-03-12 20:48:22 +09:00
2026-07-27 21:36:27 +09:00
2025-07-20 10:31:30 +09:00
2025-12-30 13:42:47 +09:00
2024-05-08 12:52:33 +09:00
2024-05-08 12:52:33 +09:00
2026-05-24 19:56:35 +09:00
2026-01-10 22:10:35 -05:00
2022-08-15 02:36:46 +09:00
2022-08-15 04:24:58 +09:00
2022-08-15 04:24:58 +09:00
2022-08-15 04:24:58 +09:00
2022-08-15 04:24:58 +09:00
2022-08-15 04:24:58 +09:00
2026-06-12 23:49:47 +09:00
2026-02-27 09:07:23 +09:00
2023-03-01 18:06:50 +09:00
2026-05-24 19:58:16 +09:00
2025-07-25 10:49:05 +09:00
2026-02-08 09:59:14 +09:00
2026-02-05 00:21:34 +09:00
2026-03-04 18:38:36 +09:00
2022-10-18 03:26:29 +09:00
2026-01-03 00:14:43 +09:00
2026-01-03 00:14:43 +09:00
2026-06-02 00:35:17 +09:00
2025-10-22 10:57:47 +03:00
2026-06-02 00:35:17 +09:00
2026-01-03 00:14:43 +09:00
2026-02-15 14:30:45 +09:00
2026-05-01 19:48:41 +09:00
2026-05-17 19:49:42 +09:00
2026-05-17 19:49:42 +09:00
2026-02-27 04:36:46 +09:00
2026-05-31 21:47:03 +09:00
2025-07-25 10:50:17 +09:00
2025-08-23 19:45:53 +03:00
2026-05-12 20:51:33 +09:00
2026-06-15 11:19:01 +09:00
2023-03-01 18:06:50 +09:00
2026-05-18 00:23:06 +09:00
2026-06-26 18:24:20 +09:00
2026-03-01 11:36:46 +09:00
2026-06-25 22:33:13 +09:00
2026-06-25 22:33:51 +09:00
2026-02-15 20:33:58 +09:00
2026-01-18 20:00:15 +09:00
2026-02-02 02:02:12 +09:00
2026-03-18 22:09:00 +09:00
2026-03-02 01:24:15 +09:00
2026-02-13 22:15:52 +09:00
2026-02-11 17:42:16 +09:00
2026-06-02 18:00:54 +09:00
2026-05-13 19:53:18 +09:00
2026-01-25 15:20:05 +09:00
2026-05-12 00:53:22 +09:00
2026-07-15 23:18:03 +09:00
2026-05-19 13:20:00 +09:00
2026-02-02 10:03:42 +09:00
2026-02-27 19:29:59 +09:00
2026-06-26 18:22:08 +09:00
2026-04-19 09:14:46 +09:00
2026-06-25 22:33:51 +09:00
2026-05-24 19:56:35 +09:00
2023-11-23 15:40:57 +08:00
2026-08-03 17:52:42 +09:00
2026-07-27 21:43:15 +09:00
2026-02-08 10:00:50 +09:00
2026-04-15 14:17:48 +09:00
2026-02-13 13:36:33 +02:00
2026-02-13 13:36:33 +02:00
2026-02-13 14:13:30 +09:00
2026-06-26 18:22:08 +09:00
2026-07-22 20:32:39 +09:00
2026-07-21 00:30:10 +09:00
2026-02-21 14:12:18 +09:00
2026-05-12 20:53:03 +09:00
2026-04-30 04:40:44 +09:00
2026-05-10 00:30:26 +09:00
2026-05-19 13:31:33 +09:00
2026-05-19 13:20:00 +09:00
2026-04-19 09:14:35 +09:00
2026-06-26 18:22:08 +09:00
2026-06-16 15:58:12 +09:00
2026-01-24 11:37:32 +09:00
2026-08-14 00:57:10 +09:00
2026-06-10 11:14:47 +09:00
2026-02-02 12:50:34 +09:00
2026-02-15 14:37:06 +09:00
2026-02-15 14:37:06 +09:00
2026-02-15 14:37:06 +09:00
2026-02-15 14:37:06 +09:00
2026-02-15 14:37:06 +09:00
2026-02-15 14:37:06 +09:00
2026-02-15 14:32:53 +09:00
2026-02-15 14:33:05 +09:00
2026-02-15 14:33:16 +09:00
2026-06-22 16:46:53 +09:00
2026-06-22 16:46:53 +09:00
2026-05-12 20:54:11 +09:00
2026-06-26 18:22:08 +09:00
2026-04-28 21:09:16 +09:00
2024-03-13 15:22:57 +09:00
2023-11-30 20:01:48 +08:00
2026-06-26 18:22:08 +09:00
2026-02-25 21:15:55 +09:00
2026-01-27 10:49:05 +09:00
2026-01-27 10:49:05 +09:00
2026-05-10 00:28:13 +09:00
2026-05-12 00:53:36 +09:00
2026-04-29 18:29:31 +09:00
2026-05-10 00:28:30 +09:00
2026-05-12 00:41:05 +09:00
2026-05-12 00:40:32 +09:00
2026-02-10 00:05:15 +09:00
2024-06-24 19:00:54 +09:00
2026-05-05 14:04:12 +09:00
2026-05-31 21:47:03 +09:00
2026-08-01 11:35:37 +09:00
2026-05-12 00:42:10 +09:00
2026-01-01 14:44:53 +09:00
2026-01-19 02:45:47 +09:00
2026-02-11 16:50:23 +09:00
2026-06-12 23:49:15 +09:00
2026-04-19 22:33:27 +09:00
2026-06-02 18:00:54 +09:00
2026-06-12 23:50:07 +09:00
2026-07-08 15:21:41 +09:00
2026-02-15 09:03:56 +09:00
2023-04-02 13:42:27 +00:00
2026-07-30 07:53:35 +09:00
2026-02-13 13:36:33 +02:00
2026-04-30 04:45:23 +09:00
2026-02-08 20:36:35 +09:00
2026-02-08 20:36:35 +09:00
2026-05-28 09:19:11 +09:00
2022-08-09 03:36:26 +09:00
2026-02-13 18:07:25 +09:00
2026-06-25 22:33:51 +09:00
2023-02-28 17:11:41 +09:00
2023-02-28 17:11:41 +09:00
2026-03-01 10:39:06 +09:00
2026-03-01 19:27:33 +09:00
2023-11-30 21:01:17 +08:00
2026-05-30 20:16:10 +09:00
2026-05-12 00:39:37 +09:00
2026-06-12 23:49:15 +09:00
2025-07-25 10:43:16 +09:00
2026-08-09 14:58:53 +09:00
2023-11-30 21:06:09 +08:00
2026-02-10 00:48:22 +09:00
2026-01-31 05:49:16 +09:00
2026-06-25 22:33:51 +09:00
2026-01-31 05:49:16 +09:00
2026-01-31 05:49:16 +09:00
2026-08-09 14:58:53 +09:00
2026-02-12 01:01:35 +09:00
2026-07-02 16:32:33 +09:00
2026-02-22 21:31:42 +09:00
2026-06-15 11:20:13 +09:00
2026-06-01 00:08:40 +09:00
2026-04-03 00:49:55 +09:00
2026-01-03 08:27:18 +09:00
2026-05-12 20:52:08 +09:00
2026-02-16 00:31:57 +09:00
2026-06-25 22:33:51 +09:00
2026-05-10 00:28:50 +09:00
2026-07-26 14:31:34 +09:00
2026-02-13 13:36:33 +02:00
2026-02-13 22:15:19 +09:00
2026-03-07 20:20:16 +09:00
2026-08-09 14:58:07 +09:00
2026-04-19 09:15:12 +09:00
2026-07-08 15:21:41 +09:00
2026-02-09 01:40:26 +09:00
2026-06-26 18:22:08 +09:00
2026-06-12 23:49:15 +09:00
2026-08-08 02:25:21 +09:00
2026-05-12 20:54:18 +09:00
2026-05-30 20:16:10 +09:00
2026-05-19 13:20:00 +09:00
2026-04-29 18:52:22 +09:00
2026-08-01 00:59:41 +09:00
2026-06-12 23:50:07 +09:00
2026-02-03 14:58:43 +09:00
2026-02-03 22:10:31 +09:00
2026-06-26 18:22:08 +09:00
2026-02-08 16:35:56 +09:00
2026-02-08 16:35:56 +09:00
2026-03-29 00:52:34 +09:00
2026-02-13 22:15:19 +09:00
2026-06-26 18:22:08 +09:00
2026-06-30 23:32:30 +09:00
2026-01-18 01:23:34 +09:00
2026-06-12 23:50:07 +09:00
2026-02-06 00:15:18 +09:00
2026-05-19 13:31:33 +09:00
2026-06-10 11:14:05 +09:00
2026-01-18 01:23:34 +09:00
2026-03-01 10:51:39 +09:00
2026-01-24 19:12:23 +09:00
2026-02-27 05:44:37 +00:00
2026-06-12 23:49:47 +09:00
2026-05-17 19:49:19 +09:00
2026-02-27 05:44:37 +00:00
2026-06-15 11:21:28 +09:00
2026-06-12 23:50:07 +09:00
2026-04-28 21:10:42 +09:00
2026-07-08 15:21:41 +09:00
2026-06-15 11:20:13 +09:00
2026-01-18 01:23:34 +09:00
2026-05-10 00:29:05 +09:00
2026-05-18 00:23:06 +09:00
2022-08-15 04:24:58 +09:00
2026-08-14 16:05:30 +09:00
2024-06-21 22:37:15 +09:00
2026-02-14 21:40:04 +09:00
2025-08-31 10:35:23 +03:00
2026-04-03 00:49:55 +09:00
2026-02-15 22:11:48 +09:00
2026-02-09 12:56:53 +09:00
2026-07-15 23:43:29 +09:00
2026-06-30 23:32:30 +09:00
2026-03-06 06:00:08 +09:00
2026-05-12 00:42:54 +09:00
2026-02-13 13:55:05 +09:00
2026-07-15 23:16:42 +09:00
2026-02-14 18:19:57 +02:00
2026-08-14 12:58:42 +09:00
2025-08-23 22:09:11 +03:00
2026-05-19 13:31:33 +09:00
2026-07-24 01:00:17 +09:00
2026-07-22 20:31:31 +09:00
2026-05-20 08:59:59 +09:00
2026-06-12 23:50:07 +09:00
2026-07-18 16:46:57 +09:00
2026-07-02 16:32:33 +09:00
2026-08-09 15:06:48 +09:00
2026-07-08 15:21:41 +09:00
2026-07-02 16:32:33 +09:00
2026-05-31 21:47:03 +09:00
2024-04-24 01:15:34 +09:00
2026-06-26 18:22:08 +09:00
2025-08-20 14:08:05 +09:00
2026-01-25 00:18:55 +09:00
2026-01-25 00:18:55 +09:00
2024-07-29 19:53:44 +09:00
2026-04-03 01:33:34 +09:00
2026-01-26 10:40:22 +09:00
2026-02-14 09:17:41 +09:00
2026-04-03 01:33:50 +09:00
2026-01-30 20:48:57 +09:00
2026-05-18 00:23:06 +09:00
2026-06-16 15:58:12 +09:00
2026-01-31 19:56:55 -05:00
2026-06-30 23:32:30 +09:00
2026-07-28 10:20:04 +09:00
2026-06-26 18:22:08 +09:00
2026-06-30 23:32:30 +09:00
2026-04-03 00:50:25 +09:00
2026-05-24 19:58:16 +09:00
2026-02-05 19:27:10 +09:00
2026-02-05 19:27:10 +09:00
2026-05-19 13:31:33 +09:00
2026-07-07 09:19:25 +09:00
2026-05-12 00:43:49 +09:00
2026-05-12 20:49:48 +09:00
2026-06-11 13:36:51 +09:00
2026-02-03 22:10:31 +09:00
2026-03-12 18:08:56 +09:00
2026-05-20 08:59:59 +09:00
2026-06-02 18:00:54 +09:00
2026-02-13 20:24:57 +09:00
2025-08-31 11:58:21 +03:00
2026-02-06 01:14:55 +09:00
2026-02-13 13:36:33 +02:00
2026-05-31 21:47:03 +09:00
2026-02-13 13:42:52 +09:00
2026-06-15 11:20:13 +09:00
2026-07-26 13:30:48 +09:00
2026-07-09 20:24:16 +09:00
2026-06-12 23:50:07 +09:00
2026-05-23 20:16:03 +09:00
2026-05-22 03:53:35 +09:00
2026-07-13 18:40:18 +09:00
2026-02-04 18:32:45 +09:00
2025-07-17 00:03:25 +09:00
2026-03-03 19:57:50 +09:00
2026-02-28 22:50:51 +09:00
2026-04-15 14:15:27 +09:00
2026-07-28 10:20:04 +09:00
2026-07-18 16:46:57 +09:00
2026-06-26 18:22:08 +09:00
2026-08-08 02:25:21 +09:00
2026-07-15 23:16:42 +09:00
2026-02-16 01:19:57 +09:00
2026-06-12 23:49:47 +09:00
2026-05-12 20:52:36 +09:00
2026-05-12 20:51:46 +09:00
2026-07-09 20:24:16 +09:00
2025-04-21 21:11:42 -07:00
2026-03-31 15:45:18 +09:00
2026-05-30 20:16:10 +09:00
2026-01-31 20:51:53 -05:00
2025-12-12 10:37:40 +09:00
2026-08-13 04:31:53 +09:00
2026-02-03 13:41:58 +09:00
2026-01-01 17:15:00 +09:00
2026-07-24 01:00:17 +09:00
2026-06-12 23:49:47 +09:00
2026-06-15 11:12:39 +09:00
2026-05-12 00:43:34 +09:00
2026-05-18 00:23:06 +09:00
2026-02-14 21:40:04 +09:00
2026-05-12 20:51:57 +09:00
2026-07-15 23:16:42 +09:00
2026-05-22 20:10:49 +09:00
2026-05-19 13:31:33 +09:00
2026-08-10 00:43:44 +09:00
2026-02-18 03:09:55 +09:00
2026-02-14 09:18:09 +09:00
2026-02-11 18:01:41 +09:00
2026-07-29 20:27:59 +09:00
2026-02-14 09:13:06 +09:00
2026-03-01 10:42:37 +09:00
2025-03-26 23:12:21 -05:00
2026-05-12 00:42:10 +09:00
2026-05-23 20:16:03 +09:00
2026-07-25 19:59:05 +09:00
2026-08-14 00:57:10 +09:00
2026-02-02 08:11:26 +09:00
2026-06-26 18:23:54 +09:00
2026-02-13 13:42:38 +09:00
2026-06-30 23:32:30 +09:00
2026-07-15 23:36:43 +09:00
2026-07-02 16:41:31 +09:00
2026-06-26 18:22:08 +09:00
2026-06-26 18:22:08 +09:00
2026-06-03 22:51:41 +09:00
2026-03-21 22:49:09 +09:00
2026-05-12 00:43:18 +09:00
2026-06-03 22:51:41 +09:00
2026-03-10 11:28:16 +09:00
2026-06-12 23:49:47 +09:00
2026-06-25 22:32:57 +09:00
2026-07-26 13:30:48 +09:00
2026-01-30 20:48:57 +09:00
2026-06-03 09:52:32 +00:00
2026-07-22 20:34:20 +09:00
2026-06-03 09:52:32 +00:00
2026-07-26 13:47:35 +09:00
2026-06-03 09:52:32 +00:00
2026-02-02 08:08:29 +09:00
2026-02-15 14:37:48 +09:00
2026-05-12 20:53:11 +09:00
2026-05-22 20:11:27 +09:00
2026-08-09 14:58:53 +09:00
2026-03-04 05:38:58 +09:00
2026-07-08 15:21:41 +09:00
2026-05-31 21:47:03 +09:00
2026-04-18 15:17:56 +09:00
2026-06-11 12:15:21 +09:00
2026-03-03 21:58:46 +09:00
2026-06-03 18:36:37 +09:00
2026-02-11 09:39:04 +09:00
2026-08-12 16:22:05 +09:00
2026-05-19 13:20:00 +09:00
2026-06-26 18:22:08 +09:00
2026-06-26 18:22:08 +09:00
2026-08-01 14:38:58 +09:00
2026-06-11 13:36:40 +09:00
2026-05-30 20:16:10 +09:00
2025-01-17 18:04:25 -08:00
2026-05-30 20:16:10 +09:00
2025-07-12 20:44:34 +09:00
2026-05-30 20:16:10 +09:00
2026-06-14 17:47:42 +09:00
2025-08-31 12:13:09 +03:00
2026-06-26 18:22:08 +09:00
2026-06-11 13:36:51 +09:00
2026-02-05 16:20:22 +09:00
2026-04-14 08:58:51 +02:00
2026-01-25 00:18:55 +09:00
2026-01-25 00:18:55 +09:00
2026-01-16 23:03:49 +09:00
2026-02-13 13:44:28 +09:00
2026-01-25 00:18:55 +09:00
2026-02-14 09:32:17 +09:00
2026-04-29 18:16:27 +09:00
2026-05-10 00:29:27 +09:00
2026-05-03 00:15:03 +09:00
2026-06-11 13:36:51 +09:00
2026-03-03 21:27:11 +09:00
2026-06-02 18:00:54 +09:00
2026-06-22 16:46:53 +09:00
2025-07-25 10:49:05 +09:00
2025-07-25 10:49:05 +09:00
2026-02-13 13:42:22 +09:00
2026-07-18 23:47:03 +09:00
2026-04-30 04:45:43 +09:00
2026-05-13 19:53:31 +09:00
2026-01-25 00:18:55 +09:00
2026-06-22 16:46:53 +09:00
2026-02-15 22:11:48 +09:00
2026-06-22 16:46:53 +09:00
2026-05-12 22:14:24 +09:00
2026-06-22 16:46:53 +09:00
2026-05-12 00:44:05 +09:00
2024-06-22 15:24:42 +09:00
2025-12-30 00:36:52 +09:00
2026-03-03 20:00:30 +09:00
2026-07-18 16:46:57 +09:00
2026-06-15 11:19:40 +09:00
2026-05-18 00:23:34 +09:00
2026-05-19 13:20:00 +09:00
2026-05-19 13:20:00 +09:00
2026-04-29 18:52:22 +09:00
2026-03-05 17:25:59 +09:00
2025-12-17 00:28:06 +09:00
2026-06-25 22:33:51 +09:00
2026-01-24 16:11:36 +09:00
2026-01-19 00:38:51 +09:00
2026-01-19 00:38:51 +09:00
2023-06-01 15:29:16 +09:00
2023-04-20 15:36:28 +09:00
2026-05-18 00:23:34 +09:00