Skip to content
Prev Previous commit
Next Next commit
Fix compilation without compiler feature
  • Loading branch information
coolreader18 authored and youknowone committed Aug 8, 2024
commit ea11d78995c281f4eeae0513d69d8d2eb127d855
25 changes: 15 additions & 10 deletions stdlib/src/dis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?
};
Expand Down