mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-09 22:25:23 +00:00
Fix pyo3 unit type value error
This commit is contained in:
parent
ff17f6e178
commit
2e6e6c01e7
1 changed files with 6 additions and 3 deletions
|
@ -113,10 +113,13 @@ impl AST {
|
|||
}
|
||||
|
||||
fn cache_py_type<N: Pyo3Node + Node>(ast_module: &PyAny) -> PyResult<()> {
|
||||
let class = ast_module.getattr(N::NAME).unwrap();
|
||||
let base = class.getattr("__new__").unwrap();
|
||||
let class = ast_module.getattr(N::NAME)?;
|
||||
let base = if std::mem::size_of::<N>() == 0 {
|
||||
class.call0()?
|
||||
} else {
|
||||
class.getattr("__new__")?
|
||||
};
|
||||
N::py_type_cache().get_or_init(|| (class.into(), base.into()));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue