Sorry, something went wrong.
|
This PR is based on @erlend-aasland's PR #101948. Changes:
I copied the clinic_state() macros. Add the defining class to methods: (...) I was not sure that it works on static types... but it seems like it does :-) I didn't get any crash. |
Sorry, something went wrong.
|
@corona10 @erlend-aasland: Would you mind to review it? |
Sorry, something went wrong.
|
sure |
Sorry, something went wrong.
|
Oh, the Windows change didn't go well: 0:20:02 load avg: 8.57 [317/463/2] test_winconsoleio crashed (Exit code 3) -- (...)
Assertion failed: mod != NULL, file D:\a\cpython\cpython\Modules\_io\_iomodule.h, line 192
Fatal Python error: Aborted
Current thread 0x000004a0 (most recent call first):
File "D:\a\cpython\cpython\Lib\test\test_winconsoleio.py", line 104 in test_conin_conout_names
(...)
|
Sorry, something went wrong.
|
The failed assertion is: assert(PyObject_TypeCheck(self, find_io_state_by_def(Py_TYPE(self))->PyWindowsConsoleIO_Type));
in _io__WindowsConsoleIO___init___impl(). The assertion fails because PyType_GetModuleByDef() returns NULL. |
Sorry, something went wrong.
|
On static types, PyType_GetModuleByDef() always returns NULL, since the function reads PyHeapTypeObject.ht_module which only exists in heap types: if(!_PyType_HasFeature((PyTypeObject *)super, Py_TPFLAGS_HEAPTYPE)) {
// Static types in the MRO need to be skipped
continue;
}
|
Sorry, something went wrong.
|
Using APIs to get the module state from a type works on heap types like _io.FileIO, but failed on _io.WindowsConsoleIO which remains a static type with my PR. I fixed my PR by reverting changes related to WindowsConsoleIO: this type should be modified in a following PR. |
Sorry, something went wrong.
|
I reverted changes related to PyWindowsConsoleIO_Type and _io._WindowsConsoleIO.close(). |
Sorry, something went wrong.
|
I prefer doing Windows only changes in separate PRs. Everytime I touch Windows stuff, something weird happen :) |
Sorry, something went wrong.
|
Aha, now the CI pass. I would feel more comfortable with a review. @erlend-aasland: you can also review if you want, to check if i picked the right parts or tour code 😁 |
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm, let's wait refleak bot.
Sorry, something went wrong.
|
I was not sure that it works on static types... but it seems like it does :-) I didn't get any crash. I missed something: Erlend already converted multiple _io types to heap types: see commit c00faf7. Types used in this PR are heap types, that's why it just works! |
Sorry, something went wrong.
|
let's wait refleak bot Thanks for running these jobs. I ran refleaks locally on test_io, but i don't trust myself 🤣 So having reliable buildbot checks sound safer. I will merge my PR once the Refleaks jobs pass, unless someome wants me to wait for their second review. |
Sorry, something went wrong.
|
No refleaks; good bot 🤖 ✅ |
Sorry, something went wrong.
Add references to static types to _PyIO_State:
Add the defining class to methods:
Add get_io_state_by_cls() function.
Add state parameter to _textiowrapper_decode()
io_TextIOWrapper___init_() now sets self->state before calling _textiowrapper_set_decoder().