-
Notifications
You must be signed in to change notification settings - Fork 951
Closed
Description
🐛 Bug Reports
🌍 Environment
- Your operating system and version: Ubuntu 18.10
- Your python version: 3.6.7
- How did you install python (e.g. apt or pyenv)? apt
- Did you use a virtualenv?: no
- Your rust version (
rustc --version): rustc 1.34.0-nightly (aadbc459b 2019-02-23) - Are you using the latest pyo3 version? Have you tried using latest master (replace
version = "0.x.y"withgit = "https://github.com/PyO3/pyo3")?yes
💥 Reproducing
The following code from https://pyo3.rs/master/class.html#inheritance
#![allow(unused_variables)]
fn main() {
use pyo3::prelude::*;
use pyo3::PyRawObject;
#[pyclass]
struct BaseClass {
val1: usize,
}
#[pymethods]
impl BaseClass {
#[new]
fn new(obj: &PyRawObject) {
obj.init(BaseClass { val1: 10 });
}
pub fn method(&self) -> PyResult<()> {
Ok(())
}
}
#[pyclass(extends=BaseClass)]
struct SubClass {
val2: usize,
}
#[pymethods]
impl SubClass {
#[new]
fn new(obj: &PyRawObject) {
obj.init(SubClass { val2: 10 });
BaseClass::new(obj);
}
fn method2(&self) -> PyResult<()> {
self.get_base().method()
}
}
}gives me
error[E0599]: no method named `get_base` found for type `&main::SubClass` in the current scope
--> src/main.rs:93:15
|
93 | self.get_base().method()
| ^^^^^^^^
|
= note: the method `get_base` exists but the following trait bounds were not satisfied:
`&main::SubClass : pyo3::objectprotocol::ObjectProtocol`
`main::SubClass : pyo3::objectprotocol::ObjectProtocol`
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `get_base`, perhaps you need to implement it:
candidate #1: `pyo3::objectprotocol::ObjectProtocol`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels