mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Introduce AsPyObject to replace IdProtocol
This commit is contained in:
12
src/lib.rs
12
src/lib.rs
@@ -51,8 +51,8 @@ use rustpython_vm::{
|
||||
compile, match_class,
|
||||
scope::Scope,
|
||||
stdlib::{atexit, sys},
|
||||
InitParameter, Interpreter, PyObjectRef, PyResult, PySettings, TryFromObject, TypeProtocol,
|
||||
VirtualMachine,
|
||||
AsPyObject, InitParameter, Interpreter, PyObjectRef, PyResult, PySettings, TryFromObject,
|
||||
TypeProtocol, VirtualMachine,
|
||||
};
|
||||
use std::{env, path::Path, process, str::FromStr};
|
||||
|
||||
@@ -536,12 +536,8 @@ fn setup_main_module(vm: &VirtualMachine) -> PyResult<Scope> {
|
||||
main_module
|
||||
.dict()
|
||||
.and_then(|d| {
|
||||
d.set_item(
|
||||
"__annotations__",
|
||||
vm.ctx.new_dict().as_object().to_owned(),
|
||||
vm,
|
||||
)
|
||||
.ok()
|
||||
d.set_item("__annotations__", vm.ctx.new_dict().into(), vm)
|
||||
.ok()
|
||||
})
|
||||
.expect("Failed to initialize __main__.__annotations__");
|
||||
|
||||
|
||||
@@ -85,9 +85,8 @@ impl<'vm> ShellHelper<'vm> {
|
||||
} else {
|
||||
// we need to get a variable based off of globals/builtins
|
||||
|
||||
let globals = str_iter_method(self.globals.as_object().to_owned(), "keys").ok()?;
|
||||
let builtins =
|
||||
str_iter_method(self.vm.builtins.as_object().to_owned(), "__dir__").ok()?;
|
||||
let globals = str_iter_method(self.globals.clone().into(), "keys").ok()?;
|
||||
let builtins = str_iter_method(self.vm.builtins.clone().into(), "__dir__").ok()?;
|
||||
(first, globals, Some(builtins))
|
||||
};
|
||||
Some((word_start, iter1.chain(iter2.into_iter().flatten())))
|
||||
|
||||
Reference in New Issue
Block a user