forked from Rust-related/RustPython
Fix compilation without compiler feature
This commit is contained in:
@@ -13,18 +13,23 @@ mod decl {
|
||||
let co = if let Ok(co) = obj.get_attr("__code__", vm) {
|
||||
// Method or function:
|
||||
PyRef::try_from_object(vm, co)?
|
||||
} else if let Ok(_co_str) = PyStrRef::try_from_object(vm, obj.clone()) {
|
||||
} else if let Ok(co_str) = PyStrRef::try_from_object(vm, obj.clone()) {
|
||||
#[cfg(not(feature = "compiler"))]
|
||||
return Err(vm.new_runtime_error(
|
||||
"dis.dis() with str argument requires `compiler` feature".to_owned(),
|
||||
));
|
||||
{
|
||||
let _ = co_str;
|
||||
return Err(vm.new_runtime_error(
|
||||
"dis.dis() with str argument requires `compiler` feature".to_owned(),
|
||||
));
|
||||
}
|
||||
#[cfg(feature = "compiler")]
|
||||
vm.compile(
|
||||
_co_str.as_str(),
|
||||
crate::vm::compiler::Mode::Exec,
|
||||
"<dis>".to_owned(),
|
||||
)
|
||||
.map_err(|err| vm.new_syntax_error(&err, Some(_co_str.as_str())))?
|
||||
{
|
||||
vm.compile(
|
||||
co_str.as_str(),
|
||||
crate::vm::compiler::Mode::Exec,
|
||||
"<dis>".to_owned(),
|
||||
)
|
||||
.map_err(|err| vm.new_syntax_error(&err, Some(co_str.as_str())))?
|
||||
}
|
||||
} else {
|
||||
PyRef::try_from_object(vm, obj)?
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user