Repository navigation
Conversation
Fixes python-cffi#170. Signed-off-by: Mark Colley <39366189+M-Colley@users.noreply.github.com>
mattip
reviewed
Nov 28, 2026
mattip
left a comment
Contributor
There was a problem hiding this comment.
All the test does is check that the c source now has the ifdef condition, right? It does not actually check that mingw + pypy works. Did you test this in practice?
And this will never run on real code since pypy ships its own vendored cffi.
I would be more convinced to do this as a backport from pypy. So first make the change in pypy, verify it fixes the problem there (does anything work with mingw + pypy + cffi?), then backport it here.
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.
Windows PyPy builds compiled with MinGW fail at link time with an undefined PyInit_ export error. Specifically, distutils and setuptools add PyInit_ to the extension export list on all Windows toolchains. Previously, src/cffi/recompiler.py guarded the dummy PyInit_ stub inside the PYPY_VERSION block with #ifdef _MSC_VER, leaving the exported symbol undefined under MinGW. Fixes #170.
This change updates src/cffi/recompiler.py to guard the dummy PyInit_ definition with #ifdef _WIN32. Consequently, both MSVC and MinGW toolchains on Windows define the required stub symbol. Additionally, testing/cffi1/test_recompiler_codegen.py adds a regression test verifying the generated PYPY_VERSION preprocessor block.
Verification ran pytest on testing/cffi1/test_recompiler_codegen.py and testing/cffi0/test_model.py, passing all 14 tests.