bpo-43816: add 'extern "C"' to pyctype.h#25365
Merged
vstinner merged 2 commits intopython:masterfrom Apr 13, 2021
Merged
Conversation
vstinner
reviewed
Apr 12, 2021
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
Contributor
Author
|
Any idea why |
Contributor
|
Thanks @andrewvaughanj for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Contributor
|
Thanks @andrewvaughanj for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
Contributor
|
Sorry @andrewvaughanj and @vstinner, I had trouble checking out the |
|
GH-25386 is a backport of this pull request to the 3.8 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Apr 13, 2021
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com> (cherry picked from commit 54db51c) Co-authored-by: Andrew V. Jones <andrewvaughanj@gmail.com>
Contributor
|
Thanks @andrewvaughanj for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
|
GH-25387 is a backport of this pull request to the 3.9 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Apr 13, 2021
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com> (cherry picked from commit 54db51c) Co-authored-by: Andrew V. Jones <andrewvaughanj@gmail.com>
miss-islington
added a commit
that referenced
this pull request
Apr 13, 2021
vstinner
pushed a commit
that referenced
this pull request
Apr 13, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
With Python 3.9.4, and when compiling with Visual Studio 2019, we have noticed that the variable
_Py_ctype_tableis not scoped with in anextern "C"block, and where the Python library (python39.lib) has been compiled with a C compiler.This causes an issue when trying to refer to
_Py_ctype_tablefrom a C++ file, as the compiler tries to name-mangle the use of_Py_ctype_table, but the linker cannot then tie the mangled name to non-mangled named frompython39.lib.Example:
Compilation:
With
cl.exe:A naïve check of Python.h (e126547) seems to suggest that:
extern "C"extern "C"For the 8 that do not contain
extern "C", none of these usePyAPI_DATA. This leads me to believe that it is an oversight thatpyctype.hdoes not haveextern "C"Resolution
This PR resolves this issue by adding an
extern "C"declaration to the top ofpyctype.h(if compiling as C++).Signed-off-by: Andrew V. Jones andrew.jones@vector.com
https://bugs.python.org/issue43816