jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Close file handle before removing a tempory file. ......................................................................
[FIX] Close file handle before removing a tempory file.
mkstemp() returns a tuple containing OS-level file handle to an open file and the absolute pathname of that file. The file might be reopended several times and closed by with-statement. But the first file handle opened by mkstemp() keeps still open. It must be closed explicitly.
Bug: T113127 Change-Id: Icf104ebee21448b405c9e4671e112d68cda68597 --- M tests/tools_tests.py 1 file changed, 2 insertions(+), 1 deletion(-)
Approvals: XZise: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/tools_tests.py b/tests/tools_tests.py index 4d98d49..2c63736 100644 --- a/tests/tools_tests.py +++ b/tests/tools_tests.py @@ -157,7 +157,7 @@
def _write_content(self, suffix): try: - fn = tempfile.mkstemp(suffix)[1] + fh, fn = tempfile.mkstemp(suffix) with tools.open_archive(fn, 'wb') as f: f.write(self.original_content) with tools.open_archive(fn, 'rb') as f: @@ -165,6 +165,7 @@ with open(fn, 'rb') as f: return f.read() finally: + os.close(fh) os.remove(fn)
def test_invalid_modes(self):
pywikibot-commits@lists.wikimedia.org