commit:     c387e1ec61dede826dca25b831905384b83fbd56
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  3 02:04:09 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jun  3 02:06:28 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c387e1ec

bin: lock-helper.py: move more code into __name__ main guard for Python 3.14

I was still seeing (flaky!) test failures after 
e5b7b8a3ac0a710272e174851673e5eb74250a69 with:
```
FAILED 
lib/portage/tests/locks/test_asynchronous_lock.py::AsynchronousLockTestCase::testAsynchronousLockWaitKill
FAILED 
lib/portage/tests/process/test_spawn_returnproc.py::SpawnReturnProcTestCase::testSpawnReturnProcTerminate
FAILED 
lib/portage/tests/locks/test_asynchronous_lock.py::AsynchronousLockTestCase::testAsynchronousLockWaitKillHardlink
FAILED 
lib/portage/tests/locks/test_lock_nonblock.py::LockNonblockTestCase::testLockNonblockHardlink
 - AssertionError: 1 != 0
```

Move more code into the guard in bin/lock-helper.py. It seems to help a bit
but not sure if that's completely cured it. In other bin/*, we mostly call
disable_legacy_globals in the guard, so this seems right on that end too.

Bug: https://bugs.gentoo.org/941956
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/lock-helper.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bin/lock-helper.py b/bin/lock-helper.py
index 3f89eeea03..172c18affd 100755
--- a/bin/lock-helper.py
+++ b/bin/lock-helper.py
@@ -8,9 +8,6 @@ import sys
 sys.path.insert(0, os.environ["PORTAGE_PYM_PATH"])
 import portage
 
-portage._internal_caller = True
-portage._disable_legacy_globals()
-
 
 def main(args):
     if args and isinstance(args[0], bytes):
@@ -29,5 +26,8 @@ def main(args):
 
 
 if __name__ == "__main__":
+    portage._internal_caller = True
+    portage._disable_legacy_globals()
+
     rval = main(sys.argv[1:])
     sys.exit(rval)

Reply via email to