43
43
"has_subprocess_support" , "requires_subprocess" ,
44
44
"anticipate_failure" , "load_package_tests" , "detect_api_mismatch" ,
45
45
"check__all__" , "skip_if_buggy_ucrt_strfptime" ,
46
- "check_disallow_instantiation" , "skip_if_sanitizer" ,
46
+ "check_disallow_instantiation" , "check_sanitizer" , " skip_if_sanitizer" ,
47
47
# sys
48
48
"is_jython" , "is_android" , "is_emscripten" , "is_wasi" ,
49
49
"check_impl_detail" , "unix_shell" , "setswitchinterval" ,
@@ -384,13 +384,11 @@ def skip_if_buildbot(reason=None):
384
384
isbuildbot = os .environ .get ('USER' ) == 'buildbot'
385
385
return unittest .skipIf (isbuildbot , reason )
386
386
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 """
389
389
if not (address or memory or ub ):
390
390
raise ValueError ('At least one of address, memory, or ub must be True' )
391
391
392
- if not reason :
393
- reason = 'not working with sanitizers active'
394
392
395
393
_cflags = sysconfig .get_config_var ('CFLAGS' ) or ''
396
394
_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):
406
404
'-fsanitize=undefined' in _cflags or
407
405
'--with-undefined-behavior-sanitizer' in _config_args
408
406
)
409
- skip = (
407
+ return (
410
408
(memory and memory_sanitizer ) or
411
409
(address and address_sanitizer ) or
412
410
(ub and ub_sanitizer )
413
411
)
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 )
414
419
return unittest .skipIf (skip , reason )
415
420
416
421
0 commit comments