From 8bb681e23491dab6cf75ec1d4af8ddc6bf0e734a Mon Sep 17 00:00:00 2001 From: neonene <53406459+neonene@users.noreply.github.com> Date: Sat, 8 Jun 2024 04:30:19 +0900 Subject: [PATCH 1/3] add PyObject_GC_Track() to _sre.template() --- Modules/_sre/sre.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/_sre/sre.c b/Modules/_sre/sre.c index c1eff63d921de9..e33034086481c2 100644 --- a/Modules/_sre/sre.c +++ b/Modules/_sre/sre.c @@ -1622,6 +1622,7 @@ _sre_template_impl(PyObject *module, PyObject *pattern, PyObject *template) } self->items[i].literal = Py_XNewRef(literal); } + PyObject_GC_Track(self); return (PyObject*) self; bad_template: From 89906788ba7979c638c83d8607cfb5d5a62f8ab6 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 8 Jun 2024 09:45:32 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst diff --git a/Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst b/Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst new file mode 100644 index 00000000000000..3a614f18a57e24 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst @@ -0,0 +1 @@ +Fix memory leak in :meth:`re.sub()` when ``\number`` is specified to refer to a group. From b3f73162174b0f878be670d292ac1a297e792281 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 8 Jun 2024 12:57:38 +0300 Subject: [PATCH 3/3] Update Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst --- .../next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst b/Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst index 3a614f18a57e24..d21532f22a1d38 100644 --- a/Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst +++ b/Misc/NEWS.d/next/Library/2024-06-08-09-45-31.gh-issue-120244.8o9Dzr.rst @@ -1 +1 @@ -Fix memory leak in :meth:`re.sub()` when ``\number`` is specified to refer to a group. +Fix memory leak in :func:`re.sub()` when the replacement string contains backreferences.