aio-libs / aio-libs/frozenlist
C extension: pickling any FrozenList raises TypeError (atomic[bint] not convertible)
- 主要言語
- Python
- スター
- 126
- フォーク
- 43
- 平均マージ
- 1時間 52分
- マージ済み PR(30日)
- 13
説明
**Version**: current master (`frozenlist 1.8.1.dev0`, commit after the free-threading changes)
**Platform**: Windows, CPython 3.13.7 — not platform-specific
### Summary
Any `FrozenList` instance fails to pickle when the C extension is used:
```python
import pickle
from frozenlist import FrozenList
fl = FrozenList([3, 1, 2])
fl.freeze()
pickle.dumps(fl)
```
```
TypeError: self._frozen cannot be converted to a Python object for pickling
```
The pure-Python implementation (`FROZENLIST_NO_EXTENSIONS=1`) round-trips fine on the same interpreter, so the two implementations have diverged.
### Root cause
`_frozenlist.pyx` declares `cdef atomic[bint] _frozen` (added for free-threading support). Cython's auto-generated `__reduce_cython__` cannot convert a `libcpp.atomic.atomic[bint]` member to a Python object, so pickling raises for every instance.
There is also no test coverage for pickling at all right now, which is why this went unnoticed.
### Suggested fix
An explicit `__reduce__` in the pyx class that serializes `(items, frozen)` through a small module-level constructor restores parity with the pure-Python implementation without giving up the atomic.
コントリビューションガイド
評価
この issue はまだ評価されていません。