commit:     482079c7835c769843544a4920ccb4c49d363351
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 13 22:38:40 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Jun 13 22:41:06 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=482079c7

PORTAGE_NICENESS: fix atexit ResourceWarning: unclosed file

# emerge -V
Portage 3.0.20 (python 3.8.5-final-0, default/linux/amd64/17.1/desktop, 
gcc-9.3.0, glibc-2.31-r6, 5.4.x x86_64)
/usr/lib/python3.8/site-packages/_emerge/actions.py:2663: ResourceWarning: 
unclosed file <_io.TextIOWrapper name='/proc/self/autogroup' mode='w' 
encoding='UTF-8'>
  lambda value: autogroup_file.open("w").write(value).close(),
ResourceWarning: Enable tracemalloc to get the object allocation traceback

Fixes: a4d882964ee1 ("PORTAGE_NICENESS: Consider autogroup scheduling")
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/_emerge/actions.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/_emerge/actions.py b/lib/_emerge/actions.py
index 18f8da200..bfb08ed6b 100644
--- a/lib/_emerge/actions.py
+++ b/lib/_emerge/actions.py
@@ -2660,7 +2660,7 @@ def nice(settings):
                # terminal where portage was executed in, would
                # continue running with that value.
                portage.atexit_register(
-                       lambda value: autogroup_file.open("w").write(value),
+                       lambda value: autogroup_file.write_text(value),
                        original_autogroup_nice_value,
                )
 

Reply via email to