Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
dyollb opened this issue Apr 23, 2025 · 0 comments
Labels
triage New bug, unverified

Comments

@dyollb
Copy link
Contributor

dyollb commented Apr 23, 2025

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

@dyollb dyollb added the triage New bug, unverified label Apr 23, 2025
@dyollb dyollb closed this as completed Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage New bug, unverified
Projects
None yet
Development

No branches or pull requests

1 participant