-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C API] The internal C API <pycore_dict.h> cannot be used in C++ #108216
Comments
This old issue was about including the public C API <Python.h>. This issue is about using the internal C API in C++. |
What is your use case for using the internal C API? https://github.com/P403n1x87/echion/ description:
It looks like a Python profiler. |
In Python 3.11, I added |
Indeed it is a profiler (actually just a frame stack sample fwiw). The internal API is used to access internal fields of structures from copies of Python objects so that it can all be done without the GIL |
* Add missing includes * Remove unused includes * Mention at least once included symbol * Sort includes
* Add missing includes * Remove unused includes * Mention at least once included symbol * Sort includes * Update Tools/cases_generator/generate_cases.py used to generated pycore_opcode_metadata.h. * Update Parser/asdl_c.py used to generate pycore_ast.h. * Cleanup also includes in _testcapimodule.c and _testinternalcapi.c.
With Python 3.11, it's possible to include <pycore_dict.h> in C++? In 3.11, there is no include. Python 3.12 added two includes:
PEP 684: A Per-Interpreter GIL modified |
* Add missing includes. * Remove unused includes. * Update old include/symbol names to newer names. * Mention at least one included symbol. * Sort includes. * Update Tools/cases_generator/generate_cases.py used to generated pycore_opcode_metadata.h. * Update Parser/asdl_c.py used to generate pycore_ast.h. * Cleanup also includes in _testcapimodule.c and _testinternalcapi.c.
Sub-set of pycore_dict.h which can be used by debuggers and profilers. pycore_dict.h includes pycore_dict_struct.h.
Sub-set of pycore_dict.h which can be used by debuggers and profilers. pycore_dict.h includes pycore_dict_struct.h.
pycore_dict_struct.h is a sub-set of pycore_dict.h which can be used by debuggers and profilers and should be usable in C++. pycore_dict.h includes pycore_dict_struct.h (no API change).
Add a new internal pycore_dict_struct.h header file. It can be used by debuggers and profilers to inspect a Python dictionary without having to call Python functions. It should be usable in C++. pycore_dict.h includes pycore_dict_struct.h (no API change).
I proposed PR #108235 which adds <pycore_dict_struct.h>: a sub-set of <pycore_dict.h> which should be usable in C++. It has no include and so does not cause C++ issue on <pycore_atomic.h>. |
Yep I add the import of |
Maybe workaround: #ifdef HAVE_STD_ATOMIC
#undef HAVE_STD_ATOMIC
#endif
#include <pycore_dict.h> |
@P403n1x87: Does @methane's workaround work for you? If yes, there is no need to change the header file, right? |
@vstinner will try to test today and report |
@vstinner @methane's workaround seems to work as it makes all the atomic-related errors disappear GH job: https://github.com/P403n1x87/echion/actions/runs/5997079612/job/16262783675?pr=8 With that "noise" reduced, I spotted this other seemingly GCC-only issue
but this likely a different issue. |
I removed |
In that case, I propose to not add
Thanks for the feedback. I close the issue. |
Ops, sorry for the noise, Victor! I didn't see there was a related PR that fixed some of the issues. |
This issue was not fixed. Only workaround is offered as a way to avoid the issue 😁 |
Aha, so we close it as not planned then! :) |
Oh. I tried but apparently failed to do that. |
Bug report
Checklist
and am confident this bug has not been reported before
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
3.12.0rc1
A clear and concise description of the bug:
This looks like a new instance of #67832.
@vstinner This seems to occur in 3.12 when importing e.g.
pycore_dict.h
in a C++ module https://github.com/P403n1x87/echion/actions/runs/5775912109/job/16065738879https://github.com/P403n1x87/echion/blob/29275a13aea67a8d008471523f38bc4477499a98/echion/mirrors.h#L14
The same job with clang on OSX doesn't show the same issue: https://github.com/P403n1x87/echion/actions/runs/5775912109/job/16065739714.
Linked PRs
The text was updated successfully, but these errors were encountered: