From d66a2c9d97eb1ea1c0ffc91bc98ba7ab3569aa67 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 26 Sep 2020 14:43:33 +0900 Subject: [PATCH 1/5] bpo-1635741: Port _bisect module to multi-phase init --- .../2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst | 2 ++ Modules/_bisectmodule.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst b/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst new file mode 100644 index 00000000000000..63eba37e7c7879 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst @@ -0,0 +1,2 @@ +Port the ``_bisect`` extension module to the multi-phase initialization API +(:pep:`489`). diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c index 82d800d9a8790f..fb13a106b3f252 100644 --- a/Modules/_bisectmodule.c +++ b/Modules/_bisectmodule.c @@ -234,21 +234,21 @@ having to sort the list after each insertion. For long lists of items with\n\ expensive comparison operations, this can be an improvement over the more\n\ common approach.\n"); +static struct PyModuleDef_Slot _bisectmodule_slots[] = { + {0, NULL} +}; static struct PyModuleDef _bisectmodule = { PyModuleDef_HEAD_INIT, - "_bisect", - module_doc, - -1, - bisect_methods, - NULL, - NULL, - NULL, - NULL + .m_name = "_bisect", + .m_doc = module_doc, + .m_methods = bisect_methods, + .m_slots = _bisectmodule_slots, + .m_size = 0 }; PyMODINIT_FUNC PyInit__bisect(void) { - return PyModule_Create(&_bisectmodule); + return PyModuleDef_Init(&_bisectmodule); } From 0a6f49e7e83eb2f43d1c744ef730a4035a3520d0 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 26 Sep 2020 14:52:45 +0900 Subject: [PATCH 2/5] bpo-1635741: Update NEWS.d --- .../2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst b/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst index 63eba37e7c7879..9859d3f9753bcc 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst @@ -1,2 +1 @@ -Port the ``_bisect`` extension module to the multi-phase initialization API -(:pep:`489`). +Port :mod:`_bisect` to the multi-phase initialization (:pep:`489`). From 6661ad718638ad22fe27c45b6ba94aa28dea5a5a Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 26 Sep 2020 19:27:32 +0900 Subject: [PATCH 3/5] Update Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst Co-authored-by: Victor Stinner --- .../2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst b/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst index 9859d3f9753bcc..252dab35a1368a 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2020-09-26-14-43-30.bpo-1635741.aJS9B3.rst @@ -1 +1 @@ -Port :mod:`_bisect` to the multi-phase initialization (:pep:`489`). +Port the :mod:`_bisect` module to the multi-phase initialization API (:pep:`489`). From 6fd31dd7444a2f93b6cc74615a0e8544ce924c7e Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 26 Sep 2020 19:28:58 +0900 Subject: [PATCH 4/5] bpo-1635741: Apply code review --- Modules/_bisectmodule.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c index fb13a106b3f252..194488bd0ca407 100644 --- a/Modules/_bisectmodule.c +++ b/Modules/_bisectmodule.c @@ -234,16 +234,11 @@ having to sort the list after each insertion. For long lists of items with\n\ expensive comparison operations, this can be an improvement over the more\n\ common approach.\n"); -static struct PyModuleDef_Slot _bisectmodule_slots[] = { - {0, NULL} -}; - static struct PyModuleDef _bisectmodule = { PyModuleDef_HEAD_INIT, .m_name = "_bisect", .m_doc = module_doc, .m_methods = bisect_methods, - .m_slots = _bisectmodule_slots, .m_size = 0 }; From c6215ec6182852095388af466f78f00425ce8674 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 26 Sep 2020 19:30:05 +0900 Subject: [PATCH 5/5] bpo-1635741: nit --- Modules/_bisectmodule.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c index 194488bd0ca407..277e9755f27211 100644 --- a/Modules/_bisectmodule.c +++ b/Modules/_bisectmodule.c @@ -234,6 +234,7 @@ having to sort the list after each insertion. For long lists of items with\n\ expensive comparison operations, this can be an improvement over the more\n\ common approach.\n"); + static struct PyModuleDef _bisectmodule = { PyModuleDef_HEAD_INIT, .m_name = "_bisect",