Skip to content

Unable to pickle abstract class (using abc.ABC) with type annotations #572

@Viicos

Description

@Viicos

Starting with Python 3.14a3, the following raises a TypeError:

from abc import ABC

import cloudpickle

def class_factory():
    class Model(ABC):
        field: int

    return Model

cloudpickle.dumps(model_factory())
"""
TypeError: cannot pickle '_abc._abc_data' object
when serializing dict item '_abc_impl'
when serializing tuple item 0
when serializing cell reconstructor arguments
when serializing cell object
when serializing tuple item 0
when serializing dict item '__closure__'
when serializing tuple item 1
when serializing function state
when serializing function object
when serializing dict item '__annotate_func__'
when serializing tuple item 0
when serializing abc.ABCMeta state
when serializing abc.ABCMeta object
"""

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions