Skip to content

Commit f2424c5

Browse files
committed
Don't add the builtins module name in get_fully_qualified_tp_name for PyPy
1 parent d8664ad commit f2424c5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

include/pybind11/detail/class.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,20 @@ inline std::string get_fully_qualified_tp_name(PyTypeObject *type) {
2828
#if !defined(PYPY_VERSION)
2929
return type->tp_name;
3030
#else
31-
return handle((PyObject *) type).attr("__module__").cast<std::string>() + "." + type->tp_name;
31+
auto module_name = handle((PyObject *) type).attr("__module__").cast<std::string>();
32+
bool is_builtin_module = module_name ==
33+
# if PY_MAJOR_VERSION >= 3
34+
"builtins"
35+
# else
36+
"__builtin__"
37+
# endif
38+
;
39+
if (is_builtin_module) {
40+
return type->tp_name;
41+
}
42+
else {
43+
return std::move(module_name) + "." + type->tp_name;
44+
}
3245
#endif
3346
}
3447

0 commit comments

Comments
 (0)