Skip to content
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

Fix a bad span of _slf for custom receivers in #[pymethods]. #3178

Merged
merged 1 commit into from May 23, 2023

Conversation

lifthrasiir
Copy link
Contributor

This turned out to be a remnant of #1506. It notably resulted in a very confusing error:

error[E0308]: mismatched types
    --> tests\test_methods.rs:1456:9
     |
1456 |           #[pymethods]
     |           ^^^^^^^^^^^^
     |           |
     |           expected `Py<Issue1506>`, found `*mut PyObject`
     |           arguments to this function are incorrect
...
1461 | / issue_1506!(
1462 | |     #[pymethods]
1463 | |     impl Issue1506 {
1464 | |         fn issue_1506(
...    |
1536 | |     }
1537 | | );
     | |_- in this macro invocation
     |
     = note:   expected struct `pyo3::Py<Issue1506>`
             found raw pointer `*mut pyo3::ffi::PyObject`

The actual cause is that SelfType::receiver is entirely ignored in this case and _slf refers to the original argument, but it sounds like that TryFrom::try_from somehow resulted in *mut PyObject...

@adamreichold
Copy link
Member

Great find! Thanks.

bors r+

@bors
Copy link
Contributor

bors bot commented May 23, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 408bf11 into PyO3:main May 23, 2023
33 checks passed
@lifthrasiir lifthrasiir deleted the pymethods-bad-span branch May 23, 2023 12:10
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.

None yet

2 participants