You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sysconfig gives misleading results for USE_COMPUTED_GOTOS #57449
This looks like the system Python compiled by Apple. What about a
hand-compiled Python?
Forget this. I get the same results here.
However, if you add a "#error" at the right place in ceval.c, you'll see that computed gotos are enabled. It seems more of a sysconfig bug or limitation. In pyconfig.h, I have the following:
Extract of configure.in:
-------------------------------------
# Check for --with-computed-gotosAC_MSG_CHECKING(for--with-computed-gotos)
AC_ARG_WITH(computed-gotos,
AS_HELP_STRING([--with(out)-computed-gotos],
[Usecomputedgotosinevaluationloop (enabledbydefaultonsupportedcompilers)]),
[
iftest"$withval"=yesthenAC_DEFINE(USE_COMPUTED_GOTOS, 1,
[Defineifyouwanttousecomputedgotosinceval.c.])
AC_MSG_RESULT(yes)
fiiftest"$withval"=nothenAC_DEFINE(USE_COMPUTED_GOTOS, 0,
[Defineifyouwanttousecomputedgotosinceval.c.])
AC_MSG_RESULT(no)
fi
],
[AC_MSG_RESULT(novaluespecified)])
Extract of my config.log:
-------------------------------------
configure:13788: checking whether gcc -pthread supports computed gotos
configure:13811: gcc -pthread -o conftest conftest.c -lpthread -ldl -lutil >&5
configure:13811: $? = 0
configure:13811: ./conftest
configure:13811: $? = 0
configure:13822: result: yes
configure:13832: checking for --with-computed-gotos
configure:13856: result: no value specified
-------------------------------------
Extract of my pyconfig.h
-------------------------------------
/* Define if you want to use computed gotos in ceval.c. */
/* #undef USE_COMPUTED_GOTOS */
-------------------------------------
Computed goto are disabled (in my Python 3.3 on Linux with GCC), I checked by adding #error to ceval.c.
Extract of my pyconfig.h
-------------------------------------
/* Define if you want to use computed gotos in ceval.c. */
/* #undef USE_COMPUTED_GOTOS */
-------------------------------------
Ok, now read ceval.c:
#ifdefHAVE_COMPUTED_GOTOS#ifndefUSE_COMPUTED_GOTOS#defineUSE_COMPUTED_GOTOS 1
#endif#else#if defined(USE_COMPUTED_GOTOS) &&USE_COMPUTED_GOTOS#error "Computed gotos are not supported on this compiler."
#endif#undef USE_COMPUTED_GOTOS
#defineUSE_COMPUTED_GOTOS 0
#endif
florentx commented on Oct 21, 2011
florentxmannequin
MannequinAuthor
More actions
With the #error, I can confirm that computed gotos are enabled on OS X.
About sysconfig, we may change the code to set None if the value is "undef". I don't know the impact.
--- a/Lib/sysconfig.py+++ b/Lib/sysconfig.py@@ -404,7 +404,7 @@
else:
m = undef_rx.match(line)
if m:
- vars[m.group(1)] = 0+ vars[m.group(1)] = None
return vars
With the #error, I can confirm that computed gotos are enabled on OS X.
About sysconfig, we may change the code to set None if the value is "undef". I don't know the impact.
Actually, I think sysconfig does the right thing when it comes to all
the configure-generated HAVE_XXX variables (due to the peculiar way the
configure/pyconfig.h couple works).
It's just that USE_COMPUTED_GOTOS is a ternary variable (0/1/undefined),
so maybe we should accept as a limitation that sysconfig returns a
misleading result here.
> P.S. We could probably get rid of the HAVE macro all together by doing
> all the work in the 'configure' script.
Would that be a breach of backward compatibility for sysconfig?
configure leaves USE_COMPUTED_GOTOS undefined in pyconfig.h.
sysconfig reads that as 0, but Python/ceval_macros.h treats it as 1, so computed gotos are actually enabled.
The fix agreed above still applies:
let configure.ac define USE_COMPUTED_GOTOS to 1 when no option is given and the compiler supports it.
Activity
florentx commentedon Oct 21, 2011
According to bpo-9203 the computed gotos should be enabled by default since 3.2.
However, it is not visible from the interpreter.
pitrou commentedon Oct 21, 2011
This looks like the system Python compiled by Apple. What about a
hand-compiled Python?
merwok commentedon Oct 21, 2011
Just compiled 3.2 on Debian:
>>> sysconfig.get_config_var('USE_COMPUTED_GOTOS') 0pitrou commentedon Oct 21, 2011
Forget this. I get the same results here.
However, if you add a "#error" at the right place in ceval.c, you'll see that computed gotos are enabled. It seems more of a sysconfig bug or limitation. In pyconfig.h, I have the following:
Which apparently sysconfig translates as USE_COMPUTED_GOTOS being equal to 0, which I think is wrong.
[-]computed gotos not enabled?[/-][+]sysconfig gives misleading results for USE_COMPUTED_GOTOS[/+]vstinner commentedon Oct 21, 2011
Extract of configure.in:
-------------------------------------
Extract of my config.log:
-------------------------------------
configure:13788: checking whether gcc -pthread supports computed gotos
configure:13811: gcc -pthread -o conftest conftest.c -lpthread -ldl -lutil >&5
configure:13811: $? = 0
configure:13811: ./conftest
configure:13811: $? = 0
configure:13822: result: yes
configure:13832: checking for --with-computed-gotos
configure:13856: result: no value specified
-------------------------------------
Extract of my pyconfig.h
-------------------------------------
/* Define if you want to use computed gotos in ceval.c. */
/* #undef USE_COMPUTED_GOTOS */
-------------------------------------
Computed goto are disabled (in my Python 3.3 on Linux with GCC), I checked by adding #error to ceval.c.
pitrou commentedon Oct 21, 2011
Ok, now read ceval.c:
florentx commentedon Oct 21, 2011
With the #error, I can confirm that computed gotos are enabled on OS X.
About sysconfig, we may change the code to set None if the value is "undef". I don't know the impact.
pitrou commentedon Oct 21, 2011
Actually, I think sysconfig does the right thing when it comes to all
the configure-generated HAVE_XXX variables (due to the peculiar way the
configure/pyconfig.h couple works).
It's just that USE_COMPUTED_GOTOS is a ternary variable (0/1/undefined),
so maybe we should accept as a limitation that sysconfig returns a
misleading result here.
3 remaining items
meadori commentedon Oct 26, 2011
Yeah, I think so. Best to leave it alone then.
arhadthedev commentedon Apr 29, 2023
Is the issue still reprodusible on OS X?
ronaldoussoren commentedon May 2, 2023
This is with the 3.11.3 installed from python.org. So no, this doesn't seem to be reproducible on macOS.
ronaldoussoren commentedon Jun 24, 2023
Dropping the os-mac label because this isn't a Mac-specific issue.
vasiliyk commentedon Oct 22, 2026
Still reproducible on 3.16.0a1+dev:
configure leaves
USE_COMPUTED_GOTOSundefined inpyconfig.h.sysconfig reads that as 0, but
Python/ceval_macros.htreats it as 1, so computed gotos are actually enabled.The fix agreed above still applies:
let configure.ac define
USE_COMPUTED_GOTOSto 1 when no option is given and the compiler supports it.I will open a PR for this.
vasiliyk commentedon Nov 24, 2026
With PR
configure.acdefinesUSE_COMPUTED_GOTOSto 1 when no option is given and the compiler supports it.--with-computed-gotosand--without-computed-gotosstill give 1 and 0.