Skip to content

Commit

Permalink
Patch in PR pybind#4313: Minimal reproducer for clash when binding ty…
Browse files Browse the repository at this point in the history
…pes defined in the unnamed namespace.
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Nov 7, 2022
1 parent 9141519 commit ba747dc
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ set(PYBIND11_TEST_FILES
test_tagbased_polymorphic
test_thread
test_union
test_unnamed_namespace_a
test_unnamed_namespace_b
test_virtual_functions)

# Invoking cmake with something like:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_unnamed_namespace_a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "pybind11_tests.h"

namespace {
struct any_struct {};
} // namespace

TEST_SUBMODULE(unnamed_namespace_a, m) {
py::class_<any_struct>(m, "unnamed_namespace_a_any_struct");
}
5 changes: 5 additions & 0 deletions tests/test_unnamed_namespace_a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pybind11_tests import unnamed_namespace_a as m


def test_have_type():
assert hasattr(m, "unnamed_namespace_a_any_struct")
9 changes: 9 additions & 0 deletions tests/test_unnamed_namespace_b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "pybind11_tests.h"

namespace {
struct any_struct {};
} // namespace

TEST_SUBMODULE(unnamed_namespace_b, m) {
py::class_<any_struct>(m, "unnamed_namespace_b_any_struct");
}
5 changes: 5 additions & 0 deletions tests/test_unnamed_namespace_b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pybind11_tests import unnamed_namespace_b as m


def test_have_type():
assert hasattr(m, "unnamed_namespace_b_any_struct")

0 comments on commit ba747dc

Please sign in to comment.