mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
@@ -297,7 +297,7 @@ impl SymbolTableAnalyzer {
|
||||
&mut self,
|
||||
symbol: &mut Symbol,
|
||||
st_typ: SymbolTableType,
|
||||
sub_tables: &mut [SymbolTable],
|
||||
sub_tables: &[SymbolTable],
|
||||
) -> SymbolTableResult {
|
||||
if symbol
|
||||
.flags
|
||||
|
||||
@@ -119,8 +119,8 @@ impl<'vm> ShellHelper<'vm> {
|
||||
// only the completions that don't start with a '_'
|
||||
let no_underscore = all_completions
|
||||
.iter()
|
||||
.filter(|&s| !s.as_str().starts_with('_'))
|
||||
.cloned()
|
||||
.filter(|s| !s.as_str().starts_with('_'))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// if there are only completions that start with a '_', give them all of the
|
||||
|
||||
@@ -310,7 +310,7 @@ mod zlib {
|
||||
|
||||
fn save_unused_input(
|
||||
&self,
|
||||
d: &mut Decompress,
|
||||
d: &Decompress,
|
||||
data: &[u8],
|
||||
stream_end: bool,
|
||||
orig_in: u64,
|
||||
@@ -349,7 +349,7 @@ mod zlib {
|
||||
Ok((buf, false)) => (Ok(buf), false),
|
||||
Err(err) => (Err(err), false),
|
||||
};
|
||||
self.save_unused_input(&mut d, data, stream_end, orig_in, vm);
|
||||
self.save_unused_input(&d, data, stream_end, orig_in, vm);
|
||||
|
||||
let leftover = if stream_end {
|
||||
b""
|
||||
@@ -390,7 +390,7 @@ mod zlib {
|
||||
Ok((buf, stream_end)) => (Ok(buf), stream_end),
|
||||
Err(err) => (Err(err), false),
|
||||
};
|
||||
self.save_unused_input(&mut d, &data, stream_end, orig_in, vm);
|
||||
self.save_unused_input(&d, &data, stream_end, orig_in, vm);
|
||||
|
||||
*data = PyBytes::from(Vec::new()).into_ref(&vm.ctx);
|
||||
|
||||
|
||||
@@ -1946,22 +1946,18 @@ impl ExecutingFrame<'_> {
|
||||
impl fmt::Debug for Frame {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let state = self.state.lock();
|
||||
let stack_str = state
|
||||
.stack
|
||||
.iter()
|
||||
.map(|elem| {
|
||||
if elem.payload_is::<Frame>() {
|
||||
"\n > {frame}".to_owned()
|
||||
} else {
|
||||
format!("\n > {elem:?}")
|
||||
}
|
||||
})
|
||||
.collect::<String>();
|
||||
let block_str = state
|
||||
.blocks
|
||||
.iter()
|
||||
.map(|elem| format!("\n > {elem:?}"))
|
||||
.collect::<String>();
|
||||
let stack_str = state.stack.iter().fold(String::new(), |mut s, elem| {
|
||||
if elem.payload_is::<Frame>() {
|
||||
s.push_str("\n > {frame}");
|
||||
} else {
|
||||
std::fmt::write(&mut s, format_args!("\n > {elem:?}")).unwrap();
|
||||
}
|
||||
s
|
||||
});
|
||||
let block_str = state.blocks.iter().fold(String::new(), |mut s, elem| {
|
||||
std::fmt::write(&mut s, format_args!("\n > {elem:?}")).unwrap();
|
||||
s
|
||||
});
|
||||
// TODO: fix this up
|
||||
let locals = self.locals.clone();
|
||||
write!(
|
||||
|
||||
@@ -31,10 +31,7 @@ pub(crate) fn init_importlib_base(vm: &mut VirtualMachine) -> PyResult<PyObjectR
|
||||
Ok(importlib)
|
||||
}
|
||||
|
||||
pub(crate) fn init_importlib_package(
|
||||
vm: &mut VirtualMachine,
|
||||
importlib: PyObjectRef,
|
||||
) -> PyResult<()> {
|
||||
pub(crate) fn init_importlib_package(vm: &VirtualMachine, importlib: PyObjectRef) -> PyResult<()> {
|
||||
thread::enter_vm(vm, || {
|
||||
flame_guard!("install_external");
|
||||
|
||||
|
||||
@@ -116,10 +116,12 @@ macro_rules! match_class {
|
||||
|
||||
// The default arm, binding the original object to the specified identifier.
|
||||
(match ($obj:expr) { $binding:ident => $default:expr $(,)? }) => {{
|
||||
#[allow(clippy::redundant_locals)]
|
||||
let $binding = $obj;
|
||||
$default
|
||||
}};
|
||||
(match ($obj:expr) { ref $binding:ident => $default:expr $(,)? }) => {{
|
||||
#[allow(clippy::redundant_locals)]
|
||||
let $binding = &$obj;
|
||||
$default
|
||||
}};
|
||||
|
||||
@@ -168,7 +168,7 @@ fn range_from_object(
|
||||
None
|
||||
};
|
||||
let range = SourceRange {
|
||||
start: location.unwrap_or(SourceLocation::default()),
|
||||
start: location.unwrap_or_default(),
|
||||
end: end_location,
|
||||
};
|
||||
Ok(range)
|
||||
|
||||
@@ -784,8 +784,8 @@ mod sys {
|
||||
impl PyThreadInfo {
|
||||
const INFO: Self = PyThreadInfo {
|
||||
name: crate::stdlib::thread::_thread::PYTHREAD_NAME,
|
||||
/// As I know, there's only way to use lock as "Mutex" in Rust
|
||||
/// with satisfying python document spec.
|
||||
// As I know, there's only way to use lock as "Mutex" in Rust
|
||||
// with satisfying python document spec.
|
||||
lock: Some("mutex+cond"),
|
||||
version: None,
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ pub mod eval {
|
||||
|
||||
fn run_py(source: &str, options: Option<Object>, mode: Mode) -> Result<JsValue, JsValue> {
|
||||
let vm = VMStore::init(PY_EVAL_VM_ID.into(), Some(true));
|
||||
let options = options.unwrap_or_else(Object::new);
|
||||
let options = options.unwrap_or_default();
|
||||
let js_vars = {
|
||||
let prop = Reflect::get(&options, &"vars".into())?;
|
||||
if prop.is_undefined() {
|
||||
|
||||
Reference in New Issue
Block a user