From e1b3d3d5bf3aeec67fbd6240ad88bdbead77b297 Mon Sep 17 00:00:00 2001 From: AN Long Date: Fri, 17 Nov 2023 15:37:35 +0800 Subject: [PATCH 1/7] add critical section for io.TextIOWrapper --- Modules/_io/clinic/textio.c.h | 86 +++++++++++++++++++++++++++++++---- Modules/_io/textio.c | 46 +++++++++++++------ 2 files changed, 107 insertions(+), 25 deletions(-) diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h index b24a1669f9b344..76bf484f657656 100644 --- a/Modules/_io/clinic/textio.c.h +++ b/Modules/_io/clinic/textio.c.h @@ -630,7 +630,9 @@ _io_TextIOWrapper_reconfigure(textio *self, PyObject *const *args, Py_ssize_t na } write_through_obj = args[4]; skip_optional_kwonly: + Py_BEGIN_CRITICAL_SECTION(self); return_value = _io_TextIOWrapper_reconfigure_impl(self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj); + Py_END_CRITICAL_SECTION(); exit: return return_value; @@ -650,7 +652,13 @@ _io_TextIOWrapper_detach_impl(textio *self); static PyObject * _io_TextIOWrapper_detach(textio *self, PyObject *Py_UNUSED(ignored)) { - return _io_TextIOWrapper_detach_impl(self); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_TextIOWrapper_detach_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; } PyDoc_STRVAR(_io_TextIOWrapper_write__doc__, @@ -675,7 +683,9 @@ _io_TextIOWrapper_write(textio *self, PyObject *arg) goto exit; } text = arg; + Py_BEGIN_CRITICAL_SECTION(self); return_value = _io_TextIOWrapper_write_impl(self, text); + Py_END_CRITICAL_SECTION(); exit: return return_value; @@ -708,7 +718,9 @@ _io_TextIOWrapper_read(textio *self, PyObject *const *args, Py_ssize_t nargs) goto exit; } skip_optional: + Py_BEGIN_CRITICAL_SECTION(self); return_value = _io_TextIOWrapper_read_impl(self, n); + Py_END_CRITICAL_SECTION(); exit: return return_value; @@ -750,7 +762,9 @@ _io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs size = ival; } skip_optional: + Py_BEGIN_CRITICAL_SECTION(self); return_value = _io_TextIOWrapper_readline_impl(self, size); + Py_END_CRITICAL_SECTION(); exit: return return_value; @@ -804,7 +818,9 @@ _io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs) goto exit; } skip_optional: + Py_BEGIN_CRITICAL_SECTION(self); return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence); + Py_END_CRITICAL_SECTION(); exit: return return_value; @@ -828,7 +844,13 @@ _io_TextIOWrapper_tell_impl(textio *self); static PyObject * _io_TextIOWrapper_tell(textio *self, PyObject *Py_UNUSED(ignored)) { - return _io_TextIOWrapper_tell_impl(self); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_TextIOWrapper_tell_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; } PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__, @@ -856,7 +878,9 @@ _io_TextIOWrapper_truncate(textio *self, PyObject *const *args, Py_ssize_t nargs } pos = args[0]; skip_optional: + Py_BEGIN_CRITICAL_SECTION(self); return_value = _io_TextIOWrapper_truncate_impl(self, pos); + Py_END_CRITICAL_SECTION(); exit: return return_value; @@ -876,7 +900,13 @@ _io_TextIOWrapper_fileno_impl(textio *self); static PyObject * _io_TextIOWrapper_fileno(textio *self, PyObject *Py_UNUSED(ignored)) { - return _io_TextIOWrapper_fileno_impl(self); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_TextIOWrapper_fileno_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; } PyDoc_STRVAR(_io_TextIOWrapper_seekable__doc__, @@ -893,7 +923,13 @@ _io_TextIOWrapper_seekable_impl(textio *self); static PyObject * _io_TextIOWrapper_seekable(textio *self, PyObject *Py_UNUSED(ignored)) { - return _io_TextIOWrapper_seekable_impl(self); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_TextIOWrapper_seekable_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; } PyDoc_STRVAR(_io_TextIOWrapper_readable__doc__, @@ -910,7 +946,13 @@ _io_TextIOWrapper_readable_impl(textio *self); static PyObject * _io_TextIOWrapper_readable(textio *self, PyObject *Py_UNUSED(ignored)) { - return _io_TextIOWrapper_readable_impl(self); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_TextIOWrapper_readable_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; } PyDoc_STRVAR(_io_TextIOWrapper_writable__doc__, @@ -927,7 +969,13 @@ _io_TextIOWrapper_writable_impl(textio *self); static PyObject * _io_TextIOWrapper_writable(textio *self, PyObject *Py_UNUSED(ignored)) { - return _io_TextIOWrapper_writable_impl(self); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_TextIOWrapper_writable_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; } PyDoc_STRVAR(_io_TextIOWrapper_isatty__doc__, @@ -944,7 +992,13 @@ _io_TextIOWrapper_isatty_impl(textio *self); static PyObject * _io_TextIOWrapper_isatty(textio *self, PyObject *Py_UNUSED(ignored)) { - return _io_TextIOWrapper_isatty_impl(self); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_TextIOWrapper_isatty_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; } PyDoc_STRVAR(_io_TextIOWrapper_flush__doc__, @@ -961,7 +1015,13 @@ _io_TextIOWrapper_flush_impl(textio *self); static PyObject * _io_TextIOWrapper_flush(textio *self, PyObject *Py_UNUSED(ignored)) { - return _io_TextIOWrapper_flush_impl(self); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_TextIOWrapper_flush_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; } PyDoc_STRVAR(_io_TextIOWrapper_close__doc__, @@ -978,6 +1038,12 @@ _io_TextIOWrapper_close_impl(textio *self); static PyObject * _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored)) { - return _io_TextIOWrapper_close_impl(self); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_TextIOWrapper_close_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; } -/*[clinic end generated code: output=e58ce89b7354e77a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ec8ccae78ec3b379 input=a9049054013a1b77]*/ diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 8d19198502fe12..9e4ff66115c5c9 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -9,6 +9,7 @@ #include "Python.h" #include "pycore_call.h" // _PyObject_CallMethod() #include "pycore_codecs.h" // _PyCodecInfo_GetIncrementalDecoder() +#include "pycore_critical_section.h" #include "pycore_fileutils.h" // _Py_GetLocaleEncoding() #include "pycore_interp.h" // PyInterpreterState.fs_codec #include "pycore_long.h" // _PyLong_GetZero() @@ -1327,6 +1328,7 @@ textiowrapper_change_encoding(textio *self, PyObject *encoding, } /*[clinic input] +@critical_section _io.TextIOWrapper.reconfigure * encoding: object = None @@ -1346,7 +1348,7 @@ _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding, PyObject *errors, PyObject *newline_obj, PyObject *line_buffering_obj, PyObject *write_through_obj) -/*[clinic end generated code: output=52b812ff4b3d4b0f input=671e82136e0f5822]*/ +/*[clinic end generated code: output=52b812ff4b3d4b0f input=dc3bd35ebda702a7]*/ { int line_buffering; int write_through; @@ -1531,12 +1533,13 @@ textiowrapper_closed_get(textio *self, void *context); /*[clinic input] +@critical_section _io.TextIOWrapper.detach [clinic start generated code]*/ static PyObject * _io_TextIOWrapper_detach_impl(textio *self) -/*[clinic end generated code: output=7ba3715cd032d5f2 input=e5a71fbda9e1d9f9]*/ +/*[clinic end generated code: output=7ba3715cd032d5f2 input=c908a3b4ef203b0f]*/ { PyObject *buffer; CHECK_ATTACHED(self); @@ -1622,6 +1625,7 @@ _textiowrapper_writeflush(textio *self) } /*[clinic input] +@critical_section _io.TextIOWrapper.write text: unicode / @@ -1629,7 +1633,7 @@ _io.TextIOWrapper.write static PyObject * _io_TextIOWrapper_write_impl(textio *self, PyObject *text) -/*[clinic end generated code: output=d2deb0d50771fcec input=fdf19153584a0e44]*/ +/*[clinic end generated code: output=d2deb0d50771fcec input=73ec95c5c4a3489c]*/ { PyObject *ret; PyObject *b; @@ -1933,6 +1937,7 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint) } /*[clinic input] +@critical_section _io.TextIOWrapper.read size as n: Py_ssize_t(accept={int, NoneType}) = -1 / @@ -1940,7 +1945,7 @@ _io.TextIOWrapper.read static PyObject * _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n) -/*[clinic end generated code: output=7e651ce6cc6a25a6 input=123eecbfe214aeb8]*/ +/*[clinic end generated code: output=7e651ce6cc6a25a6 input=67d14c5661121377]*/ { PyObject *result = NULL, *chunks = NULL; @@ -2308,6 +2313,7 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit) } /*[clinic input] +@critical_section _io.TextIOWrapper.readline size: Py_ssize_t = -1 / @@ -2315,7 +2321,7 @@ _io.TextIOWrapper.readline static PyObject * _io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size) -/*[clinic end generated code: output=344afa98804e8b25 input=56c7172483b36db6]*/ +/*[clinic end generated code: output=344afa98804e8b25 input=b65bab871dc3ddba]*/ { CHECK_ATTACHED(self); return _textiowrapper_readline(self, size); @@ -2454,6 +2460,7 @@ _textiowrapper_encoder_setstate(textio *self, cookie_type *cookie) } /*[clinic input] +@critical_section _io.TextIOWrapper.seek cookie as cookieObj: object Zero or an opaque number returned by tell(). @@ -2478,7 +2485,7 @@ and may raise exceptions. static PyObject * _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) -/*[clinic end generated code: output=0a15679764e2d04d input=0f68adcb02cf2823]*/ +/*[clinic end generated code: output=0a15679764e2d04d input=4bea78698be23d7e]*/ { PyObject *posobj; cookie_type cookie; @@ -2665,6 +2672,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) } /*[clinic input] +@critical_section _io.TextIOWrapper.tell Return the stream position as an opaque number. @@ -2675,7 +2683,7 @@ previous stream position. static PyObject * _io_TextIOWrapper_tell_impl(textio *self) -/*[clinic end generated code: output=4f168c08bf34ad5f input=0852d627d76fb520]*/ +/*[clinic end generated code: output=4f168c08bf34ad5f input=415d6b4e4f8e6e8c]*/ { PyObject *res; PyObject *posobj = NULL; @@ -2901,6 +2909,7 @@ _io_TextIOWrapper_tell_impl(textio *self) } /*[clinic input] +@critical_section _io.TextIOWrapper.truncate pos: object = None / @@ -2908,7 +2917,7 @@ _io.TextIOWrapper.truncate static PyObject * _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos) -/*[clinic end generated code: output=90ec2afb9bb7745f input=56ec8baa65aea377]*/ +/*[clinic end generated code: output=90ec2afb9bb7745f input=8bddb320834c93ee]*/ { CHECK_ATTACHED(self) @@ -2988,72 +2997,78 @@ textiowrapper_repr(textio *self) /* Inquiries */ /*[clinic input] +@critical_section _io.TextIOWrapper.fileno [clinic start generated code]*/ static PyObject * _io_TextIOWrapper_fileno_impl(textio *self) -/*[clinic end generated code: output=21490a4c3da13e6c input=c488ca83d0069f9b]*/ +/*[clinic end generated code: output=21490a4c3da13e6c input=515e1196aceb97ab]*/ { CHECK_ATTACHED(self); return PyObject_CallMethodNoArgs(self->buffer, &_Py_ID(fileno)); } /*[clinic input] +@critical_section _io.TextIOWrapper.seekable [clinic start generated code]*/ static PyObject * _io_TextIOWrapper_seekable_impl(textio *self) -/*[clinic end generated code: output=ab223dbbcffc0f00 input=8b005ca06e1fca13]*/ +/*[clinic end generated code: output=ab223dbbcffc0f00 input=71c4c092736c549b]*/ { CHECK_ATTACHED(self); return PyObject_CallMethodNoArgs(self->buffer, &_Py_ID(seekable)); } /*[clinic input] +@critical_section _io.TextIOWrapper.readable [clinic start generated code]*/ static PyObject * _io_TextIOWrapper_readable_impl(textio *self) -/*[clinic end generated code: output=72ff7ba289a8a91b input=0704ea7e01b0d3eb]*/ +/*[clinic end generated code: output=72ff7ba289a8a91b input=80438d1f01b0a89b]*/ { CHECK_ATTACHED(self); return PyObject_CallMethodNoArgs(self->buffer, &_Py_ID(readable)); } /*[clinic input] +@critical_section _io.TextIOWrapper.writable [clinic start generated code]*/ static PyObject * _io_TextIOWrapper_writable_impl(textio *self) -/*[clinic end generated code: output=a728c71790d03200 input=c41740bc9d8636e8]*/ +/*[clinic end generated code: output=a728c71790d03200 input=9d6c22befb0c340a]*/ { CHECK_ATTACHED(self); return PyObject_CallMethodNoArgs(self->buffer, &_Py_ID(writable)); } /*[clinic input] +@critical_section _io.TextIOWrapper.isatty [clinic start generated code]*/ static PyObject * _io_TextIOWrapper_isatty_impl(textio *self) -/*[clinic end generated code: output=12be1a35bace882e input=fb68d9f2c99bbfff]*/ +/*[clinic end generated code: output=12be1a35bace882e input=7f83ff04d4d1733d]*/ { CHECK_ATTACHED(self); return PyObject_CallMethodNoArgs(self->buffer, &_Py_ID(isatty)); } /*[clinic input] +@critical_section _io.TextIOWrapper.flush [clinic start generated code]*/ static PyObject * _io_TextIOWrapper_flush_impl(textio *self) -/*[clinic end generated code: output=59de9165f9c2e4d2 input=928c60590694ab85]*/ +/*[clinic end generated code: output=59de9165f9c2e4d2 input=3ac3bf521bfed59d]*/ { CHECK_ATTACHED(self); CHECK_CLOSED(self); @@ -3064,12 +3079,13 @@ _io_TextIOWrapper_flush_impl(textio *self) } /*[clinic input] +@critical_section _io.TextIOWrapper.close [clinic start generated code]*/ static PyObject * _io_TextIOWrapper_close_impl(textio *self) -/*[clinic end generated code: output=056ccf8b4876e4f4 input=9c2114315eae1948]*/ +/*[clinic end generated code: output=056ccf8b4876e4f4 input=8e12d7079d5ac5c1]*/ { PyObject *res; int r; From 9ecb2c450d99ac91fdcd2af17e334f814a75fc2d Mon Sep 17 00:00:00 2001 From: AN Long Date: Fri, 17 Nov 2023 17:31:20 +0800 Subject: [PATCH 2/7] using critical section to make io.TextIOWrapper getters thread safe without GIL --- Modules/_io/textio.c | 72 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 6 deletions(-) diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 9e4ff66115c5c9..9ad498bf8544fd 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -3166,21 +3166,41 @@ textiowrapper_iternext(textio *self) } static PyObject * -textiowrapper_name_get(textio *self, void *context) +textiowrapper_name_get_impl(textio *self, void *context) { CHECK_ATTACHED(self); return PyObject_GetAttr(self->buffer, &_Py_ID(name)); } static PyObject * -textiowrapper_closed_get(textio *self, void *context) +textiowrapper_name_get(textio *self, void *context) +{ + PyObject *result = NULL; + Py_BEGIN_CRITICAL_SECTION(self); + result = textiowrapper_name_get_impl(self, context); + Py_END_CRITICAL_SECTION(); + return result; +} + +static PyObject * +textiowrapper_closed_get_impl(textio *self, void *context) { CHECK_ATTACHED(self); return PyObject_GetAttr(self->buffer, &_Py_ID(closed)); } static PyObject * -textiowrapper_newlines_get(textio *self, void *context) +textiowrapper_closed_get(textio *self, void *context) +{ + PyObject *result = NULL; + Py_BEGIN_CRITICAL_SECTION(self); + result = textiowrapper_closed_get_impl(self, context); + Py_END_CRITICAL_SECTION(); + return result; +} + +static PyObject * +textiowrapper_newlines_get_impl(textio *self, void *context) { PyObject *res; CHECK_ATTACHED(self); @@ -3193,21 +3213,51 @@ textiowrapper_newlines_get(textio *self, void *context) } static PyObject * -textiowrapper_errors_get(textio *self, void *context) +textiowrapper_newlines_get(textio *self, void *context) +{ + PyObject *result = NULL; + Py_BEGIN_CRITICAL_SECTION(self); + result = textiowrapper_newlines_get_impl(self, context); + Py_END_CRITICAL_SECTION(); + return result; +} + +static PyObject * +textiowrapper_errors_get_impl(textio *self, void *context) { CHECK_INITIALIZED(self); return Py_NewRef(self->errors); } static PyObject * -textiowrapper_chunk_size_get(textio *self, void *context) +textiowrapper_errors_get(textio *self, void *context) +{ + PyObject *result = NULL; + Py_BEGIN_CRITICAL_SECTION(self); + result = textiowrapper_errors_get_impl(self, context); + Py_END_CRITICAL_SECTION(); + return result; +} + +static PyObject * +textiowrapper_chunk_size_get_impl(textio *self, void *context) { CHECK_ATTACHED(self); return PyLong_FromSsize_t(self->chunk_size); } +static PyObject * +textiowrapper_chunk_size_get(textio *self, void *context) +{ + PyObject *result = NULL; + Py_BEGIN_CRITICAL_SECTION(self); + result = textiowrapper_chunk_size_get_impl(self, context); + Py_END_CRITICAL_SECTION(); + return result; +} + static int -textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context) +textiowrapper_chunk_size_set_impl(textio *self, PyObject *arg, void *context) { Py_ssize_t n; CHECK_ATTACHED_INT(self); @@ -3227,6 +3277,16 @@ textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context) return 0; } +static int +textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context) +{ + int result = 0; + Py_BEGIN_CRITICAL_SECTION(self); + result = textiowrapper_chunk_size_set_impl(self, arg, context); + Py_END_CRITICAL_SECTION(); + return result; +} + static PyMethodDef incrementalnewlinedecoder_methods[] = { _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF From 68584eae8090857576a61010f9a3b8ca97663dc1 Mon Sep 17 00:00:00 2001 From: AN Long Date: Fri, 17 Nov 2023 17:36:55 +0800 Subject: [PATCH 3/7] add news entry --- .../next/Library/2023-11-17-17-34-30.gh-issue-111965.6iMWn0.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-11-17-17-34-30.gh-issue-111965.6iMWn0.rst diff --git a/Misc/NEWS.d/next/Library/2023-11-17-17-34-30.gh-issue-111965.6iMWn0.rst b/Misc/NEWS.d/next/Library/2023-11-17-17-34-30.gh-issue-111965.6iMWn0.rst new file mode 100644 index 00000000000000..c724716120ee23 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-11-17-17-34-30.gh-issue-111965.6iMWn0.rst @@ -0,0 +1 @@ +Using critical section to make ``io.TextIOWrapper`` thread safe without GIL. From 45331d3283d2df312f6a33395568daefc9620b8a Mon Sep 17 00:00:00 2001 From: AN Long Date: Fri, 17 Nov 2023 18:51:51 +0800 Subject: [PATCH 4/7] remove news entry --- .../next/Library/2023-11-17-17-34-30.gh-issue-111965.6iMWn0.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Library/2023-11-17-17-34-30.gh-issue-111965.6iMWn0.rst diff --git a/Misc/NEWS.d/next/Library/2023-11-17-17-34-30.gh-issue-111965.6iMWn0.rst b/Misc/NEWS.d/next/Library/2023-11-17-17-34-30.gh-issue-111965.6iMWn0.rst deleted file mode 100644 index c724716120ee23..00000000000000 --- a/Misc/NEWS.d/next/Library/2023-11-17-17-34-30.gh-issue-111965.6iMWn0.rst +++ /dev/null @@ -1 +0,0 @@ -Using critical section to make ``io.TextIOWrapper`` thread safe without GIL. From 6b1d58f554922a55b65c8a280eee185487f593da Mon Sep 17 00:00:00 2001 From: AN Long Date: Sat, 18 Nov 2023 13:19:00 +0800 Subject: [PATCH 5/7] Update include header comments --- Modules/_io/textio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 9ad498bf8544fd..48224a62f25cfb 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -9,7 +9,7 @@ #include "Python.h" #include "pycore_call.h" // _PyObject_CallMethod() #include "pycore_codecs.h" // _PyCodecInfo_GetIncrementalDecoder() -#include "pycore_critical_section.h" +#include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION() #include "pycore_fileutils.h" // _Py_GetLocaleEncoding() #include "pycore_interp.h" // PyInterpreterState.fs_codec #include "pycore_long.h" // _PyLong_GetZero() From 1898faa91183d41704ac9c8df8c0d333e529aa06 Mon Sep 17 00:00:00 2001 From: AN Long Date: Sat, 18 Nov 2023 16:31:16 +0800 Subject: [PATCH 6/7] Update Modules/_io/textio.c Co-authored-by: Donghee Na --- Modules/_io/textio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 48224a62f25cfb..8a29a4781a92ba 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -7,12 +7,12 @@ */ #include "Python.h" -#include "pycore_call.h" // _PyObject_CallMethod() -#include "pycore_codecs.h" // _PyCodecInfo_GetIncrementalDecoder() +#include "pycore_call.h" // _PyObject_CallMethod() +#include "pycore_codecs.h" // _PyCodecInfo_GetIncrementalDecoder() #include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION() -#include "pycore_fileutils.h" // _Py_GetLocaleEncoding() -#include "pycore_interp.h" // PyInterpreterState.fs_codec -#include "pycore_long.h" // _PyLong_GetZero() +#include "pycore_fileutils.h" // _Py_GetLocaleEncoding() +#include "pycore_interp.h" // PyInterpreterState.fs_codec +#include "pycore_long.h" // _PyLong_GetZero() #include "pycore_object.h" // _PyObject_GC_UNTRACK() #include "pycore_pyerrors.h" // _PyErr_ChainExceptions1() #include "pycore_pystate.h" // _PyInterpreterState_GET() From da2d2c14bc11ed908a5639b883c99de99163f1c0 Mon Sep 17 00:00:00 2001 From: AN Long Date: Sat, 18 Nov 2023 16:36:40 +0800 Subject: [PATCH 7/7] align include headers --- Modules/_io/textio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 8a29a4781a92ba..9f4155a5dd63ee 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -13,9 +13,9 @@ #include "pycore_fileutils.h" // _Py_GetLocaleEncoding() #include "pycore_interp.h" // PyInterpreterState.fs_codec #include "pycore_long.h" // _PyLong_GetZero() -#include "pycore_object.h" // _PyObject_GC_UNTRACK() -#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1() -#include "pycore_pystate.h" // _PyInterpreterState_GET() +#include "pycore_object.h" // _PyObject_GC_UNTRACK() +#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1() +#include "pycore_pystate.h" // _PyInterpreterState_GET() #include "_iomodule.h"