Skip to content

Commit 4d0e357

Browse files
committed
Fix ast error types and messages
1 parent 53b3448 commit 4d0e357

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

vm/src/stdlib/ast.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ impl Node for ast::Constant {
239239
}
240240
builtins::singletons::PyNone => ast::Constant::None,
241241
builtins::slice::PyEllipsis => ast::Constant::Ellipsis,
242-
_ => return Err(vm.new_type_error("unsupported type for constant".to_owned())),
242+
obj =>
243+
return Err(vm.new_type_error(format!(
244+
"invalid type in Constant: type '{}'",
245+
obj.class().name()
246+
))),
243247
});
244248
Ok(constant)
245249
}

vm/src/stdlib/builtins.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ mod builtins {
109109
dont_inherit: OptionalArg<bool>,
110110
#[pyarg(any, optional)]
111111
optimize: OptionalArg<PyIntRef>,
112+
#[pyarg(any, optional)]
113+
_feature_version: OptionalArg<i32>,
112114
}
113115

114116
#[cfg(feature = "rustpython-compiler")]
@@ -122,6 +124,10 @@ mod builtins {
122124
{
123125
use crate::{class::PyClassImpl, stdlib::ast};
124126

127+
if args._feature_version.is_present() {
128+
eprintln!("TODO: compile() got `_feature_version` but ignored");
129+
}
130+
125131
let mode_str = args.mode.as_str();
126132

127133
if args

0 commit comments

Comments
 (0)