From d12f0209c56ee8434a500b5f0ad546e88b65f786 Mon Sep 17 00:00:00 2001 From: Matthias Miltenberger Date: Sat, 19 Mar 2022 21:07:16 +0100 Subject: [PATCH] do not close file descriptors to fix #570 --- CHANGELOG.md | 1 + src/pyscipopt/scip.pyx | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5c7b8213..a0db18366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased ### Added ### Fixed +- revert change from #543 to fix #570 (closing file descriptors) ### Changed ### Removed diff --git a/src/pyscipopt/scip.pyx b/src/pyscipopt/scip.pyx index 854c80a64..b47a45f76 100644 --- a/src/pyscipopt/scip.pyx +++ b/src/pyscipopt/scip.pyx @@ -10,7 +10,7 @@ cimport cython from cpython cimport Py_INCREF, Py_DECREF from cpython.pycapsule cimport PyCapsule_New, PyCapsule_IsValid, PyCapsule_GetPointer from libc.stdlib cimport malloc, free -from libc.stdio cimport fdopen, fclose +from libc.stdio cimport fdopen from collections.abc import Iterable from itertools import repeat @@ -4238,7 +4238,6 @@ cdef class Model: with open(filename, "w") as f: cfile = fdopen(f.fileno(), "w") PY_SCIP_CALL(SCIPprintBestSol(self._scip, cfile, write_zeros)) - fclose(cfile) def writeBestTransSol(self, filename="transprob.sol", write_zeros=False): """Write the best feasible primal solution for the transformed problem to a file. @@ -4266,7 +4265,6 @@ cdef class Model: with open(filename, "w") as f: cfile = fdopen(f.fileno(), "w") PY_SCIP_CALL(SCIPprintSol(self._scip, solution.sol, cfile, write_zeros)) - fclose(cfile) def writeTransSol(self, Solution solution, filename="transprob.sol", write_zeros=False): """Write the given transformed primal solution to a file. @@ -4626,7 +4624,6 @@ cdef class Model: with open(filename, "w") as f: cfile = fdopen(f.fileno(), "w") PY_SCIP_CALL(SCIPprintStatistics(self._scip, cfile)) - fclose(cfile) def getNLPs(self): """gets total number of LPs solved so far"""