gh-103583: Isolate CJK codec modules by erlend-aasland · Pull Request #103869 · python/cpython
Lifetime should be guaranteed, since each MultibyteCodecObjects owns a reference the cjk codec module that owns the memory of the MultibyteCodec struct.
This approach exploits the dependency introduced in gh-103589; we know for sure that the _codec* extension modules will outlive _multibytecodec. This means we can store the cjk codec module state safely in the codec struct and modify the various codec handlers to accept the codec struct (iso. void *config). Then we add custom cjk module state where needed, and conveniently fetch it from the codec struct. (Quick and dirty explanation; see the code if what I wrote does not make sense 😎)
🤖 New build scheduled with the buildbot fleet by @erlend-aasland for commit ef983c4 🤖
If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.
BTW, I removed the initialized guards. I'm pretty sure we can do that, but I haven't verified it yet.
🤖 New build scheduled with the buildbot fleet by @erlend-aasland for commit dec79a7 🤖
If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.
erlend-aasland
changed the title
gh-103583: Isolate CJK modules, alternative 2
gh-103583: Isolate CJK codec modules
This was referenced
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, This is quite a complicated but nice approach. But nothing can be better than this.
Thanks for the hard work!
Thanks for the review, Dong-hee! Yes, it is complicated, but as shown in my competing PRs, other approaches are even more complicated.