Skip to content

Commit 44a32c0

Browse files
Fix qualname prefix in pybind11 3.0.0 (#259)
Pybind11 3 changed the holder for functions to a type starting with `pybind11_detail_function_record_` Eg `pybind11_detail_function_record_v1_msvc_md_mscver19` This breaks the old implementation. This fix should fix all the cases.
1 parent bcbb324 commit 44a32c0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pybind11_stubgen/parser/mixins/parse.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,15 @@ def _get_full_name(self, path: QualifiedName, origin: Any) -> QualifiedName | No
418418
if qual_name is None:
419419
self.report_error(NameResolutionError(path))
420420
return None
421-
# Note: `PyCapsule.` prefix in __qualname__ is an artefact of pybind11
422-
_PyCapsule = "PyCapsule."
423-
if qual_name.startswith(_PyCapsule):
424-
qual_name = qual_name[len(_PyCapsule) :]
421+
# Note: __qualname__ prefix is an artefact of pybind11
422+
# `PyCapsule.` in pybind11 2
423+
# pybind11_detail_function_record_* in 3
424+
match = re.match(
425+
r"(PyCapsule|pybind11_detail_function_record_[_a-zA-Z0-9]+)\.",
426+
qual_name,
427+
)
428+
if match:
429+
qual_name = qual_name[match.end() :]
425430
origin_full_name = f"{module_name}.{qual_name}"
426431

427432
origin_name = QualifiedName.from_str(origin_full_name)

0 commit comments

Comments
 (0)