From 483edb8136919d82013284ad3b0cd834e68fce15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Thu, 14 Mar 2024 10:23:59 +0100
Subject: [PATCH] Workaround hang/OOM kill in Python 3.13, avoid calling
list.remove() in try-except
See https://bugzilla.redhat.com/show_bug.cgi?id=2250649#c9 and bellow for details.
Python 3.13 changed the exception message for list.remove() to include the repr
of the missing object. Previously, it never mentioned the object at all.
https://github.com/python/cpython/commit/217f47d6e5e56bca78b8556e910cd00890f6f84a
Unfortunately, the repr() of the removed klass object
seems to very expensive to construct.
Even on Python 3.12, calling a repr(klass) directly causes
the build of PyQt5 and PyQt6 to hang in copr and time out after 5 hours.
In local mock, it causes sip-build to be OOM killed.
By checking if klass is in the list before attempting the removal,
we avoid the repr() call on Python 3.13+.
CPython upstream report: https://github.com/python/cpython/issues/116792
---
sipbuild/generator/parser/parser_manager.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/sipbuild/generator/parser/parser_manager.py b/sipbuild/generator/parser/parser_manager.py
index 666d904..70d7e3c 100644
--- a/sipbuild/generator/parser/parser_manager.py
+++ b/sipbuild/generator/parser/parser_manager.py
@@ -432,10 +432,8 @@ class ParserManager:
for klass in self.spec.classes:
if klass.iface_file is iface_file:
if not self.parsing_template:
- try:
+ if klass in self._template_arg_classes:
self._template_arg_classes.remove(klass)
- except ValueError:
- pass
return klass
--
2.44.0