Skip to content

Alternative approach to #3807 #4612

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

Merged
merged 8 commits into from
Apr 10, 2023
Merged

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Apr 8, 2023

This approach supports an important PyCLIF use case: Base not specified in classh<Derived> statement, but passing Derived as Base works anyway.

Description

Suggested changelog entry:

@rwgk
Copy link
Collaborator Author

rwgk commented Apr 9, 2023

@wangxf123456 FYI

This PR all by itself (without additional changes in PyCLIF-pybind11) fixes //third_party/clif/testing/python:final_test

For completeness, the error (before this PR is applied) was:

[ RUN      ] FinalTest.testCanUseSwigFinalAsFinal
[  FAILED  ] FinalTest.testCanUseSwigFinalAsFinal
======================================================================
ERROR: testCanUseSwigFinalAsFinal (__main__.FinalTest)
FinalTest.testCanUseSwigFinalAsFinal
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/work/.../google3/runfiles/google3/third_party/clif/testing/python/final_test.py", line 12, in testCanUseSwigFinalAsFinal
    final.TakesFinal(swig_object)
TypeError: TakesFinal(): incompatible function arguments. The following argument types are supported:
    1. (final: google3.third_party.clif.testing.python.final.Final) -> None

Invoked with: <google3.third_party.clif.testing.python.final.SwigFinal object at 0x7fbe0b5d03f0>

@rwgk rwgk marked this pull request as ready for review April 10, 2023 17:43
@rwgk
Copy link
Collaborator Author

rwgk commented Apr 10, 2023

Google-internal global testing ID: OCL:522836781:BASE:523134970:1681144155208:16ce654b

@rwgk rwgk merged commit d930de0 into pybind:smart_holder Apr 10, 2023
@rwgk rwgk deleted the as_base_ptrs_sh branch April 10, 2023 18:13
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Apr 10, 2023
@rwgk rwgk removed the needs changelog Possibly needs a changelog entry label Apr 10, 2023
wangxf123456 pushed a commit to google/clif that referenced this pull request Apr 12, 2023
This change was enabled by pybind/pybind11#4612

TGP-tested via TGP-head 2023-04-06 (cl/522266833) re-run with this change:

* https://fusion2.corp.google.com/presubmit/tap/522266833/OCL:522266833:BASE:522968984:1681064677276:5304c616;groups=Passing/targets

* 116 Passing

Example generated code:

```
      UnspecDerived_class.def(
          "as_clif_testing_unspecified_inheritance_UnspecBase",
          [](::clif_testing::unspecified_inheritance::UnspecDerived* self) {
              return py::capsule(static_cast<void *>(self));
          }
      );
```

PiperOrigin-RevId: 523233130
wangxf123456 pushed a commit to google/clif that referenced this pull request Apr 14, 2023
This change was enabled by pybind/pybind11#4612

TGP-tested via TGP-head 2023-04-06 (cl/522266833) re-run with this change:

* https://fusion2.corp.google.com/presubmit/tap/522266833/OCL:522266833:BASE:522968984:1681064677276:5304c616;groups=Passing/targets

* 116 Passing

Example generated code:

```
      UnspecDerived_class.def(
          "as_clif_testing_unspecified_inheritance_UnspecBase",
          [](::clif_testing::unspecified_inheritance::UnspecDerived* self) {
              return py::capsule(static_cast<void *>(self));
          }
      );
```

PiperOrigin-RevId: 523233130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants