mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Re-export pyobject::* from the root of the crate
This commit is contained in:
133 files changed
+300
-323
No files matched your search
@@ -4,8 +4,8 @@ use criterion::{
|
||||
};
|
||||
use rustpython_compiler::Mode;
|
||||
use rustpython_parser::parser::parse_program;
|
||||
use rustpython_vm::pyobject::PyResult;
|
||||
use rustpython_vm::Interpreter;
|
||||
use rustpython_vm::PyResult;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ use criterion::{
|
||||
criterion_group, criterion_main, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, Throughput,
|
||||
};
|
||||
use rustpython_compiler::Mode;
|
||||
use rustpython_vm::pyobject::ItemProtocol;
|
||||
use rustpython_vm::pyobject::PyResult;
|
||||
use rustpython_vm::ItemProtocol;
|
||||
use rustpython_vm::PyResult;
|
||||
use rustpython_vm::{InitParameter, Interpreter, PySettings};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{ffi, fs, io};
|
||||
|
||||
@@ -158,7 +158,7 @@ fn generate_field((i, field): (usize, &Field)) -> Result<TokenStream2, Diagnosti
|
||||
.or(namestring)
|
||||
.ok_or_else(|| err_span!(field, "field in tuple struct must have name attribute"))?;
|
||||
let middle = quote! {
|
||||
.map(|x| ::rustpython_vm::pyobject::TryFromObject::try_from_object(vm, x)).transpose()?
|
||||
.map(|x| ::rustpython_vm::TryFromObject::try_from_object(vm, x)).transpose()?
|
||||
};
|
||||
let ending = if let Some(default) = attr.default {
|
||||
let default = default.unwrap_or_else(|| parse_quote!(::std::default::Default::default()));
|
||||
|
||||
@@ -68,11 +68,11 @@ pub(crate) fn impl_pyimpl(
|
||||
let class_extensions = &context.class_extensions;
|
||||
quote! {
|
||||
#imp
|
||||
impl ::rustpython_vm::pyobject::PyClassImpl for #ty {
|
||||
impl ::rustpython_vm::PyClassImpl for #ty {
|
||||
const TP_FLAGS: ::rustpython_vm::slots::PyTpFlags = ::rustpython_vm::slots::PyTpFlags::from_bits_truncate(#flags);
|
||||
|
||||
fn impl_extend_class(
|
||||
ctx: &::rustpython_vm::pyobject::PyContext,
|
||||
ctx: &::rustpython_vm::PyContext,
|
||||
class: &::rustpython_vm::builtins::PyTypeRef,
|
||||
) {
|
||||
#getset_impl
|
||||
@@ -105,7 +105,7 @@ pub(crate) fn impl_pyimpl(
|
||||
let extra_methods = iter_chain![
|
||||
parse_quote! {
|
||||
fn __extend_py_class(
|
||||
ctx: &::rustpython_vm::pyobject::PyContext,
|
||||
ctx: &::rustpython_vm::PyContext,
|
||||
class: &::rustpython_vm::builtins::PyTypeRef,
|
||||
) {
|
||||
#getset_impl
|
||||
@@ -180,14 +180,14 @@ fn generate_class_def(
|
||||
let base_class = if is_pystruct {
|
||||
quote! {
|
||||
fn static_baseclass() -> &'static ::rustpython_vm::builtins::PyTypeRef {
|
||||
use rustpython_vm::pyobject::StaticType;
|
||||
use rustpython_vm::StaticType;
|
||||
rustpython_vm::builtins::PyTuple::static_type()
|
||||
}
|
||||
}
|
||||
} else if let Some(base) = base {
|
||||
quote! {
|
||||
fn static_baseclass() -> &'static ::rustpython_vm::builtins::PyTypeRef {
|
||||
use rustpython_vm::pyobject::StaticType;
|
||||
use rustpython_vm::StaticType;
|
||||
#base::static_type()
|
||||
}
|
||||
}
|
||||
@@ -196,14 +196,14 @@ fn generate_class_def(
|
||||
};
|
||||
|
||||
let tokens = quote! {
|
||||
impl ::rustpython_vm::pyobject::PyClassDef for #ident {
|
||||
impl ::rustpython_vm::PyClassDef for #ident {
|
||||
const NAME: &'static str = #name;
|
||||
const MODULE_NAME: Option<&'static str> = #module_name;
|
||||
const TP_NAME: &'static str = #module_class_name;
|
||||
const DOC: Option<&'static str> = #doc;
|
||||
}
|
||||
|
||||
impl ::rustpython_vm::pyobject::StaticType for #ident {
|
||||
impl ::rustpython_vm::StaticType for #ident {
|
||||
fn static_cell() -> &'static ::rustpython_common::static_cell::StaticCell<::rustpython_vm::builtins::PyTypeRef> {
|
||||
::rustpython_common::static_cell! {
|
||||
static CELL: ::rustpython_vm::builtins::PyTypeRef;
|
||||
@@ -555,7 +555,7 @@ impl ToTokens for GetSetNursery {
|
||||
#( #cfgs )*
|
||||
class.set_str_attr(
|
||||
#name,
|
||||
::rustpython_vm::pyobject::PyObject::new(
|
||||
::rustpython_vm::PyObject::new(
|
||||
::rustpython_vm::builtins::PyGetSet::new(#name.into())
|
||||
.with_get(&Self::#getter)
|
||||
#setter #deleter,
|
||||
|
||||
@@ -64,7 +64,7 @@ pub fn impl_pymodule(
|
||||
parse_quote! {
|
||||
pub(crate) fn extend_module(
|
||||
vm: &::rustpython_vm::VirtualMachine,
|
||||
module: &::rustpython_vm::pyobject::PyObjectRef,
|
||||
module: &::rustpython_vm::PyObjectRef,
|
||||
) {
|
||||
#module_extend_items
|
||||
}
|
||||
@@ -73,7 +73,7 @@ pub fn impl_pymodule(
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn make_module(
|
||||
vm: &::rustpython_vm::VirtualMachine
|
||||
) -> ::rustpython_vm::pyobject::PyObjectRef {
|
||||
) -> ::rustpython_vm::PyObjectRef {
|
||||
let module = vm.new_module(MODULE_NAME, vm.ctx.new_dict());
|
||||
extend_module(vm, &module);
|
||||
module
|
||||
@@ -318,7 +318,7 @@ impl ModuleItem for ClassItem {
|
||||
.optional_name()
|
||||
.unwrap_or_else(|| class_name.clone());
|
||||
let new_class = quote_spanned!(ident.span() =>
|
||||
<#ident as ::rustpython_vm::pyobject::PyClassImpl>::make_class(&vm.ctx);
|
||||
<#ident as ::rustpython_vm::PyClassImpl>::make_class(&vm.ctx);
|
||||
);
|
||||
let item = quote! {
|
||||
let new_class = #new_class;
|
||||
|
||||
@@ -29,19 +29,19 @@ pub(crate) fn impl_pystruct_sequence(
|
||||
|
||||
let ty = &input.ident;
|
||||
let ret = quote! {
|
||||
impl ::rustpython_vm::pyobject::PyStructSequence for #ty {
|
||||
impl ::rustpython_vm::PyStructSequence for #ty {
|
||||
const FIELD_NAMES: &'static [&'static str] = &[#(stringify!(#field_names)),*];
|
||||
fn into_tuple(self, vm: &::rustpython_vm::VirtualMachine) -> ::rustpython_vm::builtins::tuple::PyTuple {
|
||||
let items = vec![#(::rustpython_vm::pyobject::IntoPyObject::into_pyobject(
|
||||
let items = vec![#(::rustpython_vm::IntoPyObject::into_pyobject(
|
||||
self.#field_names,
|
||||
vm,
|
||||
)),*];
|
||||
::rustpython_vm::builtins::tuple::PyTuple::_new(items.into_boxed_slice())
|
||||
}
|
||||
}
|
||||
impl ::rustpython_vm::pyobject::IntoPyObject for #ty {
|
||||
fn into_pyobject(self, vm: &::rustpython_vm::VirtualMachine) -> ::rustpython_vm::pyobject::PyObjectRef {
|
||||
::rustpython_vm::pyobject::PyStructSequence::into_struct_sequence(self, vm).into_object()
|
||||
impl ::rustpython_vm::IntoPyObject for #ty {
|
||||
fn into_pyobject(self, vm: &::rustpython_vm::VirtualMachine) -> ::rustpython_vm::PyObjectRef {
|
||||
::rustpython_vm::PyStructSequence::into_struct_sequence(self, vm).into_object()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use rustpython_vm as vm;
|
||||
|
||||
fn main() -> vm::pyobject::PyResult<()> {
|
||||
fn main() -> vm::PyResult<()> {
|
||||
vm::Interpreter::default().enter(run)
|
||||
}
|
||||
|
||||
fn run(vm: &vm::VirtualMachine) -> vm::pyobject::PyResult<()> {
|
||||
fn run(vm: &vm::VirtualMachine) -> vm::PyResult<()> {
|
||||
let scope = vm.new_scope_with_builtins();
|
||||
|
||||
// the file parameter is relevant to the directory where the crate's Cargo.toml is located, see $CARGO_MANIFEST_DIR:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use rustpython_vm as vm;
|
||||
|
||||
fn main() -> vm::pyobject::PyResult<()> {
|
||||
fn main() -> vm::PyResult<()> {
|
||||
vm::Interpreter::default().enter(|vm| {
|
||||
let scope = vm.new_scope_with_builtins();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use rustpython_vm as vm;
|
||||
// these are needed for special memory shenanigans to let us share a variable with Python and Rust
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
// this needs to be in scope in order to insert things into scope.globals
|
||||
use vm::pyobject::ItemProtocol;
|
||||
use vm::ItemProtocol;
|
||||
|
||||
// This has to be a macro because it uses the py_compile macro,
|
||||
// which compiles python source to optimized bytecode at compile time, so that
|
||||
@@ -30,11 +30,11 @@ fn on(b: bool) {
|
||||
ON.store(b, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
fn main() -> vm::pyobject::PyResult<()> {
|
||||
fn main() -> vm::PyResult<()> {
|
||||
vm::Interpreter::default().enter(run)
|
||||
}
|
||||
|
||||
fn run(vm: &vm::VirtualMachine) -> vm::pyobject::PyResult<()> {
|
||||
fn run(vm: &vm::VirtualMachine) -> vm::PyResult<()> {
|
||||
let mut input = String::with_capacity(50);
|
||||
let stdin = std::io::stdin();
|
||||
|
||||
|
||||
+3
-7
@@ -46,13 +46,9 @@ extern crate log;
|
||||
|
||||
use clap::{App, AppSettings, Arg, ArgMatches};
|
||||
use rustpython_vm::{
|
||||
builtins::PyInt,
|
||||
compile,
|
||||
exceptions::print_exception,
|
||||
match_class,
|
||||
pyobject::{BorrowValue, ItemProtocol, PyResult, TypeProtocol},
|
||||
scope::Scope,
|
||||
sysmodule, InitParameter, Interpreter, PySettings, VirtualMachine,
|
||||
builtins::PyInt, compile, exceptions::print_exception, match_class, scope::Scope, sysmodule,
|
||||
BorrowValue, InitParameter, Interpreter, ItemProtocol, PyResult, PySettings, TypeProtocol,
|
||||
VirtualMachine,
|
||||
};
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
+1
-2
@@ -5,9 +5,8 @@ use rustpython_vm::readline::{Readline, ReadlineResult};
|
||||
use rustpython_vm::{
|
||||
compile::{self, CompileError, CompileErrorType},
|
||||
exceptions::{print_exception, PyBaseExceptionRef},
|
||||
pyobject::{BorrowValue, PyResult, TypeProtocol},
|
||||
scope::Scope,
|
||||
VirtualMachine,
|
||||
BorrowValue, PyResult, TypeProtocol, VirtualMachine,
|
||||
};
|
||||
|
||||
enum ShellExecResult {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
use rustpython_vm::builtins::{PyDictRef, PyStrRef};
|
||||
use rustpython_vm::pyobject::{BorrowValue, PyIterable, PyResult, TryFromObject};
|
||||
use rustpython_vm::VirtualMachine;
|
||||
use rustpython_vm::{BorrowValue, PyIterable, PyResult, TryFromObject};
|
||||
|
||||
pub struct ShellHelper<'vm> {
|
||||
vm: &'vm VirtualMachine,
|
||||
|
||||
+1
-3
@@ -1,10 +1,8 @@
|
||||
use crate::builtins::int::PyIntRef;
|
||||
use crate::cformat::CFormatString;
|
||||
use crate::function::{single_or_tuple_any, OptionalOption};
|
||||
use crate::pyobject::{
|
||||
BorrowValue, PyIterator, PyObjectRef, PyResult, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, PyIterator, PyObjectRef, PyResult, TryFromObject, TypeProtocol};
|
||||
use num_traits::{cast::ToPrimitive, sign::Signed};
|
||||
use std::str::FromStr;
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ use crate::coroutine::{Coro, Variant};
|
||||
use crate::exceptions::PyBaseExceptionRef;
|
||||
use crate::frame::FrameRef;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{
|
||||
IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
|
||||
};
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
|
||||
};
|
||||
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ use crate::builtins::pystr::PyStrRef;
|
||||
use crate::builtins::pytype::PyTypeRef;
|
||||
use crate::common::borrow::BorrowValue;
|
||||
use crate::function::{FuncArgs, PyNativeFunc};
|
||||
use crate::pyobject::{
|
||||
PyClassImpl, PyContext, PyObject, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
|
||||
};
|
||||
use crate::slots::{Callable, SlotDescriptor};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
PyClassImpl, PyContext, PyObject, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
|
||||
};
|
||||
|
||||
pub struct PyNativeFuncDef {
|
||||
pub func: PyNativeFunc,
|
||||
|
||||
@@ -16,15 +16,15 @@ use crate::byteslike::PyBytesLike;
|
||||
use crate::common::borrow::{BorrowedValue, BorrowedValueMut};
|
||||
use crate::common::lock::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard};
|
||||
use crate::function::{OptionalArg, OptionalOption};
|
||||
use crate::pyobject::{
|
||||
BorrowValue, Either, IdProtocol, IntoPyObject, PyClassImpl, PyComparisonValue, PyContext,
|
||||
PyIterable, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
|
||||
};
|
||||
use crate::sliceable::{PySliceableSequence, PySliceableSequenceMut, SequenceIndex};
|
||||
use crate::slots::{
|
||||
BufferProtocol, Comparable, Hashable, Iterable, PyComparisonOp, PyIter, Unhashable,
|
||||
};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, Either, IdProtocol, IntoPyObject, PyClassImpl, PyComparisonValue, PyContext,
|
||||
PyIterable, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
|
||||
};
|
||||
use bstr::ByteSlice;
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use std::mem::size_of;
|
||||
|
||||
@@ -15,16 +15,16 @@ use crate::bytesinner::{
|
||||
};
|
||||
use crate::common::hash::PyHash;
|
||||
use crate::function::{OptionalArg, OptionalOption};
|
||||
use crate::pyobject::{
|
||||
BorrowValue, Either, IntoPyObject, PyClassImpl, PyComparisonValue, PyContext, PyIterable,
|
||||
PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::slots::{BufferProtocol, Comparable, Hashable, Iterable, PyComparisonOp, PyIter};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
anystr::{self, AnyStr},
|
||||
byteslike::PyBytesLike,
|
||||
};
|
||||
use crate::{
|
||||
BorrowValue, Either, IntoPyObject, PyClassImpl, PyComparisonValue, PyContext, PyIterable,
|
||||
PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
|
||||
use crate::builtins::memory::{Buffer, BufferOptions};
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::pyobject::{
|
||||
PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
|
||||
};
|
||||
use crate::slots::SlotDescriptor;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol};
|
||||
|
||||
/// classmethod(function) -> method
|
||||
///
|
||||
|
||||
@@ -7,11 +7,11 @@ use std::ops::Deref;
|
||||
|
||||
use super::{PyStrRef, PyTypeRef};
|
||||
use crate::bytecode::{self, BorrowedConstant, Constant, ConstantBag};
|
||||
use crate::pyobject::{
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
StaticType, TypeProtocol,
|
||||
};
|
||||
use crate::VirtualMachine;
|
||||
use num_traits::Zero;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -5,13 +5,13 @@ use super::float;
|
||||
use super::pystr::PyStr;
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::function::{OptionalArg, OptionalOption};
|
||||
use crate::pyobject::{
|
||||
use crate::slots::{Comparable, Hashable, PyComparisonOp};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, IntoPyObject, Never,
|
||||
PyArithmaticValue::{self, *},
|
||||
PyClassImpl, PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
|
||||
};
|
||||
use crate::slots::{Comparable, Hashable, PyComparisonOp};
|
||||
use crate::VirtualMachine;
|
||||
use rustpython_common::{float_ops, hash};
|
||||
|
||||
/// Create a complex number from a real part and an optional imaginary part.
|
||||
|
||||
@@ -4,9 +4,9 @@ use super::pytype::PyTypeRef;
|
||||
use crate::coroutine::{Coro, Variant};
|
||||
use crate::frame::FrameRef;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
|
||||
type PyCoroutineRef = PyRef<PyCoroutine>;
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ use crate::dictdatatype::{self, DictKey};
|
||||
use crate::exceptions::PyBaseExceptionRef;
|
||||
use crate::function::{FuncArgs, KwArgs, OptionalArg};
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{
|
||||
use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter, Unhashable};
|
||||
use crate::vm::{ReprGuard, VirtualMachine};
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, IntoPyObject, ItemProtocol, PyArithmaticValue::*, PyAttributes,
|
||||
PyClassImpl, PyComparisonValue, PyContext, PyIterable, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter, Unhashable};
|
||||
use crate::vm::{ReprGuard, VirtualMachine};
|
||||
|
||||
pub type DictContentType = dictdatatype::Dict;
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ use super::int::PyIntRef;
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{
|
||||
BorrowValue, IntoPyObject, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
};
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IntoPyObject, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
};
|
||||
|
||||
#[pyclass(module = false, name = "enumerate")]
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use super::pybool;
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
|
||||
/// filter(function or None, iterable) --> filter object
|
||||
///
|
||||
|
||||
@@ -9,14 +9,14 @@ use super::pystr::{PyStr, PyStrRef};
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::format::FormatSpec;
|
||||
use crate::function::{OptionalArg, OptionalOption};
|
||||
use crate::pyobject::{
|
||||
use crate::slots::{Comparable, Hashable, PyComparisonOp};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, IntoPyObject,
|
||||
PyArithmaticValue::{self, *},
|
||||
PyClassImpl, PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::slots::{Comparable, Hashable, PyComparisonOp};
|
||||
use crate::VirtualMachine;
|
||||
use rustpython_common::{float_ops, hash};
|
||||
|
||||
/// Convert a string or number to a floating point number, if possible.
|
||||
|
||||
@@ -6,8 +6,8 @@ use super::code::PyCodeRef;
|
||||
use super::dict::PyDictRef;
|
||||
use super::pystr::PyStrRef;
|
||||
use crate::frame::{Frame, FrameRef};
|
||||
use crate::pyobject::{IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult};
|
||||
|
||||
pub fn init(context: &PyContext) {
|
||||
FrameRef::extend_class(context, &context.types.frame_type);
|
||||
|
||||
@@ -13,15 +13,15 @@ use crate::bytecode;
|
||||
use crate::common::lock::PyMutex;
|
||||
use crate::frame::Frame;
|
||||
use crate::function::{FuncArgs, OptionalArg};
|
||||
use crate::scope::Scope;
|
||||
use crate::slots::{Callable, Comparable, PyComparisonOp, SlotDescriptor, SlotGetattro};
|
||||
#[cfg(feature = "jit")]
|
||||
use crate::pyobject::IntoPyObject;
|
||||
use crate::pyobject::{
|
||||
use crate::IntoPyObject;
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, ItemProtocol, PyClassImpl, PyComparisonValue, PyContext, PyObjectRef,
|
||||
PyRef, PyResult, PyValue, TypeProtocol,
|
||||
};
|
||||
use crate::scope::Scope;
|
||||
use crate::slots::{Callable, Comparable, PyComparisonOp, SlotDescriptor, SlotGetattro};
|
||||
use crate::VirtualMachine;
|
||||
use itertools::Itertools;
|
||||
#[cfg(feature = "jit")]
|
||||
use rustpython_common::lock::OnceCell;
|
||||
|
||||
@@ -4,11 +4,11 @@ use crate::builtins::{float, int, pybool, PyStrRef};
|
||||
use crate::bytecode::CodeFlags;
|
||||
use crate::exceptions::PyBaseExceptionRef;
|
||||
use crate::function::FuncArgs;
|
||||
use crate::pyobject::{
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, IntoPyObject, ItemProtocol, PyObjectRef, PyResult, TryFromObject,
|
||||
TypeProtocol,
|
||||
};
|
||||
use crate::VirtualMachine;
|
||||
use num_traits::ToPrimitive;
|
||||
use rustpython_jit::{AbiValue, Args, CompiledCode, JitArgumentError, JitType};
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ use super::pytype::PyTypeRef;
|
||||
use crate::coroutine::{Coro, Variant};
|
||||
use crate::frame::FrameRef;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
|
||||
#[pyclass(module = false, name = "generator")]
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
*/
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::function::{OwnedParam, RefParam};
|
||||
use crate::pyobject::{
|
||||
use crate::slots::SlotDescriptor;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
IntoPyResult, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyThreadingConstraint,
|
||||
PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::slots::SlotDescriptor;
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
pub type PyGetterFunc = Box<py_dyn_fn!(dyn Fn(&VirtualMachine, PyObjectRef) -> PyResult)>;
|
||||
pub type PySetterFunc =
|
||||
|
||||
@@ -15,14 +15,14 @@ use super::pystr::{PyStr, PyStrRef};
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::format::FormatSpec;
|
||||
use crate::function::{OptionalArg, OptionalOption};
|
||||
use crate::pyobject::{
|
||||
use crate::slots::{Comparable, Hashable, PyComparisonOp};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{bytesinner::PyBytesInner, byteslike::try_bytes_like};
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, IntoPyObject, IntoPyResult, PyArithmaticValue, PyClassImpl,
|
||||
PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
|
||||
TypeProtocol,
|
||||
};
|
||||
use crate::slots::{Comparable, Hashable, PyComparisonOp};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{bytesinner::PyBytesInner, byteslike::try_bytes_like};
|
||||
use rustpython_common::hash;
|
||||
|
||||
/// int(x=0) -> integer
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::pyobject::{
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
ItemProtocol, PyCallable, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
TypeProtocol,
|
||||
};
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
#[pyclass(module = false, name = "iter")]
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -9,14 +9,14 @@ use super::pytype::PyTypeRef;
|
||||
use super::slice::PySliceRef;
|
||||
use crate::common::lock::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard};
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{
|
||||
BorrowValue, Either, PyClassImpl, PyComparisonValue, PyContext, PyIterable, PyObjectRef, PyRef,
|
||||
PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::sequence::{self, SimpleSeq};
|
||||
use crate::sliceable::{PySliceableSequence, PySliceableSequenceMut, SequenceIndex};
|
||||
use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter, Unhashable};
|
||||
use crate::vm::{ReprGuard, VirtualMachine};
|
||||
use crate::{
|
||||
BorrowValue, Either, PyClassImpl, PyComparisonValue, PyContext, PyIterable, PyObjectRef, PyRef,
|
||||
PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
|
||||
/// Built-in mutable sequence.
|
||||
///
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Builtin function definitions.
|
||||
//!
|
||||
//! Implements functions listed here: https://docs.python.org/3/library/builtins.html
|
||||
use crate::pyobject::PyObjectRef;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::PyObjectRef;
|
||||
|
||||
/// Built-in functions, exceptions, and other objects.
|
||||
///
|
||||
@@ -28,15 +28,15 @@ mod decl {
|
||||
single_or_tuple_any, Args, FuncArgs, KwArgs, OptionalArg, OptionalOption,
|
||||
};
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{
|
||||
BorrowValue, Either, IdProtocol, ItemProtocol, PyArithmaticValue, PyCallable, PyClassImpl,
|
||||
PyIterable, PyObjectRef, PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::readline::{Readline, ReadlineResult};
|
||||
use crate::scope::Scope;
|
||||
use crate::slots::PyComparisonOp;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{py_io, sysmodule};
|
||||
use crate::{
|
||||
BorrowValue, Either, IdProtocol, ItemProtocol, PyArithmaticValue, PyCallable, PyClassImpl,
|
||||
PyIterable, PyObjectRef, PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use num_traits::{Signed, Zero};
|
||||
|
||||
#[pyfunction]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::function::Args;
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
|
||||
/// map(func, *iterables) --> map object
|
||||
///
|
||||
|
||||
@@ -3,12 +3,12 @@ use super::pystr::PyStrRef;
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{
|
||||
use crate::slots::Iterable;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IntoPyObject, ItemProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult,
|
||||
PyValue, TryFromObject,
|
||||
};
|
||||
use crate::slots::Iterable;
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
#[pyclass(module = false, name = "mappingproxy")]
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -11,14 +11,14 @@ use crate::common::hash::PyHash;
|
||||
use crate::common::lock::OnceCell;
|
||||
use crate::common::rc::PyRc;
|
||||
use crate::function::{FuncArgs, OptionalArg};
|
||||
use crate::pyobject::{
|
||||
Either, IdProtocol, IntoPyObject, PyClassImpl, PyComparisonValue, PyContext, PyObjectRef,
|
||||
PyRef, PyResult, PyThreadingConstraint, PyValue, TypeProtocol,
|
||||
};
|
||||
use crate::sliceable::{convert_slice, saturate_range, wrap_index, SequenceIndex};
|
||||
use crate::slots::{BufferProtocol, Comparable, Hashable, PyComparisonOp};
|
||||
use crate::stdlib::pystruct::_struct::FormatSpec;
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
Either, IdProtocol, IntoPyObject, PyClassImpl, PyComparisonValue, PyContext, PyObjectRef,
|
||||
PyRef, PyResult, PyThreadingConstraint, PyValue, TypeProtocol,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use itertools::Itertools;
|
||||
use num_bigint::BigInt;
|
||||
|
||||
@@ -2,12 +2,12 @@ use super::dict::PyDictRef;
|
||||
use super::pystr::{PyStr, PyStrRef};
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::function::FuncArgs;
|
||||
use crate::pyobject::{
|
||||
use crate::slots::SlotGetattro;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IntoPyObject, ItemProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult,
|
||||
PyValue,
|
||||
};
|
||||
use crate::slots::SlotGetattro;
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
#[pyclass(module = false, name = "module")]
|
||||
#[derive(Debug)]
|
||||
@@ -60,7 +60,7 @@ impl PyModule {
|
||||
|
||||
#[pymethod(magic)]
|
||||
fn init(zelf: PyRef<Self>, args: ModuleInitArgs, vm: &VirtualMachine) {
|
||||
debug_assert!(crate::pyobject::TypeProtocol::class(zelf.as_object())
|
||||
debug_assert!(crate::TypeProtocol::class(zelf.as_object())
|
||||
.slots
|
||||
.flags
|
||||
.has_feature(crate::slots::PyTpFlags::HAS_DICT));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::function::KwArgs;
|
||||
use crate::pyobject::{PyClassImpl, PyContext, PyRef, PyResult, PyValue};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyClassImpl, PyContext, PyRef, PyResult, PyValue};
|
||||
|
||||
/// A simple attribute-based namespace.
|
||||
///
|
||||
|
||||
@@ -6,13 +6,13 @@ use super::pytype::PyTypeRef;
|
||||
use crate::builtins::pytype::PyType;
|
||||
use crate::common::hash::PyHash;
|
||||
use crate::function::FuncArgs;
|
||||
use crate::pyobject::{
|
||||
use crate::slots::PyComparisonOp;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, Either, IdProtocol, ItemProtocol, PyArithmaticValue, PyAttributes, PyClassImpl,
|
||||
PyComparisonValue, PyContext, PyObject, PyObjectRef, PyResult, PyValue, TryFromObject,
|
||||
TypeProtocol,
|
||||
};
|
||||
use crate::slots::PyComparisonOp;
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
/// The most base type
|
||||
#[pyclass(module = false, name = "object")]
|
||||
|
||||
@@ -5,11 +5,11 @@ use crate::common::lock::PyRwLock;
|
||||
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::function::FuncArgs;
|
||||
use crate::pyobject::{
|
||||
PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::slots::SlotDescriptor;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
|
||||
/// Property attribute.
|
||||
///
|
||||
|
||||
@@ -4,11 +4,11 @@ use num_traits::Zero;
|
||||
use super::int::PyInt;
|
||||
use super::pystr::PyStrRef;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, IntoPyObject, PyClassImpl, PyContext, PyObjectRef, PyResult,
|
||||
TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
impl IntoPyObject for bool {
|
||||
fn into_pyobject(self, vm: &VirtualMachine) -> PyObjectRef {
|
||||
|
||||
@@ -20,14 +20,14 @@ use crate::anystr::{self, adjust_indices, AnyStr, AnyStrContainer, AnyStrWrapper
|
||||
use crate::exceptions::IntoPyException;
|
||||
use crate::format::{FormatSpec, FormatString, FromTemplate};
|
||||
use crate::function::{FuncArgs, OptionalArg, OptionalOption};
|
||||
use crate::pyobject::{
|
||||
use crate::sliceable::PySliceableSequence;
|
||||
use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, Either, IdProtocol, IntoPyObject, ItemProtocol, PyClassImpl, PyComparisonValue,
|
||||
PyContext, PyIterable, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TryIntoRef,
|
||||
TypeProtocol,
|
||||
};
|
||||
use crate::sliceable::PySliceableSequence;
|
||||
use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter};
|
||||
use crate::VirtualMachine;
|
||||
use rustpython_common::hash;
|
||||
|
||||
/// str(object='') -> str
|
||||
|
||||
@@ -9,12 +9,12 @@ https://github.com/python/cpython/blob/50b48572d9a90c5bb36e2bef6179548ea927a35a/
|
||||
use super::pystr::PyStrRef;
|
||||
use super::pytype::{PyType, PyTypeRef};
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{
|
||||
use crate::slots::{SlotDescriptor, SlotGetattro};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
TypeProtocol,
|
||||
};
|
||||
use crate::slots::{SlotDescriptor, SlotGetattro};
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
#[pyclass(module = false, name = "super")]
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -17,12 +17,12 @@ use super::tuple::PyTuple;
|
||||
use super::weakref::PyWeak;
|
||||
use crate::builtins::tuple::PyTupleTyped;
|
||||
use crate::function::{FuncArgs, KwArgs};
|
||||
use crate::pyobject::{
|
||||
use crate::slots::{self, Callable, PyTpFlags, PyTypeSlots, SlotGetattro, SlotSetattro};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, Either, IdProtocol, PyAttributes, PyClassImpl, PyContext, PyLease, PyObjectRef,
|
||||
PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::slots::{self, Callable, PyTpFlags, PyTypeSlots, SlotGetattro, SlotSetattro};
|
||||
use crate::vm::VirtualMachine;
|
||||
use itertools::Itertools;
|
||||
use std::ops::Deref;
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ use super::pytype::PyTypeRef;
|
||||
use super::slice::{PySlice, PySliceRef};
|
||||
use crate::common::hash::PyHash;
|
||||
use crate::function::{FuncArgs, OptionalArg};
|
||||
use crate::pyobject::{
|
||||
self, BorrowValue, IdProtocol, IntoPyRef, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult,
|
||||
PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, IntoPyRef, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult,
|
||||
PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
|
||||
/// range(stop) -> range object
|
||||
/// range(start, stop[, step]) -> range object
|
||||
@@ -341,7 +341,7 @@ impl Hashable for PyRange {
|
||||
zelf.step().into_object(),
|
||||
]
|
||||
};
|
||||
pyobject::hash_iter(elements.iter(), vm)
|
||||
crate::hash_iter(elements.iter(), vm)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ impl Comparable for PyRange {
|
||||
other: &PyObjectRef,
|
||||
op: PyComparisonOp,
|
||||
_vm: &VirtualMachine,
|
||||
) -> PyResult<pyobject::PyComparisonValue> {
|
||||
) -> PyResult<crate::PyComparisonValue> {
|
||||
op.eq_only(|| {
|
||||
if zelf.is(other) {
|
||||
return Ok(true.into());
|
||||
|
||||
@@ -7,12 +7,12 @@ use crate::common::rc::PyRc;
|
||||
use crate::dictdatatype;
|
||||
use crate::function::OptionalArg::{Missing, Present};
|
||||
use crate::function::{Args, OptionalArg};
|
||||
use crate::pyobject::{
|
||||
self, BorrowValue, IdProtocol, PyClassImpl, PyComparisonValue, PyContext, PyIterable,
|
||||
PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter, Unhashable};
|
||||
use crate::vm::{ReprGuard, VirtualMachine};
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, PyClassImpl, PyComparisonValue, PyContext, PyIterable, PyObjectRef,
|
||||
PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use std::fmt;
|
||||
|
||||
@@ -291,7 +291,7 @@ impl PySetInner {
|
||||
}
|
||||
|
||||
fn hash(&self, vm: &VirtualMachine) -> PyResult<PyHash> {
|
||||
pyobject::hash_iter_unordered(self.content.keys().iter(), vm)
|
||||
crate::hash_iter_unordered(self.content.keys().iter(), vm)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::pyobject::{
|
||||
IntoPyObject, PyClassImpl, PyContext, PyObjectRef, PyRef, PyValue, TypeProtocol,
|
||||
};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{IntoPyObject, PyClassImpl, PyContext, PyObjectRef, PyRef, PyValue, TypeProtocol};
|
||||
|
||||
#[pyclass(module = false, name = "NoneType")]
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
use super::int::{PyInt, PyIntRef};
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::function::{FuncArgs, OptionalArg};
|
||||
use crate::pyobject::{
|
||||
use crate::slots::{Comparable, Hashable, PyComparisonOp, Unhashable};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IntoPyObject, PyClassImpl, PyComparisonValue, PyContext, PyObjectRef, PyRef,
|
||||
PyResult, PyValue, TryIntoRef, TypeProtocol,
|
||||
};
|
||||
use crate::slots::{Comparable, Hashable, PyComparisonOp, Unhashable};
|
||||
use crate::VirtualMachine;
|
||||
use num_bigint::{BigInt, ToBigInt};
|
||||
use num_traits::{One, Signed, Zero};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::pyobject::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
use crate::slots::SlotDescriptor;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
|
||||
#[pyclass(module = false, name = "staticmethod")]
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::builtins::pytype::PyTypeRef;
|
||||
use crate::frame::FrameRef;
|
||||
use crate::pyobject::{BorrowValue, PyClassImpl, PyContext, PyRef, PyValue};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, PyClassImpl, PyContext, PyRef, PyValue};
|
||||
|
||||
#[pyclass(module = false, name = "traceback")]
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -5,15 +5,15 @@ use std::marker::PhantomData;
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::common::hash::PyHash;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{
|
||||
self, BorrowValue, Either, IdProtocol, IntoPyObject, PyArithmaticValue, PyClassImpl,
|
||||
PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TransmuteFromObject,
|
||||
TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::sequence::{self, SimpleSeq};
|
||||
use crate::sliceable::PySliceableSequence;
|
||||
use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter};
|
||||
use crate::vm::{ReprGuard, VirtualMachine};
|
||||
use crate::{
|
||||
BorrowValue, Either, IdProtocol, IntoPyObject, PyArithmaticValue, PyClassImpl,
|
||||
PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TransmuteFromObject,
|
||||
TryFromObject, TypeProtocol,
|
||||
};
|
||||
|
||||
/// tuple() -> empty tuple
|
||||
/// tuple(iterable) -> tuple initialized from iterable's items
|
||||
@@ -266,7 +266,7 @@ impl PyTuple {
|
||||
|
||||
impl Hashable for PyTuple {
|
||||
fn hash(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyHash> {
|
||||
pyobject::hash_iter(zelf.elements.iter(), vm)
|
||||
crate::hash_iter(zelf.elements.iter(), vm)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ use super::pytype::PyTypeRef;
|
||||
use super::weakref::PyWeak;
|
||||
use super::PyStrRef;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
use crate::slots::SlotSetattro;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
|
||||
#[pyclass(module = false, name = "weakproxy")]
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::common::hash::PyHash;
|
||||
use crate::function::{FuncArgs, OptionalArg};
|
||||
use crate::pyobject::{
|
||||
use crate::slots::{Callable, Comparable, Hashable, PyComparisonOp};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyObjectWeak, PyRef, PyResult, PyValue,
|
||||
TypeProtocol,
|
||||
};
|
||||
use crate::slots::{Callable, Comparable, Hashable, PyComparisonOp};
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
|
||||
@@ -94,7 +94,7 @@ impl Comparable for PyWeak {
|
||||
other: &PyObjectRef,
|
||||
op: PyComparisonOp,
|
||||
vm: &VirtualMachine,
|
||||
) -> PyResult<crate::pyobject::PyComparisonValue> {
|
||||
) -> PyResult<crate::PyComparisonValue> {
|
||||
op.eq_only(|| {
|
||||
let other = class_or_notimplemented!(Self, other);
|
||||
let both = zelf.upgrade().and_then(|s| other.upgrade().map(|o| (s, o)));
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use super::pytype::PyTypeRef;
|
||||
use crate::function::Args;
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue};
|
||||
|
||||
pub type PyZipRef = PyRef<PyZip>;
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ use crate::builtins::PyTypeRef;
|
||||
use crate::byteslike::try_bytes_like;
|
||||
use crate::cformat::CFormatBytes;
|
||||
use crate::function::{OptionalArg, OptionalOption};
|
||||
use crate::pyobject::{
|
||||
BorrowValue, Either, IdProtocol, PyComparisonValue, PyIterable, PyObjectRef, PyResult, PyValue,
|
||||
TryFromObject,
|
||||
};
|
||||
use crate::sliceable::PySliceableSequence;
|
||||
use crate::slots::PyComparisonOp;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, Either, IdProtocol, PyComparisonValue, PyIterable, PyObjectRef, PyResult, PyValue,
|
||||
TryFromObject,
|
||||
};
|
||||
use rustpython_common::hash;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
use crate::builtins::memory::{try_buffer_from_object, BufferRef};
|
||||
use crate::builtins::PyStrRef;
|
||||
use crate::common::borrow::{BorrowedValue, BorrowedValueMut};
|
||||
use crate::pyobject::{BorrowValue, PyObjectRef, PyResult, TryFromObject};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, PyObjectRef, PyResult, TryFromObject};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PyBytesLike(BufferRef);
|
||||
|
||||
+1
-3
@@ -5,10 +5,8 @@ use crate::builtins::int::{self, PyInt};
|
||||
use crate::builtins::pystr::PyStr;
|
||||
use crate::builtins::{memory::try_buffer_from_object, tuple, PyBytes};
|
||||
use crate::common::float_ops;
|
||||
use crate::pyobject::{
|
||||
BorrowValue, ItemProtocol, PyObjectRef, PyResult, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, ItemProtocol, PyObjectRef, PyResult, TryFromObject, TypeProtocol};
|
||||
use itertools::Itertools;
|
||||
use num_bigint::{BigInt, Sign};
|
||||
use num_traits::cast::ToPrimitive;
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
use crate::builtins::{PyStrRef, PyTypeRef};
|
||||
use crate::exceptions::{self, PyBaseExceptionRef};
|
||||
use crate::frame::{ExecutionResult, FrameRef};
|
||||
use crate::pyobject::{PyObjectRef, PyResult, TypeProtocol};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{PyObjectRef, PyResult, TypeProtocol};
|
||||
|
||||
use crate::common::lock::PyMutex;
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
|
||||
@@ -4,10 +4,10 @@ use crate::builtins::{PyStr, PyStrRef};
|
||||
/// And: https://www.youtube.com/watch?v=p33CVV29OG8
|
||||
/// And: http://code.activestate.com/recipes/578375/
|
||||
use crate::common::lock::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard};
|
||||
use crate::pyobject::{
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, IntoPyObject, PyObjectRef, PyRefExact, PyResult, TypeProtocol,
|
||||
};
|
||||
use crate::vm::VirtualMachine;
|
||||
use rustpython_common::hash;
|
||||
use std::fmt;
|
||||
use std::mem::size_of;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
use crate::compile;
|
||||
use crate::pyobject::PyResult;
|
||||
use crate::scope::Scope;
|
||||
use crate::PyResult;
|
||||
use crate::VirtualMachine;
|
||||
|
||||
pub fn eval(vm: &VirtualMachine, source: &str, scope: Scope, source_path: &str) -> PyResult {
|
||||
|
||||
@@ -6,14 +6,14 @@ use crate::builtins::tuple::{PyTuple, PyTupleRef};
|
||||
use crate::common::lock::PyRwLock;
|
||||
use crate::function::FuncArgs;
|
||||
use crate::py_io::{self, Write};
|
||||
use crate::pyobject::StaticType;
|
||||
use crate::pyobject::{
|
||||
use crate::sysmodule;
|
||||
use crate::types::create_type_with_slots;
|
||||
use crate::StaticType;
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IntoPyObject, PyClassImpl, PyContext, PyIterable, PyObjectRef, PyRef, PyResult,
|
||||
PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::sysmodule;
|
||||
use crate::types::create_type_with_slots;
|
||||
use crate::VirtualMachine;
|
||||
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use itertools::Itertools;
|
||||
|
||||
+1
-1
@@ -2,8 +2,8 @@ use crate::builtins::{self, pystr};
|
||||
use crate::common::float_ops;
|
||||
use crate::exceptions::{IntoPyException, PyBaseExceptionRef};
|
||||
use crate::function::FuncArgs;
|
||||
use crate::pyobject::{ItemProtocol, PyObjectRef, PyResult, TypeProtocol};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{ItemProtocol, PyObjectRef, PyResult, TypeProtocol};
|
||||
use itertools::{Itertools, PeekingNext};
|
||||
use num_bigint::{BigInt, Sign};
|
||||
use num_traits::cast::ToPrimitive;
|
||||
|
||||
+5
-5
@@ -25,13 +25,13 @@ use crate::coroutine::Coro;
|
||||
use crate::exceptions::{self, ExceptionCtor, PyBaseExceptionRef};
|
||||
use crate::function::FuncArgs;
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{
|
||||
BorrowValue, IdProtocol, ItemProtocol, PyMethod, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::scope::Scope;
|
||||
use crate::slots::PyComparisonOp;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, ItemProtocol, PyMethod, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
TryFromObject, TypeProtocol,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct Block {
|
||||
@@ -434,7 +434,7 @@ impl ExecutingFrame<'_> {
|
||||
exc_tb: PyObjectRef,
|
||||
) -> PyResult<ExecutionResult> {
|
||||
if let Some(coro) = self.yield_from_target() {
|
||||
use crate::pyobject::Either;
|
||||
use crate::Either;
|
||||
// borrow checker shenanigans - we only need to use exc_type/val/tb if the following
|
||||
// variable is Some
|
||||
let thrower = if let Some(coro) = self.builtin_coro(coro) {
|
||||
|
||||
+2
-2
@@ -2,11 +2,11 @@ use self::OptionalArg::*;
|
||||
use crate::builtins::pytype::PyTypeRef;
|
||||
use crate::builtins::tuple::PyTupleRef;
|
||||
use crate::exceptions::PyBaseExceptionRef;
|
||||
use crate::pyobject::{
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IntoPyObject, IntoPyResult, PyObjectRef, PyRef, PyResult, PyThreadingConstraint,
|
||||
PyValue, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::vm::VirtualMachine;
|
||||
use indexmap::IndexMap;
|
||||
use itertools::Itertools;
|
||||
use result_like::impl_option_like;
|
||||
|
||||
+1
-1
@@ -9,10 +9,10 @@ use crate::builtins::{code, list};
|
||||
#[cfg(feature = "rustpython-compiler")]
|
||||
use crate::compile;
|
||||
use crate::exceptions::PyBaseExceptionRef;
|
||||
use crate::pyobject::{BorrowValue, ItemProtocol, PyResult, PyValue, TryFromObject, TypeProtocol};
|
||||
use crate::scope::Scope;
|
||||
use crate::version::get_git_revision;
|
||||
use crate::vm::{InitParameter, VirtualMachine};
|
||||
use crate::{BorrowValue, ItemProtocol, PyResult, PyValue, TryFromObject, TypeProtocol};
|
||||
|
||||
pub(crate) fn init_importlib(
|
||||
vm: &mut VirtualMachine,
|
||||
|
||||
+1
-1
@@ -5,8 +5,8 @@
|
||||
use crate::builtins::int::{self, PyInt};
|
||||
use crate::builtins::iter::PySequenceIterator;
|
||||
use crate::exceptions::PyBaseExceptionRef;
|
||||
use crate::pyobject::{BorrowValue, PyObjectRef, PyResult, PyValue, TryFromObject, TypeProtocol};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, PyObjectRef, PyResult, PyValue, TryFromObject, TypeProtocol};
|
||||
use num_traits::Signed;
|
||||
|
||||
/*
|
||||
|
||||
+3
-2
@@ -67,7 +67,7 @@ pub mod import;
|
||||
pub mod iterator;
|
||||
pub mod py_io;
|
||||
pub mod py_serde;
|
||||
pub mod pyobject;
|
||||
mod pyobject;
|
||||
mod pyobjectrc;
|
||||
pub mod readline;
|
||||
pub mod scope;
|
||||
@@ -80,7 +80,8 @@ pub mod types;
|
||||
mod version;
|
||||
mod vm;
|
||||
|
||||
// pub use self::pyobject::Executor;
|
||||
// pub use self::Executor;
|
||||
pub use self::pyobject::*;
|
||||
pub use self::vm::{InitParameter, Interpreter, PySettings, VirtualMachine};
|
||||
pub use rustpython_bytecode as bytecode;
|
||||
pub use rustpython_common as common;
|
||||
|
||||
+6
-6
@@ -11,7 +11,7 @@ macro_rules! py_module {
|
||||
macro_rules! extend_module {
|
||||
( $vm:expr, $module:expr, { $($name:expr => $value:expr),* $(,)? }) => {{
|
||||
#[allow(unused_variables)]
|
||||
let module: &$crate::pyobject::PyObjectRef = &$module;
|
||||
let module: &$crate::PyObjectRef = &$module;
|
||||
$(
|
||||
$vm.__module_set_attr(&module, $name, $value).unwrap();
|
||||
)*
|
||||
@@ -86,7 +86,7 @@ macro_rules! py_namespace {
|
||||
/// use rustpython_vm::match_class;
|
||||
/// use rustpython_vm::builtins::PyFloat;
|
||||
/// use rustpython_vm::builtins::PyInt;
|
||||
/// use rustpython_vm::pyobject::PyValue;
|
||||
/// use rustpython_vm::PyValue;
|
||||
///
|
||||
/// # rustpython_vm::Interpreter::default().enter(|vm| {
|
||||
/// let obj = PyInt::from(0).into_ref(&vm).into_object();
|
||||
@@ -111,7 +111,7 @@ macro_rules! py_namespace {
|
||||
/// use rustpython_vm::match_class;
|
||||
/// use rustpython_vm::builtins::PyFloat;
|
||||
/// use rustpython_vm::builtins::PyInt;
|
||||
/// use rustpython_vm::pyobject::{PyValue, BorrowValue};
|
||||
/// use rustpython_vm::{PyValue, BorrowValue};
|
||||
///
|
||||
/// # rustpython_vm::Interpreter::default().enter(|vm| {
|
||||
/// let obj = PyInt::from(0).into_ref(&vm).into_object();
|
||||
@@ -215,9 +215,9 @@ macro_rules! flame_guard {
|
||||
#[macro_export]
|
||||
macro_rules! class_or_notimplemented {
|
||||
($t:ty, $obj:expr) => {
|
||||
match $crate::pyobject::PyObjectRef::downcast_ref::<$t>($obj) {
|
||||
match $crate::PyObjectRef::downcast_ref::<$t>($obj) {
|
||||
Some(pyref) => pyref,
|
||||
None => return Ok($crate::pyobject::PyArithmaticValue::NotImplemented),
|
||||
None => return Ok($crate::PyArithmaticValue::NotImplemented),
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -226,7 +226,7 @@ macro_rules! class_or_notimplemented {
|
||||
macro_rules! named_function {
|
||||
($ctx:expr, $module:ident, $func:ident) => {{
|
||||
#[allow(unused_variables)] // weird lint, something to do with paste probably
|
||||
let ctx: &$crate::pyobject::PyContext = &$ctx;
|
||||
let ctx: &$crate::PyContext = &$ctx;
|
||||
$crate::__exports::paste::expr! {
|
||||
ctx.make_funcdef(
|
||||
stringify!($module),
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
use crate::builtins::bytes::PyBytes;
|
||||
use crate::builtins::pystr::PyStr;
|
||||
use crate::exceptions::PyBaseExceptionRef;
|
||||
use crate::pyobject::{BorrowValue, PyObjectRef, PyResult};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{BorrowValue, PyObjectRef, PyResult};
|
||||
use std::{fmt, io, ops};
|
||||
|
||||
pub trait Write {
|
||||
|
||||
+1
-1
@@ -4,8 +4,8 @@ use serde::de::{DeserializeSeed, Visitor};
|
||||
use serde::ser::{Serialize, SerializeMap, SerializeSeq};
|
||||
|
||||
use crate::builtins::{dict::PyDictRef, float, int, list::PyList, pybool, pystr, tuple::PyTuple};
|
||||
use crate::pyobject::{BorrowValue, ItemProtocol, PyObjectRef, TypeProtocol};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{BorrowValue, ItemProtocol, PyObjectRef, TypeProtocol};
|
||||
|
||||
#[inline]
|
||||
pub fn serialize<S>(
|
||||
|
||||
+1
-1
@@ -1000,7 +1000,7 @@ impl<A: IntoPyObject, B: IntoPyObject> IntoPyObject for Either<A, B> {
|
||||
/// ```
|
||||
/// use rustpython_vm::VirtualMachine;
|
||||
/// use rustpython_vm::builtins::{PyStrRef, PyIntRef};
|
||||
/// use rustpython_vm::pyobject::Either;
|
||||
/// use rustpython_vm::Either;
|
||||
///
|
||||
/// fn do_something(arg: Either<PyIntRef, PyStrRef>, vm: &VirtualMachine) {
|
||||
/// match arg {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::builtins::{PyDictRef, PyTypeRef};
|
||||
use crate::common::lock::PyRwLock;
|
||||
use crate::common::rc::{PyRc, PyWeak};
|
||||
use crate::pyobject::{self, IdProtocol, PyObjectPayload, TypeProtocol};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{IdProtocol, PyObjectPayload, TypeProtocol};
|
||||
use std::any::TypeId;
|
||||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
@@ -226,7 +226,7 @@ impl PyObjectRef {
|
||||
///
|
||||
/// If the downcast fails, the original ref is returned in as `Err` so
|
||||
/// another downcast can be attempted without unnecessary cloning.
|
||||
pub fn downcast_exact<T: PyObjectPayload + pyobject::PyValue>(
|
||||
pub fn downcast_exact<T: PyObjectPayload + crate::PyValue>(
|
||||
self,
|
||||
vm: &VirtualMachine,
|
||||
) -> Result<PyRef<T>, Self> {
|
||||
@@ -244,7 +244,7 @@ impl PyObjectRef {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn payload_if_exact<T: PyObjectPayload + pyobject::PyValue>(
|
||||
pub fn payload_if_exact<T: PyObjectPayload + crate::PyValue>(
|
||||
&self,
|
||||
vm: &VirtualMachine,
|
||||
) -> Option<&T> {
|
||||
@@ -271,10 +271,7 @@ impl PyObjectRef {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn payload_if_subclass<T: pyobject::PyValue>(
|
||||
&self,
|
||||
vm: &crate::VirtualMachine,
|
||||
) -> Option<&T> {
|
||||
pub fn payload_if_subclass<T: crate::PyValue>(&self, vm: &crate::VirtualMachine) -> Option<&T> {
|
||||
if self.class().issubclass(T::class(vm)) {
|
||||
self.payload()
|
||||
} else {
|
||||
@@ -297,7 +294,7 @@ impl PyObjectWeak {
|
||||
|
||||
impl Drop for PyObjectRef {
|
||||
fn drop(&mut self) {
|
||||
use crate::pyobject::BorrowValue;
|
||||
use crate::BorrowValue;
|
||||
|
||||
// PyObjectRef will drop the value when its count goes to 0
|
||||
if PyRc::strong_count(&self.rc) != 1 {
|
||||
@@ -475,7 +472,7 @@ macro_rules! partially_init {
|
||||
|
||||
pub(crate) fn init_type_hierarchy() -> (PyTypeRef, PyTypeRef) {
|
||||
use crate::builtins::{object, PyType, PyWeak};
|
||||
use crate::pyobject::{PyAttributes, PyClassDef, PyClassImpl};
|
||||
use crate::{PyAttributes, PyClassDef, PyClassImpl};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ptr;
|
||||
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::builtins::{PyDictRef, PyStr, PyStrRef};
|
||||
use crate::pyobject::{IntoPyObject, ItemProtocol, TryIntoRef};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{IntoPyObject, ItemProtocol, TryIntoRef};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Scope {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
use crate::pyobject::{PyObjectRef, PyResult};
|
||||
use crate::slots::PyComparisonOp;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyObjectRef, PyResult};
|
||||
use num_traits::cast::ToPrimitive;
|
||||
|
||||
pub(super) type DynPyIter<'a> = Box<dyn ExactSizeIterator<Item = &'a PyObjectRef> + 'a>;
|
||||
|
||||
+1
-1
@@ -4,8 +4,8 @@ use std::ops::Range;
|
||||
|
||||
use crate::builtins::int::PyInt;
|
||||
use crate::builtins::slice::{PySlice, PySliceRef};
|
||||
use crate::pyobject::{BorrowValue, Either, PyObjectRef, PyResult, TryFromObject, TypeProtocol};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, Either, PyObjectRef, PyResult, TryFromObject, TypeProtocol};
|
||||
|
||||
pub trait PySliceableSequenceMut {
|
||||
type Item: Clone;
|
||||
|
||||
+2
-2
@@ -5,10 +5,10 @@ use crate::builtins::pystr::PyStrRef;
|
||||
use crate::common::hash::PyHash;
|
||||
use crate::common::lock::PyRwLock;
|
||||
use crate::function::{FuncArgs, OptionalArg, PyNativeFunc};
|
||||
use crate::pyobject::{
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
Either, IdProtocol, PyComparisonValue, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
|
||||
};
|
||||
use crate::VirtualMachine;
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
|
||||
bitflags! {
|
||||
|
||||
@@ -12,13 +12,13 @@ use crate::common::lock::{
|
||||
PyRwLockWriteGuard,
|
||||
};
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{
|
||||
BorrowValue, Either, IdProtocol, IntoPyObject, PyClassImpl, PyComparisonValue, PyIterable,
|
||||
PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::sliceable::{saturate_index, PySliceableSequence, PySliceableSequenceMut};
|
||||
use crate::slots::{BufferProtocol, Comparable, Iterable, PyComparisonOp, PyIter};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, Either, IdProtocol, IntoPyObject, PyClassImpl, PyComparisonValue, PyIterable,
|
||||
PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use itertools::Itertools;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
@@ -16,11 +16,11 @@ use rustpython_compiler as compile;
|
||||
|
||||
use crate::builtins::{self, PyStrRef, PyTypeRef};
|
||||
use crate::function::FuncArgs;
|
||||
use crate::pyobject::{
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, ItemProtocol, PyClassImpl, PyContext, PyObjectRef, PyResult, PyValue,
|
||||
StaticType, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
|
||||
@@ -3,8 +3,8 @@ pub(crate) use atexit::make_module;
|
||||
#[pymodule]
|
||||
mod atexit {
|
||||
use crate::function::FuncArgs;
|
||||
use crate::pyobject::{PyObjectRef, PyResult};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{PyObjectRef, PyResult};
|
||||
|
||||
#[pyfunction]
|
||||
fn register(func: PyObjectRef, args: FuncArgs, vm: &VirtualMachine) -> PyObjectRef {
|
||||
|
||||
@@ -7,8 +7,8 @@ mod decl {
|
||||
use crate::builtins::pystr::{PyStr, PyStrRef};
|
||||
use crate::byteslike::PyBytesLike;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{BorrowValue, PyObjectRef, PyResult, TryFromObject, TypeProtocol};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, PyObjectRef, PyResult, TryFromObject, TypeProtocol};
|
||||
use crc::{crc32, Hasher32};
|
||||
use itertools::Itertools;
|
||||
|
||||
|
||||
@@ -5,13 +5,11 @@ mod _collections {
|
||||
use crate::builtins::pytype::PyTypeRef;
|
||||
use crate::common::lock::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard};
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{
|
||||
PyComparisonValue, PyIterable, PyObjectRef, PyRef, PyResult, PyValue, StaticType,
|
||||
};
|
||||
use crate::slots::{Comparable, Iterable, PyComparisonOp, PyIter};
|
||||
use crate::vm::ReprGuard;
|
||||
use crate::VirtualMachine;
|
||||
use crate::{sequence, sliceable};
|
||||
use crate::{PyComparisonValue, PyIterable, PyObjectRef, PyRef, PyResult, PyValue, StaticType};
|
||||
use itertools::Itertools;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ use crate::builtins::pytype::PyTypeRef;
|
||||
use crate::common::lock::PyMutex;
|
||||
use crate::function::{ArgumentError, FromArgs, FuncArgs};
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{
|
||||
BorrowValue, PyClassImpl, PyIterable, PyObjectRef, PyRef, PyResult, PyValue, StaticType,
|
||||
TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::slots::PyIter;
|
||||
use crate::types::create_simple_type;
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, PyClassImpl, PyIterable, PyObjectRef, PyRef, PyResult, PyValue, StaticType,
|
||||
TryFromObject, TypeProtocol,
|
||||
};
|
||||
|
||||
#[repr(i32)]
|
||||
pub enum QuoteStyle {
|
||||
|
||||
@@ -7,8 +7,8 @@ mod decl {
|
||||
use crate::builtins::pystr::PyStrRef;
|
||||
use crate::bytecode::CodeFlags;
|
||||
use crate::compile;
|
||||
use crate::pyobject::{BorrowValue, ItemProtocol, PyObjectRef, PyResult, TryFromObject};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, ItemProtocol, PyObjectRef, PyResult, TryFromObject};
|
||||
|
||||
#[pyfunction]
|
||||
fn dis(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::pyobject::{ItemProtocol, PyObjectRef};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{ItemProtocol, PyObjectRef};
|
||||
|
||||
pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
|
||||
let errorcode = vm.ctx.new_dict();
|
||||
|
||||
@@ -6,8 +6,8 @@ mod fcntl {
|
||||
use crate::builtins::int;
|
||||
use crate::byteslike::{BufOrStr, PyRwBytesLike};
|
||||
use crate::function::OptionalArg;
|
||||
use crate::pyobject::{BorrowValue, Either, PyResult};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{BorrowValue, Either, PyResult};
|
||||
|
||||
#[pyattr]
|
||||
use libc::{FD_CLOEXEC, F_GETFD, F_GETFL, F_SETFD, F_SETFL};
|
||||
|
||||
@@ -4,8 +4,8 @@ pub(crate) use _functools::make_module;
|
||||
mod _functools {
|
||||
use crate::function::OptionalArg;
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{PyObjectRef, PyResult, TypeProtocol};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyObjectRef, PyResult, TypeProtocol};
|
||||
|
||||
#[pyfunction]
|
||||
fn reduce(
|
||||
|
||||
@@ -7,8 +7,8 @@ mod hashlib {
|
||||
use crate::builtins::pytype::PyTypeRef;
|
||||
use crate::common::lock::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard};
|
||||
use crate::function::{FuncArgs, OptionalArg};
|
||||
use crate::pyobject::{BorrowValue, PyResult, PyValue, StaticType};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, PyResult, PyValue, StaticType};
|
||||
use blake2::{Blake2b, Blake2s};
|
||||
use digest::DynDigest;
|
||||
use md5::Md5;
|
||||
|
||||
@@ -3,14 +3,14 @@ use crate::builtins::code::PyCode;
|
||||
use crate::builtins::module::PyModuleRef;
|
||||
use crate::builtins::pystr::{self, PyStr, PyStrRef};
|
||||
use crate::import;
|
||||
use crate::pyobject::{BorrowValue, ItemProtocol, PyObjectRef, PyResult, PyValue};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, ItemProtocol, PyObjectRef, PyResult, PyValue};
|
||||
|
||||
#[cfg(feature = "threading")]
|
||||
mod lock {
|
||||
use crate::pyobject::PyResult;
|
||||
use crate::stdlib::thread::RawRMutex;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::PyResult;
|
||||
|
||||
pub(super) static IMP_LOCK: RawRMutex = RawRMutex::INIT;
|
||||
|
||||
|
||||
+6
-6
@@ -8,8 +8,8 @@ cfg_if::cfg_if! {
|
||||
type Offset = i64;
|
||||
}
|
||||
}
|
||||
use crate::pyobject::{BorrowValue, PyObjectRef, PyResult, TryFromObject};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{BorrowValue, PyObjectRef, PyResult, TryFromObject};
|
||||
pub(crate) use _io::io_open as open;
|
||||
|
||||
pub(crate) fn make_module(vm: &VirtualMachine) -> PyObjectRef {
|
||||
@@ -88,11 +88,11 @@ mod _io {
|
||||
use crate::common::rc::PyRc;
|
||||
use crate::exceptions::{self, IntoPyException, PyBaseExceptionRef};
|
||||
use crate::function::{FuncArgs, OptionalArg, OptionalOption};
|
||||
use crate::pyobject::{
|
||||
use crate::vm::{ReprGuard, VirtualMachine};
|
||||
use crate::{
|
||||
BorrowValue, Either, IdProtocol, IntoPyObject, PyContext, PyIterable, PyObjectRef, PyRef,
|
||||
PyResult, PyValue, StaticType, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::vm::{ReprGuard, VirtualMachine};
|
||||
|
||||
fn validate_whence(whence: i32) -> bool {
|
||||
let x = (0..=2).contains(&whence);
|
||||
@@ -3663,11 +3663,11 @@ mod fileio {
|
||||
use crate::exceptions::IntoPyException;
|
||||
use crate::function::OptionalOption;
|
||||
use crate::function::{FuncArgs, OptionalArg};
|
||||
use crate::pyobject::{
|
||||
BorrowValue, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::stdlib::os;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ mod decl {
|
||||
use crate::common::rc::PyRc;
|
||||
use crate::function::{Args, FuncArgs, OptionalArg, OptionalOption};
|
||||
use crate::iterator::{call_next, get_all, get_iter, get_next_object};
|
||||
use crate::pyobject::{
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, IntoPyObject, PyCallable, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
PyWeakRef, StaticType, TypeProtocol,
|
||||
};
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
#[pyattr]
|
||||
#[pyclass(name = "chain")]
|
||||
|
||||
@@ -9,12 +9,12 @@ mod _json {
|
||||
use crate::exceptions::PyBaseExceptionRef;
|
||||
use crate::function::{FuncArgs, OptionalArg};
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{
|
||||
use crate::slots::Callable;
|
||||
use crate::VirtualMachine;
|
||||
use crate::{
|
||||
BorrowValue, IdProtocol, IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, StaticType,
|
||||
TryFromObject,
|
||||
};
|
||||
use crate::slots::Callable;
|
||||
use crate::VirtualMachine;
|
||||
|
||||
use num_bigint::BigInt;
|
||||
use std::str::FromStr;
|
||||
|
||||
@@ -7,8 +7,8 @@ mod decl {
|
||||
use rustpython_parser::lexer;
|
||||
|
||||
use crate::builtins::pystr::PyStrRef;
|
||||
use crate::pyobject::{BorrowValue, PyObjectRef};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, PyObjectRef};
|
||||
|
||||
#[pyfunction]
|
||||
fn iskeyword(s: PyStrRef) -> bool {
|
||||
|
||||
@@ -7,8 +7,8 @@ mod decl {
|
||||
use crate::bytecode;
|
||||
use crate::byteslike::PyBytesLike;
|
||||
use crate::common::borrow::BorrowValue;
|
||||
use crate::pyobject::{PyObjectRef, PyResult, TryFromObject};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyObjectRef, PyResult, TryFromObject};
|
||||
|
||||
#[pyfunction]
|
||||
fn dumps(co: PyCodeRef) -> PyBytes {
|
||||
|
||||
@@ -10,8 +10,8 @@ use puruspe::{erf, erfc, gamma, ln_gamma};
|
||||
use crate::builtins::float::{self, IntoPyFloat, PyFloatRef};
|
||||
use crate::builtins::int::{self, PyInt, PyIntRef};
|
||||
use crate::function::{Args, OptionalArg};
|
||||
use crate::pyobject::{BorrowValue, Either, PyIterable, PyObjectRef, PyResult, TypeProtocol};
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{BorrowValue, Either, PyIterable, PyObjectRef, PyResult, TypeProtocol};
|
||||
use rustpython_common::float_ops;
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::pyobject::PyObjectRef;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::PyObjectRef;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::os::errno_err;
|
||||
use crate::builtins::bytes::PyBytesRef;
|
||||
use crate::builtins::pystr::PyStrRef;
|
||||
use crate::pyobject::{BorrowValue, PyObjectRef, PyResult};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{BorrowValue, PyObjectRef, PyResult};
|
||||
|
||||
use itertools::Itertools;
|
||||
use winapi::shared::minwindef::UINT;
|
||||
|
||||
@@ -5,7 +5,7 @@ pub(crate) use _multiprocessing::make_module;
|
||||
mod _multiprocessing {
|
||||
use super::super::os;
|
||||
use crate::byteslike::PyBytesLike;
|
||||
use crate::pyobject::PyResult;
|
||||
use crate::PyResult;
|
||||
use crate::VirtualMachine;
|
||||
use winapi::um::winsock2::{self, SOCKET};
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ use crate::byteslike::PyBytesLike;
|
||||
use crate::common::cmp;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::iterator;
|
||||
use crate::pyobject::{BorrowValue, Either, PyObjectRef, PyResult, TypeProtocol};
|
||||
use crate::VirtualMachine;
|
||||
use crate::{BorrowValue, Either, PyObjectRef, PyResult, TypeProtocol};
|
||||
|
||||
fn _operator_length_hint(obj: PyObjectRef, default: OptionalArg, vm: &VirtualMachine) -> PyResult {
|
||||
let default = default.unwrap_or_else(|| vm.ctx.new_int(0));
|
||||
|
||||
+4
-4
@@ -23,12 +23,12 @@ use crate::byteslike::PyBytesLike;
|
||||
use crate::common::lock::PyRwLock;
|
||||
use crate::exceptions::{IntoPyException, PyBaseExceptionRef};
|
||||
use crate::function::{ArgumentError, FromArgs, FuncArgs, OptionalArg};
|
||||
use crate::pyobject::{
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::{ReprGuard, VirtualMachine};
|
||||
use crate::{
|
||||
BorrowValue, Either, IntoPyObject, ItemProtocol, PyObjectRef, PyRef, PyResult,
|
||||
PyStructSequence, PyValue, StaticType, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crate::slots::PyIter;
|
||||
use crate::vm::{ReprGuard, VirtualMachine};
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::ffi as ffi_ext;
|
||||
@@ -1662,7 +1662,7 @@ mod posix {
|
||||
|
||||
use crate::builtins::dict::PyMapping;
|
||||
use crate::builtins::list::PyListRef;
|
||||
use crate::pyobject::PyIterable;
|
||||
use crate::PyIterable;
|
||||
use bitflags::bitflags;
|
||||
use nix::errno::{errno, Errno};
|
||||
use nix::unistd::{self, Gid, Pid, Uid};
|
||||
|
||||
Loaded 100 of 133 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user