From 7280380378c05be4aed539cc2722b87b90f4a35b Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 21 Oct 2023 11:20:45 -0700 Subject: [PATCH] Fix `handle_type_name` as suggested by @sizmailov: https://github.com/pybind/pybind11/pull/4888#discussion_r1367775289 NOTE: This is actually a bug fix, in its own right. --- include/pybind11/cast.h | 8 ++++---- tests/test_pytypes.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 9da63772ed..af6705b62d 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -888,6 +888,10 @@ struct handle_type_name { static constexpr auto name = const_name("dict"); }; template <> +struct handle_type_name { + static constexpr auto name = const_name("set"); +}; +template <> struct handle_type_name { static constexpr auto name = const_name("set"); }; @@ -896,10 +900,6 @@ struct handle_type_name { static constexpr auto name = const_name("frozenset"); }; template <> -struct handle_type_name { - static constexpr auto name = const_name("anyset"); -}; -template <> struct handle_type_name { static constexpr auto name = const_name("str"); }; diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index 2b2027316c..2824d29f94 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -121,7 +121,7 @@ def test_set(capture, doc): assert m.anyset_contains({"foo"}, "foo") assert doc(m.get_set) == "get_set() -> set" - assert doc(m.print_anyset) == "print_anyset(arg0: anyset) -> None" + assert doc(m.print_anyset) == "print_anyset(arg0: set) -> None" def test_frozenset(capture, doc):