Skip to content

Python 3.14 with marshal::dumps on slices: unmarshallable object #5568

@nschloe

Description

@nschloe

Bug Description

Python 3.14 adds marshal version 5 with support for slices. PyO3 continues to use version 4 with the consequence that simple code with slices like a[:] can no longer be marshalled in Python 3.14.

For example, this

let compiled = PyCode::compile(
    py,
    CString::new("a[:]").unwrap().as_c_str(),
    CString::new("foo.py").unwrap().as_c_str(),
    PyCodeInput::File,
)?;
pyo3::marshal::dumps(&compiled, pyo3::marshal::VERSION)?;

will fail with

E       ValueError: unmarshallable object

It works in Python 3.13 and earlier; it also works with VERSION = 5.

Steps to Reproduce

See above.

Backtrace

Your operating system and version

Linux 6.12.53-1-lts

Your Python version (python --version)

3.14

Your Rust version (rustc --version)

rustc 1.90.0 (1159e78c4 2025-09-14) (Arch Linux rust 1:1.90.0-4)

Your PyO3 version

0.27.9

How did you install python? Did you use a virtualenv?

uv venv --python 3.14

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions