ITADN

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

#5994OpenHMRWork42 创建于 2026-02-24
triage
H
HMRWork42commented
### Required prerequisites - [x] Make sure you've read the [documentation](https://pybind11.readthedocs.io). Your issue may be addressed there. - [x] Search the [issue tracker](https://github.com/pybind/pybind11/issues) and [Discussions](https:/pybind/pybind11/discussions) to verify that this hasn't already been reported. +1 or comment there if it has. - [x] Consider asking first in the [Gitter chat room](https://gitter.im/pybind/Lobby) or in a [Discussion](https:/pybind/pybind11/discussions/new). ### 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 ```text 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
1 条评论