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
Oh, Include/errcode.h *is* used by PyRun_InteractiveOneFlags() and its variants. It's mentioned in its documentation:
Returns ``0`` when the input was
executed successfully, ``-1`` if there was an exception, or an error code
from the :file:`errcode.h` include file distributed as part of Python if
there was a parse error. (Note that :file:`errcode.h` is not included by
:file:`Python.h`, so must be included specifically if needed.)
I tried to remove the <string.h> include from Python.h:
-#include <string.h> // memcpy()
... but it required me to modify 100+ files. I don't know the exact number, I gave up after 100 files. I was near half of C extensions built by setup.py, so the number total may be around 150 files which should include explicitly <string.h>.
"#include <errno.h>" can now be removed from Python.h, but I'm not sure if it's a good idea. I started by removing <stdlib.h> and my plan is to see if it breaks third party C extensions. Right now, Cython is broken which prevents me to use my https://github.com/vstinner/pythonci tool :-(
Victor, what's the benefit of doing this work? Are there real problems this fixes? I'm worried about the churn in third-party extensions, examples, tutorials, etc, especially for audiences that upon seeing a compiler error won't immediately realise they need to include stdlib.h themselves. (Also, since Python.h sets things like _POSIX_C_SOURCE and _XOPEN_SOURCE, including them in the wrong order can produce even more confusing errors, or errors that only appear on some platforms.)
Activity
vstinner commentedon Oct 11, 2021
I would like to remove #include <stdlib.h> from Python.h, and make Python.h smaller.
vstinner commentedon Oct 11, 2021
New changeset 47717d1 by Victor Stinner in branch 'main':
bpo-45434: Cleanup Python.h header file (GH-28883)
47717d1
vstinner commentedon Oct 11, 2021
New changeset 03ea862 by Victor Stinner in branch 'main':
bpo-45434: Python.h no longer includes <stdlib.h> (GH-28888)
03ea862
vstinner commentedon Oct 13, 2021
New changeset 489176e by Victor Stinner in branch 'main':
bpo-45434: Convert Py_GETENV() macro to a function (GH-28912)
489176e
vstinner commentedon Oct 13, 2021
New changeset c63623a by Victor Stinner in branch 'main':
bpo-45434: bytearrayobject.h no longer includes <stdarg.h> (GH-28913)
c63623a
vstinner commentedon Oct 13, 2021
New changeset 97308df by Victor Stinner in branch 'main':
bpo-45434: Move _Py_BEGIN_SUPPRESS_IPH to pycore_fileutils.h (GH-28922)
97308df
vstinner commentedon Oct 13, 2021
New changeset bbe7497 by Victor Stinner in branch 'main':
bpo-45434: Remove pystrhex.h header file (GH-28923)
bbe7497
vstinner commentedon Oct 13, 2021
Oh, Include/errcode.h *is* used by PyRun_InteractiveOneFlags() and its variants. It's mentioned in its documentation:
Returns ``0`` when the input was
executed successfully, ``-1`` if there was an exception, or an error code
from the :file:`errcode.h` include file distributed as part of Python if
there was a parse error. (Note that :file:`errcode.h` is not included by
:file:`Python.h`, so must be included specifically if needed.)
vstinner commentedon Oct 13, 2021
New changeset 713bb19 by Victor Stinner in branch 'main':
bpo-45434: Mark the PyTokenizer C API as private (GH-28924)
713bb19
vstinner commentedon Oct 13, 2021
PyRun_InteractiveOneObjectEx() returns a single error code of errcode.h: E_EOF (11):
vstinner commentedon Oct 13, 2021
New changeset aac29af by Victor Stinner in branch 'main':
bpo-45434: pyport.h no longer includes <stdlib.h> (GH-28914)
aac29af
vstinner commentedon Oct 14, 2021
I tried to remove the <string.h> include from Python.h:
-#include <string.h> // memcpy()
... but it required me to modify 100+ files. I don't know the exact number, I gave up after 100 files. I was near half of C extensions built by setup.py, so the number total may be around 150 files which should include explicitly <string.h>.
"#include <errno.h>" can now be removed from Python.h, but I'm not sure if it's a good idea. I started by removing <stdlib.h> and my plan is to see if it breaks third party C extensions. Right now, Cython is broken which prevents me to use my https://github.com/vstinner/pythonci tool :-(
vstinner commentedon Oct 14, 2021
New changeset 2849947 by Victor Stinner in branch 'main':
bpo-45434: Limited Python.h no longer includes stdio.h (GH-28960)
2849947
vstinner commentedon Oct 14, 2021
New changeset 7076bef by Victor Stinner in branch 'main':
bpo-45434: Remove useless space in includes (GH-28963)
7076bef
vstinner commentedon Oct 15, 2021
New changeset 105582e by Victor Stinner in branch 'main':
bpo-45434: Remove Include/eval.h header file (GH-28973)
105582e
corona10 commentedon Oct 18, 2021
New changeset fd03917 by Dong-hee Na in branch 'main':
bpo-45434: Include stdlib.h for specialize stat (GH-29015)
fd03917
Yhg1s commentedon Oct 18, 2021
Victor, what's the benefit of doing this work? Are there real problems this fixes? I'm worried about the churn in third-party extensions, examples, tutorials, etc, especially for audiences that upon seeing a compiler error won't immediately realise they need to include stdlib.h themselves. (Also, since Python.h sets things like _POSIX_C_SOURCE and _XOPEN_SOURCE, including them in the wrong order can produce even more confusing errors, or errors that only appear on some platforms.)
vstinner commentedon Oct 18, 2021
I reopen the issue.
vstinner commentedon Oct 19, 2021
New changeset 52af075 by Victor Stinner in branch 'main':
bpo-45434: Only exclude <stdlib.h> in Python 3.11 limited C API (GH-29027)
52af075