From 2b5ab7412de6c77b65445cffc315a3610dbc8123 Mon Sep 17 00:00:00 2001 From: "yvernet@slb.com" Date: Wed, 19 Jan 2022 17:56:27 +0100 Subject: [PATCH 1/4] BUG: fix to_json memory leak --- pandas/_libs/src/ujson/python/objToJSON.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/_libs/src/ujson/python/objToJSON.c b/pandas/_libs/src/ujson/python/objToJSON.c index 06c3d823f72d2..c4609992342c3 100644 --- a/pandas/_libs/src/ujson/python/objToJSON.c +++ b/pandas/_libs/src/ujson/python/objToJSON.c @@ -228,6 +228,7 @@ static PyObject *get_values(PyObject *obj) { PyErr_Clear(); } else if (PyObject_HasAttrString(values, "__array__")) { // We may have gotten a Categorical or Sparse array so call np.array + Py_DECREF(values); values = PyObject_CallMethod(values, "__array__", NULL); } else if (!PyArray_CheckExact(values)) { // Didn't get a numpy array, so keep trying From c7f1e173a11a7959b363caf043cbabf23c0cea62 Mon Sep 17 00:00:00 2001 From: "yvernet@slb.com" Date: Wed, 19 Jan 2022 18:02:19 +0100 Subject: [PATCH 2/4] DOC: update whatsnew --- doc/source/whatsnew/v1.5.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 1ae76984484af..405726964b01c 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -227,7 +227,7 @@ MultiIndex I/O ^^^ - Bug in :meth:`DataFrame.to_stata` where no error is raised if the :class:`DataFrame` contains ``-np.inf`` (:issue:`45350`) -- +- Bug in :meth:`to_json` fix memory leak (:issue:`43877`) Period ^^^^^^ From 6595c9ea65dd35d03b0233d6b3c92c1be27eb315 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 21 Jan 2022 23:11:50 +0000 Subject: [PATCH 3/4] move release note --- doc/source/whatsnew/v1.4.0.rst | 1 + doc/source/whatsnew/v1.5.0.rst | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index 1ca4e8cc97df0..2c257d5dae797 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -935,6 +935,7 @@ I/O - Bug in :func:`read_json` raising ``ValueError`` when attempting to parse json strings containing "://" (:issue:`36271`) - Bug in :func:`read_csv` when ``engine="c"`` and ``encoding_errors=None`` which caused a segfault (:issue:`45180`) - Bug in :func:`read_csv` an invalid value of ``usecols`` leading to an un-closed file handle (:issue:`45384`) +- Bug in :meth:`to_json` fix memory leak (:issue:`43877`) Period ^^^^^^ diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 405726964b01c..1ae76984484af 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -227,7 +227,7 @@ MultiIndex I/O ^^^ - Bug in :meth:`DataFrame.to_stata` where no error is raised if the :class:`DataFrame` contains ``-np.inf`` (:issue:`45350`) -- Bug in :meth:`to_json` fix memory leak (:issue:`43877`) +- Period ^^^^^^ From 8a5b51435318b7bb243eaf21948ff088eb09959d Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 21 Jan 2022 23:14:15 +0000 Subject: [PATCH 4/4] update release note --- doc/source/whatsnew/v1.4.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index 497a187a7ade1..363d4b57544a9 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -966,7 +966,7 @@ I/O - Bug in :func:`read_json` raising ``ValueError`` when attempting to parse json strings containing "://" (:issue:`36271`) - Bug in :func:`read_csv` when ``engine="c"`` and ``encoding_errors=None`` which caused a segfault (:issue:`45180`) - Bug in :func:`read_csv` an invalid value of ``usecols`` leading to an unclosed file handle (:issue:`45384`) -- Bug in :meth:`to_json` fix memory leak (:issue:`43877`) +- Bug in :meth:`DataFrame.to_json` fix memory leak (:issue:`43877`) Period ^^^^^^