Skip to content

Add support for PyPy3.12 - #10047

Merged
radarhere merged 4 commits into
python-pillow:mainfrom
hugovk:pypy3.12
Sep 24, 2026
Merged

radarhere merged 4 commits into
python-pillow:mainfrom
hugovk:pypy3.12

Conversation

@hugovk

@hugovk hugovk commented Sep 23, 2026

Copy link
Copy Markdown
Member

PyPy v8.0.0 is out:

  • It adds a PyPy3.12 beta.
  • It's the last release to support PyPy3.11 (barring security issues).

https://pypy.org/posts/2026/09/pypy-v800-release.html

This PR:

  • Adds pypy3.12 to the CI.

  • Updates https://github.com/python/pythoncapi-compat/ to the latest, which is needed for PyPy3.12 support.

  • PyPy doesn't have PyConfig, so update a "if 3.12+" check to "if 3.12+ and not PyPy" so PyPy 2.12 uses the else branch.

Not available in cibuildwheel yet: pypa/cibuildwheel#2995.

@radarhere

Copy link
Copy Markdown
Member

PyPy doesn't have PyConfig, so update a "if 3.12+" check to "if 3.12+ and not PyPy" so PyPy 2.12 uses the else branch.

That's interesting, considering that Py_FileSystemDefaultEncoding is deprecated in Python 3.12. Do they plan on getting to it sooner or later?

@hugovk

hugovk commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

pypy/pypy#3836 looks the closest issue, and a big job, so I expect later rather than sooner.

Comment thread .github/workflows/test-windows.yml Outdated
Comment thread src/_imagingft.c Outdated
#if PY_MAJOR_VERSION > 3 || PY_MINOR_VERSION > 11
#if (PY_MAJOR_VERSION > 3 || PY_MINOR_VERSION > 11) && !defined(PYPY_VERSION)
PyConfig config;
PyConfig_InitPythonConfig(&config);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PyConfig_InitPythonConfig() is designed to configuration Python initialization, not to read the current configuration.

To read the current configuration, you should call PyConfig_Get("filesystem_encoding") instead.

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.

PyConfig_Get was only added in Python 3.14. We could still call it anyway, with the help of pythoncapi_compat.h, but surely there must be a correct version that works naturally with Python 3.12 and 3.13?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hum, I read again the code and in fact, getting the encoding is only half of the problem. You should use the correct error handler as well.

There is a better API for that: use PyUnicode_FSConverter with PyArg_ParseTuple family and O& format. It gets the current filesystem encoding and error handler. It's available since Python 3.1.

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.

I've created hugovk#182

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
@radarhere
radarhere merged commit 2d84574 into python-pillow:main Sep 24, 2026
73 of 76 checks passed
@hugovk
hugovk deleted the pypy3.12 branch September 24, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants