From: Douglas Bagnall Date: Wed, 6 Mar 2024 22:05:55 +0000 (+1300) Subject: pytest:segfault: prevent @no_gdb_backtrace smearing on exception X-Git-Tag: tdb-1.4.11~1411 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ceecd3f739b347e684895115c5f9cd79b91f4b7;p=thirdparty%2Fsamba.git pytest:segfault: prevent @no_gdb_backtrace smearing on exception It is OK for one of these tests to raise an exception -- that is often the only reasonable thing to do when you'd otherwise crash -- but the @no_gdb_backtrace decorator would not clean up in that case, leading to no gdb backtraces for all subsequent tests. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/segfault.py b/python/samba/tests/segfault.py index 6c01088e5f8..d676a21f9c6 100644 --- a/python/samba/tests/segfault.py +++ b/python/samba/tests/segfault.py @@ -58,9 +58,11 @@ def segfault_detector(f): def no_gdb_backtrace(f): from os import environ def w(*args, **kwargs): - environ['PLEASE_NO_GDB_BACKTRACE'] = '1' - f(*args, **kwargs) - del environ['PLEASE_NO_GDB_BACKTRACE'] + environ['PLEASE_NO_GDB_BACKTRACE'] = '1' + try: + f(*args, **kwargs) + finally: + del environ['PLEASE_NO_GDB_BACKTRACE'] return w