Title: python_is_optimized() false negatives
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.9, Python 3.8
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, jdemeyer, petr.viktorin, pitrou
Priority: normal Keywords:

Created on 2019-05-30 07:43 by jdemeyer, last changed 2019-06-24 08:24 by jdemeyer. This issue is now closed.

Messages (2)
msg343952 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2019-05-30 07:43
The function python_is_optimized() in Lib/test/

def python_is_optimized():
    """Find if Python was built with optimizations."""
    cflags = sysconfig.get_config_var('PY_CFLAGS') or ''
    final_opt = ""
    for opt in cflags.split():
        if opt.startswith('-O'):
            final_opt = opt
    return final_opt not in ('', '-O0', '-Og')

However, it seems that the *default* (when no special CFLAGS are configured) is -O3. My Python build is done with this default -O3 but python_is_optimized() returns False. This is the reason why I didn't catch the buildbot failure at
(this test is only run when python_is_optimized() is True)
msg346357 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2019-06-24 08:24
Never mind, I probably tested wrong here.
Date User Action Args
2019-06-24 08:24:38jdemeyersetstatus: open -> closed
resolution: works for me
messages: + msg346357

stage: resolved
2019-05-30 07:43:48jdemeyercreate