Skip to content

[BUG]: cannot register submodules for embedded modules #5649

@rkaminsk

Description

@rkaminsk

Required prerequisites

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

c125cc7

Problem description

Pybind's module_::def_submodule function requires the module to have a __file__ attribute. However, when creating an embedded module this attribute is not set.

I would think that adding submodules is a valid use-case that should not need any workarounds.

Reproducible example code

As a workaround, I am currently setting the attribute manually:

PYBIND11_EMBEDDED_MODULE(x, m) {
    m.attr("__file__") = "<embedded>";
    m.def_submodule("y");
}

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

The issue was introduced by 8f00d1e. @henryiii maybe you can have a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions