From e7cf51fd6a504b2ab9d887c562c2ca3ace12d033 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Sun, 31 May 2026 17:30:41 +0200
Subject: [PATCH] Workaround import problem after Python upgrade
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
To: gentoo-portage-dev@lists.gentoo.org

Make `SyncfsProcess` import non-lazy to ensure that it is imported
before the old-Python version of Portage is removed, and therefore fix
a crash when Portage is being rebuilt for a new Python version.

Bug: https://bugs.gentoo.org/970375
Closes: https://github.com/gentoo/portage/pull/1586
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
---
 lib/portage/dbapi/vartree.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
index 87d4f3453238..7f392588ef9a 100644
--- a/lib/portage/dbapi/vartree.py
+++ b/lib/portage/dbapi/vartree.py
@@ -43,6 +43,10 @@ from portage import _unicode_encode
 from portage.util.futures.executor.fork import ForkExecutor
 from ._VdbMetadataDelta import VdbMetadataDelta
 
+# Made global to fix importing on Python version upgrade:
+# https://bugs.gentoo.org/970375
+from ._SyncfsProcess import SyncfsProcess
+
 from _emerge.EbuildBuildDir import EbuildBuildDir
 from _emerge.EbuildPhase import EbuildPhase
 from _emerge.emergelog import emergelog
@@ -6128,7 +6132,6 @@ class dblink:
         does nothing if FEATURES=merge-sync is disabled.
         """
         import subprocess
-        from portage.dbapi._SyncfsProcess import SyncfsProcess
 
         if not self._device_path_map or "merge-sync" not in self.settings.features:
             return
-- 
2.54.0

