Skip to content

Fix Py_UNICODE_TODECIMAL definition for PyPy#6078

Merged
davidhewitt merged 3 commits into
PyO3:mainfrom
ngoldbaum:fix-todecimal-pypy
Jun 1, 2026
Merged

Fix Py_UNICODE_TODECIMAL definition for PyPy#6078
davidhewitt merged 3 commits into
PyO3:mainfrom
ngoldbaum:fix-todecimal-pypy

Conversation

@ngoldbaum

@ngoldbaum ngoldbaum commented May 28, 2026

Copy link
Copy Markdown
Contributor

PyPy doesn't expose _PyUnicode_ToDecimalDigit, so this definition leads to an unknown symbol error at link time. I'm not sure why the existing pypy tests didn't catch this. I was able to trigger it by running the maturin test integration::integration_cases::case_16_pyo3_stub_generation_zig with a zig compiler and pypy3.11-7.3.22 installed on an ARM Mac.

Py_UNICODE_TODECIMAL is exposed in the PyPy C API, so we can just expose it directly: https://github.com/pypy/pypy/blob/872e7d92ee361276e84844b7fab208dc73c93a11/pypy/module/cpyext/unicodeobject.py#L186-L193

That fixes the linker error for me in my local testing.

@ngoldbaum ngoldbaum force-pushed the fix-todecimal-pypy branch from 04f8186 to 88d34b3 Compare May 28, 2026 14:51
Comment thread pyo3-ffi/src/cpython/unicodeobject.rs
Co-authored-by: Bas Schoenmaeckers <7943856+bschoenmaeckers@users.noreply.github.com>

@davidhewitt davidhewitt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks; pyo3-ffi-check currently doesn't fire for missing PyPy symbols as we often naively assume they exist and allow PyPy to add them later in patch releases if they are missing.

It's probably the case that we should tighten this going forward, both so that we match the current (mostly static) implementation of PyPy 3.11 but also so that if PyPy 3.12 is ever under development we can catch missing 3.12 APIs eagerly.

@davidhewitt davidhewitt enabled auto-merge June 1, 2026 09:40
@davidhewitt davidhewitt added this pull request to the merge queue Jun 1, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 1, 2026
@davidhewitt davidhewitt added this pull request to the merge queue Jun 1, 2026
Merged via the queue into PyO3:main with commit b2163a0 Jun 1, 2026
65 of 87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix CI-skip-changelog Skip checking changelog entry FFI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants