Skip to content

[BUG]: Distinct classes with the same name but in separate anonymous namespaces considered duplicates #5627

@dyollb

Description

@dyollb

Required prerequisites

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

master

Problem description

Distinct classes with the same name but in separate anonymous namespaces trigger

ImportError: generic_type: type "Foo" is already registered!

This seems to be a new behavior in the current master branch and did not happen in 2.13.6.

I came across this issue when I was preparing a PR for pybind11-stubgen to update to v3.

Reproducible example code

Register a class in two different compilation units:

namespace {
class Foo {};
}

TEST_SUBMODULE(class, m) {
    py::class_<Foo>(m, "Foo");
}

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

This worked in v2.13.6

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