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
bpo-36635: Add _testinternalcapi module #12841
Conversation
b639226
to
a9d480a
Compare
a9d480a
to
8bb148d
Compare
I chose to name the C file _testinternalcapi.c rather _testinternalcapimodule.c, just because "_testinternalcapimodule.c" is too long :-) |
I'm not sure about the module name. Maybe "_testinternal" is better? (shorter, contains enough info?) |
I copied the _testcapi project of PCbuild/ and I tried to adapt it, but it seems like I made a mistake. Importing _testinternalcapi fails with:
|
Perhaps you need to generate new unique identifiers. |
Now done in the 2 project files. |
The GUIDs shouldn't matter outside of Visual Studio, and the only one that has to change is the ProjectGuid (which was updated initially, I believe). The ones in the filters file are referring to known values for the category, so they were fine. (There is an update missing from Based on not seeing the following line in the build logs, I think it's decided not to produce a DLL for some reason:
Possibly the |
Hum. The problem should be that PyMODINIT_FUNC is defined differently if Py_BUILD_CORE_BUILTIN is defined:
instead of:
The following change works around the issue on Windows:
|
Yeah, that sounds like it. The "BUILTIN" part of the macro implies that it's going to be merged into the CPython shared library and loading using inittab rather than dynamically. Perhaps there's another macro you could use for this module? Or else just hack around it as you showed. |
There is already a Py_BUILD_CORE_MODULE define which is defined in the Visual Studio project when a C extension is built as a .pyd file (DLL):
This define is only used at once place:
I wrote PR #12853 to change PyAPI_FUNC(type), PyAPI_DATA(type) and PyMODINIT_FUNC macros |
The PR #12853 fix this change: I tested manually, it works. |
Add a new _testinternalcapi module to test the internal C API. Move _Py_GetConfigsAsDict() function to the internal C API: _testembed now uses _testinternalcapi to access the function.
3d80dd4
to
942a874
Compare
I merged PR #12853. I rebased this PR on top of it, I squashed commits and I made minor changes (I fixed Modules/Setup). Modules/_testinternalcapi.c now requires that a define is set explicitly:
|
Thanks for the review @zooba, and thanks @serhiy-storchaka and @zware for hints to debug the compilation issue on Windows :-) |
Add a new _testinternalcapi module to test the internal C API.
Move _Py_GetConfigsAsDict() function to the internal C API:
_testembed now uses _testinternalcapi to access the function.
https://bugs.python.org/issue36635