python-pydantic-core fails to build with Python 3.14.0a1. ________________________________ test_recursive ________________________________ definition_schema = SchemaValidator(title="typed-dict", validator=DefinitionRef( DefinitionRefValidator { definition: "typed-d...d390) }) }], extra_behavior: Ignore, extras_validator: None, strict: false, loc_by_alias: true })], cache_strings=True) @pytest.mark.skipif(sys.platform == 'emscripten', reason='Seems to fail sometimes on pyodide no idea why') > @given(strategies.from_type(BranchModel)) tests/test_hypothesis.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.14/site-packages/hypothesis/core.py:674: in process_arguments_to_given s.validate() /usr/lib/python3.14/site-packages/hypothesis/strategies/_internal/strategies.py:428: in validate self.do_validate() /usr/lib/python3.14/site-packages/hypothesis/strategies/_internal/lazy.py:139: in do_validate w.validate() /usr/lib/python3.14/site-packages/hypothesis/strategies/_internal/strategies.py:429: in validate self.is_empty /usr/lib/python3.14/site-packages/hypothesis/strategies/_internal/strategies.py:147: in accept recur(self) /usr/lib/python3.14/site-packages/hypothesis/strategies/_internal/strategies.py:143: in recur mapping[strat] = getattr(strat, calculation)(recur) /usr/lib/python3.14/site-packages/hypothesis/strategies/_internal/deferred.py:68: in calc_is_empty return recur(self.wrapped_strategy) /usr/lib/python3.14/site-packages/hypothesis/strategies/_internal/deferred.py:38: in wrapped_strategy result = self.__definition() /usr/lib/python3.14/site-packages/hypothesis/strategies/_internal/core.py:1240: in <lambda> lambda thing: deferred(lambda: _from_type(thing)), /usr/lib/python3.14/site-packages/hypothesis/strategies/_internal/core.py:1253: in _from_type from hypothesis.strategies._internal import types /usr/lib/python3.14/site-packages/hypothesis/strategies/_internal/types.py:708: in <module> typing.ByteString: st.binary(), # type: ignore _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ attr = 'ByteString' def __getattr__(attr): """Improve the import time of the typing module. Soft-deprecated objects which are costly to create are only created on-demand here. """ if attr in {"Pattern", "Match"}: import re obj = _alias(getattr(re, attr), 1) elif attr in {"ContextManager", "AsyncContextManager"}: import contextlib obj = _alias(getattr(contextlib, f"Abstract{attr}"), 2, name=attr, defaults=(bool | None,)) elif attr == "_collect_parameters": import warnings depr_message = ( "The private _collect_parameters function is deprecated and will be" " removed in a future version of Python. Any use of private functions" " is discouraged and may break in the future." ) warnings.warn(depr_message, category=DeprecationWarning, stacklevel=2) obj = _collect_type_parameters else: > raise AttributeError(f"module {__name__!r} has no attribute {attr!r}") E AttributeError: module 'typing' has no attribute 'ByteString' /usr/lib64/python3.14/typing.py:3829: AttributeError ___________________________ test_isinstance[python] ____________________________ py_and_json = <class 'tests.conftest.py_and_json.<locals>.ChosenPyAndJsonValidator'> def test_isinstance(py_and_json: PyAndJson): def f(input_value, validator, info): if 'error' in info.context: raise ValueError('wrong') return validator(input_value) v = py_and_json(core_schema.with_info_wrap_validator_function(f, core_schema.str_schema())) assert v.validate_python('foobar', None, {}) == 'foobar' # internal error!, use generic bit of error message to match both cpython and pypy with pytest.raises(TypeError, match='is not iterable'): > v.validate_test('foobar') tests/test_validation_context.py:77: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/conftest.py:72: in validate_test return self.validator.validate_python(py_input, strict=strict, context=context) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ input_value = 'foobar' validator = ValidatorCallable(Str(StrValidator { strict: false, coerce_numbers_to_str: false })) info = ValidationInfo(config=None, context=None, data=None, field_name=None) def f(input_value, validator, info): > if 'error' in info.context: E TypeError: argument of type 'NoneType' is not a container or iterable tests/test_validation_context.py:67: TypeError During handling of the above exception, another exception occurred: py_and_json = <class 'tests.conftest.py_and_json.<locals>.ChosenPyAndJsonValidator'> def test_isinstance(py_and_json: PyAndJson): def f(input_value, validator, info): if 'error' in info.context: raise ValueError('wrong') return validator(input_value) v = py_and_json(core_schema.with_info_wrap_validator_function(f, core_schema.str_schema())) assert v.validate_python('foobar', None, {}) == 'foobar' # internal error!, use generic bit of error message to match both cpython and pypy > with pytest.raises(TypeError, match='is not iterable'): E AssertionError: Regex pattern did not match. E Regex: 'is not iterable' E Input: "argument of type 'NoneType' is not a container or iterable" tests/test_validation_context.py:76: AssertionError ____________________________ test_isinstance[json] _____________________________ py_and_json = <class 'tests.conftest.py_and_json.<locals>.ChosenPyAndJsonValidator'> def test_isinstance(py_and_json: PyAndJson): def f(input_value, validator, info): if 'error' in info.context: raise ValueError('wrong') return validator(input_value) v = py_and_json(core_schema.with_info_wrap_validator_function(f, core_schema.str_schema())) assert v.validate_python('foobar', None, {}) == 'foobar' # internal error!, use generic bit of error message to match both cpython and pypy with pytest.raises(TypeError, match='is not iterable'): > v.validate_test('foobar') tests/test_validation_context.py:77: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/conftest.py:67: in validate_test return self.validator.validate_json( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ input_value = 'foobar' validator = ValidatorCallable(Str(StrValidator { strict: false, coerce_numbers_to_str: false })) info = ValidationInfo(config=None, context=None, data=None, field_name=None) def f(input_value, validator, info): > if 'error' in info.context: E TypeError: argument of type 'NoneType' is not a container or iterable tests/test_validation_context.py:67: TypeError During handling of the above exception, another exception occurred: py_and_json = <class 'tests.conftest.py_and_json.<locals>.ChosenPyAndJsonValidator'> def test_isinstance(py_and_json: PyAndJson): def f(input_value, validator, info): if 'error' in info.context: raise ValueError('wrong') return validator(input_value) v = py_and_json(core_schema.with_info_wrap_validator_function(f, core_schema.str_schema())) assert v.validate_python('foobar', None, {}) == 'foobar' # internal error!, use generic bit of error message to match both cpython and pypy > with pytest.raises(TypeError, match='is not iterable'): E AssertionError: Regex pattern did not match. E Regex: 'is not iterable' E Input: "argument of type 'NoneType' is not a container or iterable" tests/test_validation_context.py:76: AssertionError ===== 3 failed, 4326 passed, 58 skipped, 1 deselected, 2 xfailed in 13.25s ===== https://docs.python.org/3.14/whatsnew/3.14.html For the build logs, see: https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08225292-python-pydantic-core/ For all our attempts to build python-pydantic-core with Python 3.14, see: https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/python-pydantic-core/ Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.14: https://copr.fedorainfracloud.org/coprs/g/python/python3.14/ Let us know here if you have any questions. Python 3.14 is planned to be included in Fedora 43. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14. A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon. We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.
This bug appears to have been reported against 'rawhide' during the Fedora Linux 42 development cycle. Changing version to 42.
With Python 3.14.0a5 there are different failures. 1) AssertionErrors in test_isinstance[python] and test_isinstance[json] as reported above. 2) Segmentation fault in tests/test_json.py::test_partial_parse, sometimes accompanied by a garbage output from the test itself, example: _________________________________________________ test_partial_parse __________________________________________________ def test_partial_parse(): with pytest.raises(ValueError, match='EOF while parsing a string at line 1 column 15'): from_json('["aa", "bb", "c') > assert from_json('["aa", "bb", "c', allow_partial=True) == ['aa', 'bb'] E AssertionError: assert ['Ø[', 'fo'] == ['aa', 'bb'] E E At index 0 diff: 'Ø[' != 'aa' E E Full diff: E [ E - 'aa', E ? ^^ E + 'Ø[', E ? ^^ E - 'bb', E ? ^^ E + 'fo', E ? ^^ E ] tests/test_json.py:374: AssertionError 3) Segmentation fault in tests/validators/test_json.py::test_any - same as above
It’s hard to report things like this upstream when one can’t even build for Python 3.14 in a virtual environment, e.g.: $ git clone https://github.com/pydantic/pydantic-core.git $ cd pydantic-core $ uv venv --python 3.14 $ . .venv/bin/activate (pydantic-core) $ PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 uv pip install -e . Resolved 2 packages in 257ms × Failed to build `pydantic-core @ file:///home/ben/src/forks/pydantic-core` ├─▶ The build backend returned an error ╰─▶ Call to `maturin.build_wheel` failed (exit status: 1) [stdout] Running `maturin pep517 build-wheel -i /home/ben/.cache/uv/builds-v0/.tmpvltD2Y/bin/python --compatibility off` [stderr] 📦 Including license file "/home/ben/src/forks/pydantic-core/LICENSE" 🍹 Building a mixed python/rust project 🔗 Found pyo3 bindings 🐍 Found CPython 3.14 at /home/ben/.cache/uv/builds-v0/.tmpvltD2Y/bin/python 📡 Using build options features, bindings from pyproject.toml Compiling pyo3-build-config v0.23.5 Compiling pyo3-macros-backend v0.23.5 Compiling pyo3-ffi v0.23.5 Compiling pyo3 v0.23.5 Compiling jiter v0.8.2 Compiling pydantic-core v2.31.1 (/home/ben/src/forks/pydantic-core) Compiling pyo3-macros v0.23.5 error[E0425]: cannot find function, tuple struct or tuple variant `PyUnicode_New` in module `pyo3::ffi` --> /home/ben/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jiter-0.8.2/src/py_string_cache.rs:216:26 | 216 | let ptr = pyo3::ffi::PyUnicode_New(s.len() as isize, 127); | ^^^^^^^^^^^^^ help: a function with a similar name exists: `PySlice_New` | ::: /home/ben/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-ffi-0.23.5/src/sliceobject.rs:50:5 | 50 | / pub fn PySlice_New( 51 | | start: *mut PyObject, 52 | | stop: *mut PyObject, 53 | | step: *mut PyObject, 54 | | ) -> *mut PyObject; | |_______________________- similarly named function `PySlice_New` defined here error[E0425]: cannot find function, tuple struct or tuple variant `PyUnicode_KIND` in module `pyo3::ffi` --> /home/ben/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jiter-0.8.2/src/py_string_cache.rs:218:33 | 218 | debug_assert_eq!(pyo3::ffi::PyUnicode_KIND(ptr), pyo3::ffi::PyUnicode_1BYTE_KIND); | ^^^^^^^^^^^^^^ help: a function with a similar name exists: `PyUnicode_Find` | ::: /home/ben/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-ffi-0.23.5/src/unicodeobject.rs:303:5 | 303 | / pub fn PyUnicode_Find( 304 | | str: *mut PyObject, 305 | | substr: *mut PyObject, 306 | | start: Py_ssize_t, 307 | | end: Py_ssize_t, 308 | | direction: c_int, 309 | | ) -> Py_ssize_t; | |____________________- similarly named function `PyUnicode_Find` defined here error[E0425]: cannot find value `PyUnicode_1BYTE_KIND` in module `pyo3::ffi` --> /home/ben/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jiter-0.8.2/src/py_string_cache.rs:218:65 | 218 | debug_assert_eq!(pyo3::ffi::PyUnicode_KIND(ptr), pyo3::ffi::PyUnicode_1BYTE_KIND); | ^^^^^^^^^^^^^^^^^^^^ not found in `pyo3::ffi` error[E0425]: cannot find function, tuple struct or tuple variant `PyUnicode_DATA` in module `pyo3::ffi` --> /home/ben/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jiter-0.8.2/src/py_string_cache.rs:219:31 | 219 | let data_ptr = pyo3::ffi::PyUnicode_DATA(ptr).cast(); | ^^^^^^^^^^^^^^ help: a function with a similar name exists: `PyUnicode_Find` | ::: /home/ben/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-ffi-0.23.5/src/unicodeobject.rs:303:5 | 303 | / pub fn PyUnicode_Find( 304 | | str: *mut PyObject, 305 | | substr: *mut PyObject, 306 | | start: Py_ssize_t, 307 | | end: Py_ssize_t, 308 | | direction: c_int, 309 | | ) -> Py_ssize_t; | |____________________- similarly named function `PyUnicode_Find` defined here For more information about this error, try `rustc --explain E0425`. error: could not compile `jiter` (lib) due to 4 previous errors warning: build failed, waiting for other jobs to finish... 💥 maturin failed Caused by: Failed to build a native library through cargo Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_ENVIRONMENT_SIGNATURE="cpython-3.14-64bit" PYO3_PYTHON="/home/ben/.cache/uv/builds-v0/.tmpvltD2Y/bin/python" PYTHON_SYS_EXECUTABLE="/home/ben/.cache/uv/builds-v0/.tmpvltD2Y/bin/python" "cargo" "rustc" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/ben/src/forks/pydantic-core/Cargo.toml" "--release" "--lib" "--crate-type" "cdylib"` Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/home/ben/.cache/uv/builds-v0/.tmpvltD2Y/bin/python', '--compatibility', 'off'] returned non-zero exit status 1 hint: This usually indicates a problem with the package or the build environment. Pydantic is also complicated and subtle enough that it tends to be difficult to fix issues downstream. Fortunately, upstream does tend to be proactive about supporting new Python versions, just rather later in the release cycle. Segmentation faults and garbage output could be due to pyo3-ffi not yet having fully correct object layouts for Python 3.14, as discussed in https://github.com/PyO3/pyo3/issues/3555. Noted that PyO3 and Pydantic do have some of the same maintainers, particularly David Hewitt, so the projects collaborate closely. Overall, just as we saw with bug 2259626, I think it’s going to be hard to do much about this until later in the Python development cycle.
I am aware pydantic developers prefer to wait until the beta versions of Python. No pressure on reporting things upstream too soon. Fortunately pydantic isn't that big of a blocker in the grand scheme of things. I just prefer to update the relevant information in the downstream bug reports when periodically revisiting the dependency tree of the internal rebuild, so that things are easier to find and mitigate, once fixes appear.
(In reply to Karolina Surma from comment #4) > I am aware pydantic developers prefer to wait until the beta versions of > Python. No pressure on reporting things upstream too soon. Fortunately > pydantic isn't that big of a blocker in the grand scheme of things. I just > prefer to update the relevant information in the downstream bug reports when > periodically revisiting the dependency tree of the internal rebuild, so that > things are easier to find and mitigate, once fixes appear. I do appreciate the updates. Knowing the latest status is helpful even if I can’t do much about it yet.
I’m preparing to ship Pydantic 2.11[1] with pydantic-core 2.33.1[2] in Rawhide. I didn’t necessarily expect this to bring Python 3.14 support but, but I decided to at least check to see if anything had changed. Since building python-inline-snapshot for Python 3.14 is still blocked by dependencies – at least python-executing – I used --without inline_snapshot_tests to get a local mock build of pydantic-core 2.33.1 for Python 3.14. [1] https://src.fedoraproject.org/rpms/python-pydantic/pull-request/43 [2] https://src.fedoraproject.org/rpms/python-pydantic-core/pull-request/21 + /usr/bin/pytest --ignore=tests/benchmarks --ignore=tests/validators/test_allow_partial.py -k '' -rs Fatal Python error: Segmentation fault Current thread 0x00007f1ee0e65bc0 [pytest] (most recent call first): File "/builddir/build/BUILD/python-pydantic-core-2.33.1-build/pydantic-core-2.33.1/tests/serializers/test_any.py", line 59 in __init__ File "/builddir/build/BUILD/python-pydantic-core-2.33.1-build/pydantic-core-2.33.1/tests/serializers/test_any.py", line 78 in <module> File "/usr/lib/python3.14/site-packages/_pytest/assertion/rewrite.py", line 184 in exec_module File "<frozen importlib._bootstrap>", line 938 in _load_unlocked File "<frozen importlib._bootstrap>", line 1342 in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1371 in _find_and_load File "<frozen importlib._bootstrap>", line 1398 in _gcd_import File "/usr/lib64/python3.14/importlib/__init__.py", line 88 in import_module File "/usr/lib/python3.14/site-packages/_pytest/pathlib.py", line 587 in import_path File "/usr/lib/python3.14/site-packages/_pytest/python.py", line 493 in importtestmodule File "/usr/lib/python3.14/site-packages/_pytest/python.py", line 546 in _getobj File "/usr/lib/python3.14/site-packages/_pytest/python.py", line 284 in obj File "/usr/lib/python3.14/site-packages/_pytest/python.py", line 562 in _register_setup_module_fixture File "/usr/lib/python3.14/site-packages/_pytest/python.py", line 549 in collect File "/usr/lib/python3.14/site-packages/_pytest/runner.py", line 389 in collect File "/usr/lib/python3.14/site-packages/_pytest/runner.py", line 341 in from_call File "/usr/lib/python3.14/site-packages/_pytest/runner.py", line 391 in pytest_make_collect_report File "/usr/lib/python3.14/site-packages/pluggy/_callers.py", line 103 in _multicall File "/usr/lib/python3.14/site-packages/pluggy/_manager.py", line 120 in _hookexec File "/usr/lib/python3.14/site-packages/pluggy/_hooks.py", line 513 in __call__ File "/usr/lib/python3.14/site-packages/_pytest/runner.py", line 567 in collect_one_node File "/usr/lib/python3.14/site-packages/_pytest/main.py", line 835 in _collect_one_node File "/usr/lib/python3.14/site-packages/_pytest/main.py", line 970 in genitems File "/usr/lib/python3.14/site-packages/_pytest/main.py", line 975 in genitems File "/usr/lib/python3.14/site-packages/_pytest/main.py", line 975 in genitems File "/usr/lib/python3.14/site-packages/_pytest/main.py", line 809 in perform_collect File "/usr/lib/python3.14/site-packages/_pytest/main.py", line 347 in pytest_collection File "/usr/lib/python3.14/site-packages/pluggy/_callers.py", line 103 in _multicall File "/usr/lib/python3.14/site-packages/pluggy/_manager.py", line 120 in _hookexec File "/usr/lib/python3.14/site-packages/pluggy/_hooks.py", line 513 in __call__ File "/usr/lib/python3.14/site-packages/_pytest/main.py", line 336 in _main File "/usr/lib/python3.14/site-packages/_pytest/main.py", line 283 in wrap_session File "/usr/lib/python3.14/site-packages/_pytest/main.py", line 330 in pytest_cmdline_main File "/usr/lib/python3.14/site-packages/pluggy/_callers.py", line 103 in _multicall File "/usr/lib/python3.14/site-packages/pluggy/_manager.py", line 120 in _hookexec File "/usr/lib/python3.14/site-packages/pluggy/_hooks.py", line 513 in __call__ File "/usr/lib/python3.14/site-packages/_pytest/config/__init__.py", line 175 in main File "/usr/lib/python3.14/site-packages/_pytest/config/__init__.py", line 201 in console_main File "/usr/bin/pytest", line 8 in <module> That seems to be worse than before, but I trust upstream will investigate Python 3.14 in due time. There’s now a tracking issue https://github.com/pydantic/pydantic/issues/11613. Other related tracking issues/PR’s: https://github.com/PyO3/pyo3/issues/4662 https://github.com/PyO3/pyo3/pull/4811
PyO3 0.25 is releasing today with Python 3.14 support. I know Pydantic will Python 3.14 issues of its own, but a compatible PyO3 helps clear the way for upstream to actually work on them.
With b1, in a clean environment, I can't even get that far (build --without inline_snapshot_tests): cargo:rerun-if-changed=generate_self_schema.py --- stderr Traceback (most recent call last): File "/builddir/build/BUILD/python-pydantic-core-2.33.2-build/pydantic-core-2.33.2/generate_self_schema.py", line 245, in <module> main() ~~~~^^ File "/builddir/build/BUILD/python-pydantic-core-2.33.2-build/pydantic-core-2.33.2/generate_self_schema.py", line 212, in main m = re.search(r"Literal\['(.+?)']", type_.__forward_arg__) ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute '__forward_arg__' thread 'main' panicked at build.rs:29:9: generate_self_schema.py failed with exit status: 1
Since 2.35.0, pydantic-core supports Python 3.15, but Pydantic itself is not ready yet. We need to update these together.
*** Bug 2372055 has been marked as a duplicate of this bug. ***