dev-python/translate-toolkit: Enable py3.12

Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2023-11-07 15:09:34 +01:00
parent f038f1c0cb
commit 99445b2c0d
2 changed files with 42 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
From 3217ed10bb9371ff25cb04e194e0250d42f89206 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= <michal@cihar.com>
Date: Tue, 7 Nov 2023 08:42:56 +0100
Subject: [PATCH] optrecurse: properly close opened files
This avoids leaking file descriptors in the tests and makes sure the
content is written at the end of conversion.
Fixes #5071
---
translate/misc/optrecurse.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/translate/misc/optrecurse.py b/translate/misc/optrecurse.py
index d69666b8e8..9337c7c4ff 100644
--- a/translate/misc/optrecurse.py
+++ b/translate/misc/optrecurse.py
@@ -684,10 +684,17 @@ def processfile(
tempoutput = False
templatefile = self.opentemplatefile(options, fulltemplatepath)
passthroughoptions = self.getpassthroughoptions(options)
- if fileprocessor(inputfile, outputfile, templatefile, **passthroughoptions):
+ result = fileprocessor(
+ inputfile, outputfile, templatefile, **passthroughoptions
+ )
+ if fullinputpath is not None:
+ inputfile.close()
+ if result:
if tempoutput:
self.warning("writing to temporary output...")
self.finalizetempoutputfile(options, outputfile, fulloutputpath)
+ if fulloutputpath and os.path.isfile(fulloutputpath):
+ outputfile.close()
return True
else:
# remove the file if it is a file (could be stdout etc)

View File

@@ -4,8 +4,7 @@
EAPI=8
DISTUTILS_USE_PEP517=setuptools
# py3.12: https://github.com/translate/translate/issues/5071
PYTHON_COMPAT=( python3_{10..11} )
PYTHON_COMPAT=( python3_{10..12} )
PYTHON_REQ_USE="sqlite"
inherit distutils-r1
@@ -52,6 +51,11 @@ BDEPEND="
)
"
PATCHES=(
# https://github.com/translate/translate/commit/3217ed10bb9371ff25cb04e194e0250d42f89206
"${FILESDIR}/${P}-py312.patch"
)
distutils_enable_tests pytest
src_test() {