Skip to content

[BUG]: incompatibility of py::native_enum in 3.x with py::arg_v() default values #5994

@HMRWork42

Description

@HMRWork42

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

3.0.2

Problem description

I am having some issues with upgrading to 3.0.2, and it seems to point towards the deprecated pybind11::enum being a contributing factor, so I tried switching to pybind11::native_enum. Most conversion works (and with a bit of additional effort removing py::arithmetic()). But there seems to be a registration problem when used together with py::arg_v() to indicate a default value.

Reproducible example code

py::native_enum<GrRenderable>(m, "GrRenderable", "enum.Enum")
    .value("kNo", GrRenderable::kNo)
    .value("kYes", GrRenderable::kYes)
    .export_values();

...
py::class_<GrRecordingContext, sk_sp<GrRecordingContext>, GrImageContext>(
    m, "GrRecordingContext")
    .def("defaultBackendFormat", &GrRecordingContext::defaultBackendFormat,
        py::arg("colorType"),
        py::arg_v("renderable", GrRenderable::kNo, "skia.GrRenderable.kNo"));
...

Is this a regression? Put the last known working version here if it is.

native_enum is new in 3.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions