4343 "has_subprocess_support" , "requires_subprocess" ,
4444 "anticipate_failure" , "load_package_tests" , "detect_api_mismatch" ,
4545 "check__all__" , "skip_if_buggy_ucrt_strfptime" ,
46- "check_disallow_instantiation" , "skip_if_sanitizer" ,
46+ "check_disallow_instantiation" , "check_sanitizer" , " skip_if_sanitizer" ,
4747 # sys
4848 "is_jython" , "is_android" , "is_emscripten" , "is_wasi" ,
4949 "check_impl_detail" , "unix_shell" , "setswitchinterval" ,
@@ -384,13 +384,11 @@ def skip_if_buildbot(reason=None):
384384 isbuildbot = os .environ .get ('USER' ) == 'buildbot'
385385 return unittest .skipIf (isbuildbot , reason )
386386
387- def skip_if_sanitizer ( reason = None , * , address = False , memory = False , ub = False ):
388- """Decorator raising SkipTest if running with a sanitizer active. """
387+ def check_sanitizer ( * , address = False , memory = False , ub = False ):
388+ """Returns True if Python is compiled with sanitizer support """
389389 if not (address or memory or ub ):
390390 raise ValueError ('At least one of address, memory, or ub must be True' )
391391
392- if not reason :
393- reason = 'not working with sanitizers active'
394392
395393 _cflags = sysconfig .get_config_var ('CFLAGS' ) or ''
396394 _config_args = sysconfig .get_config_var ('CONFIG_ARGS' ) or ''
@@ -406,11 +404,18 @@ def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False):
406404 '-fsanitize=undefined' in _cflags or
407405 '--with-undefined-behavior-sanitizer' in _config_args
408406 )
409- skip = (
407+ return (
410408 (memory and memory_sanitizer ) or
411409 (address and address_sanitizer ) or
412410 (ub and ub_sanitizer )
413411 )
412+
413+
414+ def skip_if_sanitizer (reason = None , * , address = False , memory = False , ub = False ):
415+ """Decorator raising SkipTest if running with a sanitizer active."""
416+ if not reason :
417+ reason = 'not working with sanitizers active'
418+ skip = check_sanitizer (address = address , memory = memory , ub = ub )
414419 return unittest .skipIf (skip , reason )
415420
416421
0 commit comments