PyO3 / PyO3/pyo3

Use of PyPyModule_FromDefAndSpec2 is broken with pypy 7.3.19

Open
#6,305 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.2k
Forks
1k
Avg merge
2d 6h
Merged PRs (30d)
66

Description

The package cryptography-50.0.0-pp311-pypy311_pp73-manylinux_2_34_x86_64.whl, which uses PyO3, is incompatible with the PyPy interpreter in Debian 13.

$ virtualenv -ppypy3 /tmp/aa
[...]
$ /tmp/aa/bin/pip install cryptography==50.0.0
Collecting cryptography==50.0.0
  Using cached cryptography-50.0.0-pp311-pypy311_pp73-manylinux_2_34_x86_64.whl.metadata (4.3 kB)
Using cached cryptography-50.0.0-pp311-pypy311_pp73-manylinux_2_34_x86_64.whl (4.7 MB)
Installing collected packages: cryptography
Successfully installed cryptography-50.0.0
 
[notice] A new release of pip is available: 25.1.1 -> 26.2.1
[notice] To update, run: /tmp/aa/bin/pypy3 -m pip install --upgrade pip
$ /tmp/aa/bin/python
Python 3.11.11 (7.3.19+dfsg-2, Apr 11 2025, 02:57:20)
[PyPy 7.3.19 with GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> import cryptography.x509
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/aa/lib/pypy3.11/site-packages/cryptography/x509/__init__.py", line 7, in <module>
    from cryptography.x509 import certificate_transparency, oid, verification
  File "/tmp/aa/lib/pypy3.11/site-packages/cryptography/x509/certificate_transparency.py", line 8, in <module>
    from cryptography.hazmat.bindings._rust import x509 as rust_x509
ImportError: /tmp/aa/lib/pypy3.11/site-packages/cryptography/hazmat/bindings/_rust.pypy311-pp73-x86_64-linux-gnu.so: undefined symbol: PyPyModule_FromDefAndSpec2

The PyModule_FromDefAndSpec2 function was apparently added to PyPy in version 7.3.20. PyO3 claims to support "PyPy 7.3 (Python 3.11+)", as the "pypy311_pp73" tag implies.

The use of this function in PyO3 appears to have been added in version 0.27.0. Accordingly, cryptography version 47.0.0 (pyo3 version 0.28.3) and later appear to be broken, while cryptography version 46.0.7 (pyo3 version 0.26.0) and earlier do not have this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the PyO3 0.27.0 change that introduced PyPyModule_FromDefAndSpec2 and compare its assumptions with PyPy 7.3.19 and 7.3.20. Done means the generated PyPy extension no longer references an unavailable symbol on PyPy 7.3.19 while retaining compatibility with supported newer versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
backend, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.