diff --git a/vm/src/builtins/bytearray.rs b/vm/src/builtins/bytearray.rs index b3e80e6d04..e7ff8df7af 100644 --- a/vm/src/builtins/bytearray.rs +++ b/vm/src/builtins/bytearray.rs @@ -14,8 +14,7 @@ use crate::{ ByteInnerNewOptions, ByteInnerPaddingOptions, ByteInnerSplitOptions, ByteInnerTranslateOptions, DecodeArgs, PyBytesInner, }, - byteslike::ArgBytesLike, - function::{ArgIterable, FuncArgs, OptionalArg, OptionalOption}, + function::{ArgBytesLike, ArgIterable, FuncArgs, OptionalArg, OptionalOption}, protocol::{BufferInternal, BufferOptions, PyBuffer, ResizeGuard}, sliceable::{PySliceableSequence, PySliceableSequenceMut, SequenceIndex}, slots::{ diff --git a/vm/src/builtins/bytes.rs b/vm/src/builtins/bytes.rs index bed91312ec..d052423670 100644 --- a/vm/src/builtins/bytes.rs +++ b/vm/src/builtins/bytes.rs @@ -5,9 +5,8 @@ use crate::{ bytes_decode, ByteInnerFindOptions, ByteInnerNewOptions, ByteInnerPaddingOptions, ByteInnerSplitOptions, ByteInnerTranslateOptions, DecodeArgs, PyBytesInner, }, - byteslike::ArgBytesLike, common::hash::PyHash, - function::{ArgIterable, OptionalArg, OptionalOption}, + function::{ArgBytesLike, ArgIterable, OptionalArg, OptionalOption}, protocol::{BufferInternal, BufferOptions, PyBuffer}, slots::{ AsBuffer, Callable, Comparable, Hashable, Iterable, IteratorIterable, PyComparisonOp, diff --git a/vm/src/builtins/make_module.rs b/vm/src/builtins/make_module.rs index 4511b82e56..7a7b178930 100644 --- a/vm/src/builtins/make_module.rs +++ b/vm/src/builtins/make_module.rs @@ -20,10 +20,10 @@ mod decl { #[cfg(feature = "rustpython-compiler")] use crate::compile; use crate::{ - byteslike::ArgBytesLike, common::{hash::PyHash, str::to_ascii}, function::{ - ArgCallable, ArgIterable, FuncArgs, KwArgs, OptionalArg, OptionalOption, PosArgs, + ArgBytesLike, ArgCallable, ArgIterable, FuncArgs, KwArgs, OptionalArg, OptionalOption, + PosArgs, }, iterator, py_io, readline::{Readline, ReadlineResult}, diff --git a/vm/src/function.rs b/vm/src/function.rs index fe3b3cc870..6daf5f3691 100644 --- a/vm/src/function.rs +++ b/vm/src/function.rs @@ -1,4 +1,5 @@ mod argument; +mod byteslike; use self::OptionalArg::*; use crate::builtins::pytype::PyTypeRef; @@ -16,6 +17,7 @@ use std::marker::PhantomData; use std::ops::RangeInclusive; pub use argument::{ArgCallable, ArgIterable, PyIterator}; +pub use byteslike::{ArgBytesLike, ArgMemoryBuffer, ArgStrOrBytesLike}; pub trait IntoFuncArgs: Sized { fn into_args(self, vm: &VirtualMachine) -> FuncArgs; diff --git a/vm/src/byteslike.rs b/vm/src/function/byteslike.rs similarity index 100% rename from vm/src/byteslike.rs rename to vm/src/function/byteslike.rs diff --git a/vm/src/lib.rs b/vm/src/lib.rs index 7028c9e30d..a415c55ae1 100644 --- a/vm/src/lib.rs +++ b/vm/src/lib.rs @@ -45,7 +45,6 @@ pub(crate) mod macros; mod anystr; pub mod builtins; mod bytesinner; -pub mod byteslike; pub mod cformat; mod codecs; mod coroutine; diff --git a/vm/src/stdlib/array.rs b/vm/src/stdlib/array.rs index 9ca88a2e2c..c552dc6f05 100644 --- a/vm/src/stdlib/array.rs +++ b/vm/src/stdlib/array.rs @@ -15,8 +15,7 @@ mod array { IntoPyFloat, PyByteArray, PyBytes, PyBytesRef, PyIntRef, PyList, PyListRef, PySliceRef, PyStr, PyStrRef, PyTypeRef, }, - byteslike::ArgBytesLike, - function::{ArgIterable, OptionalArg}, + function::{ArgBytesLike, ArgIterable, OptionalArg}, protocol::{BufferInternal, BufferOptions, PyBuffer, ResizeGuard}, sliceable::{saturate_index, PySliceableSequence, PySliceableSequenceMut, SequenceIndex}, slots::{ diff --git a/vm/src/stdlib/binascii.rs b/vm/src/stdlib/binascii.rs index 547ad971da..035f16ccd3 100644 --- a/vm/src/stdlib/binascii.rs +++ b/vm/src/stdlib/binascii.rs @@ -4,8 +4,7 @@ pub(crate) use decl::make_module; mod decl { use crate::{ builtins::{PyByteArray, PyBytes, PyStr, PyTypeRef}, - byteslike::ArgBytesLike, - function::OptionalArg, + function::{ArgBytesLike, OptionalArg}, PyObjectRef, PyRef, PyResult, TryFromObject, TypeProtocol, VirtualMachine, }; use crc::{crc32, Hasher32}; diff --git a/vm/src/stdlib/codecs.rs b/vm/src/stdlib/codecs.rs index ac63e4e1d4..1f9e16f3ed 100644 --- a/vm/src/stdlib/codecs.rs +++ b/vm/src/stdlib/codecs.rs @@ -5,10 +5,9 @@ mod _codecs { use crate::common::encodings; use crate::{ builtins::{PyBytes, PyBytesRef, PyStr, PyStrRef, PyTuple}, - byteslike::ArgBytesLike, codecs, exceptions::PyBaseExceptionRef, - function::FuncArgs, + function::{ArgBytesLike, FuncArgs}, IdProtocol, PyObjectRef, PyResult, TryFromBorrowedObject, VirtualMachine, }; use std::ops::Range; diff --git a/vm/src/stdlib/fcntl.rs b/vm/src/stdlib/fcntl.rs index 27c84b94dd..5a0b0a21b6 100644 --- a/vm/src/stdlib/fcntl.rs +++ b/vm/src/stdlib/fcntl.rs @@ -4,8 +4,7 @@ pub(crate) use fcntl::make_module; mod fcntl { use crate::{ builtins::int, - byteslike::{ArgMemoryBuffer, ArgStrOrBytesLike}, - function::OptionalArg, + function::{ArgMemoryBuffer, ArgStrOrBytesLike, OptionalArg}, stdlib::{io, os}, utils::Either, PyResult, VirtualMachine, diff --git a/vm/src/stdlib/io.rs b/vm/src/stdlib/io.rs index 54ac8050e7..ef7531b2ea 100644 --- a/vm/src/stdlib/io.rs +++ b/vm/src/stdlib/io.rs @@ -80,8 +80,8 @@ mod _io { builtins::{ PyByteArray, PyBytes, PyBytesRef, PyMemoryView, PyStr, PyStrRef, PyType, PyTypeRef, }, - byteslike::{ArgBytesLike, ArgMemoryBuffer}, exceptions::{self, PyBaseExceptionRef}, + function::{ArgBytesLike, ArgMemoryBuffer}, function::{ArgIterable, FuncArgs, OptionalArg, OptionalOption}, protocol::{BufferInternal, BufferOptions, PyBuffer, ResizeGuard}, slots::{Iterable, PyIter, SlotConstructor}, @@ -3682,10 +3682,10 @@ mod fileio { use super::_io::*; use crate::{ builtins::{PyStr, PyStrRef, PyTypeRef}, - byteslike::{ArgBytesLike, ArgMemoryBuffer}, crt_fd::Fd, exceptions::IntoPyException, function::OptionalOption, + function::{ArgBytesLike, ArgMemoryBuffer}, function::{FuncArgs, OptionalArg}, stdlib::os, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol, VirtualMachine, diff --git a/vm/src/stdlib/marshal.rs b/vm/src/stdlib/marshal.rs index c67372e92b..30bf88b24b 100644 --- a/vm/src/stdlib/marshal.rs +++ b/vm/src/stdlib/marshal.rs @@ -5,7 +5,7 @@ mod decl { use crate::{ builtins::{PyBytes, PyCode}, bytecode, - byteslike::ArgBytesLike, + function::ArgBytesLike, PyObjectRef, PyRef, PyResult, TryFromObject, VirtualMachine, }; diff --git a/vm/src/stdlib/multiprocessing.rs b/vm/src/stdlib/multiprocessing.rs index b1848e5b37..a03643ea1d 100644 --- a/vm/src/stdlib/multiprocessing.rs +++ b/vm/src/stdlib/multiprocessing.rs @@ -3,7 +3,7 @@ pub(crate) use _multiprocessing::make_module; #[cfg(windows)] #[pymodule] mod _multiprocessing { - use crate::{byteslike::ArgBytesLike, stdlib::os, PyResult, VirtualMachine}; + use crate::{function::ArgBytesLike, stdlib::os, PyResult, VirtualMachine}; use winapi::um::winsock2::{self, SOCKET}; #[pyfunction] diff --git a/vm/src/stdlib/operator.rs b/vm/src/stdlib/operator.rs index 3586c50022..935fdac04f 100644 --- a/vm/src/stdlib/operator.rs +++ b/vm/src/stdlib/operator.rs @@ -12,8 +12,7 @@ mod _operator { use crate::common::cmp; use crate::{ builtins::{PyInt, PyIntRef, PyStrRef, PyTypeRef}, - byteslike::ArgBytesLike, - function::{FuncArgs, KwArgs, OptionalArg}, + function::{ArgBytesLike, FuncArgs, KwArgs, OptionalArg}, iterator, slots::{ Callable, diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 3d21b59fa9..7766b7aa78 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -370,10 +370,9 @@ pub(super) mod _os { use crate::common::lock::{OnceCell, PyRwLock}; use crate::{ builtins::{PyBytesRef, PyStrRef, PyTuple, PyTupleRef, PyTypeRef}, - byteslike::ArgBytesLike, crt_fd::{Fd, Offset}, exceptions::IntoPyException, - function::{FuncArgs, OptionalArg}, + function::{ArgBytesLike, FuncArgs, OptionalArg}, slots::{IteratorIterable, PyIter}, suppress_iph, utils::Either, diff --git a/vm/src/stdlib/posix.rs b/vm/src/stdlib/posix.rs index b1927c7228..9e9c94ed68 100644 --- a/vm/src/stdlib/posix.rs +++ b/vm/src/stdlib/posix.rs @@ -1729,10 +1729,10 @@ pub mod module { fn _extract_vec_bytes( x: OptionalArg, vm: &VirtualMachine, - ) -> PyResult>> { + ) -> PyResult>> { let inner = match x.into_option() { Some(v) => { - let v = vm.extract_elements::(&v)?; + let v = vm.extract_elements::(&v)?; if v.is_empty() { None } else { diff --git a/vm/src/stdlib/pyexpat.rs b/vm/src/stdlib/pyexpat.rs index 1d7f26b2aa..07dc0f5844 100644 --- a/vm/src/stdlib/pyexpat.rs +++ b/vm/src/stdlib/pyexpat.rs @@ -33,7 +33,7 @@ macro_rules! create_property { mod _pyexpat { use crate::{ builtins::{PyStr, PyStrRef, PyTypeRef}, - byteslike::ArgBytesLike, + function::ArgBytesLike, function::{IntoFuncArgs, OptionalArg}, ItemProtocol, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, VirtualMachine, diff --git a/vm/src/stdlib/pystruct.rs b/vm/src/stdlib/pystruct.rs index 2a512b398b..661e75eb54 100644 --- a/vm/src/stdlib/pystruct.rs +++ b/vm/src/stdlib/pystruct.rs @@ -16,10 +16,9 @@ pub(crate) mod _struct { bytes::PyBytesRef, float, pybool::IntoPyBool, pystr::PyStr, pystr::PyStrRef, pytype::PyTypeRef, tuple::PyTupleRef, }, - byteslike::{ArgBytesLike, ArgMemoryBuffer}, common::str::wchar_t, exceptions::PyBaseExceptionRef, - function::PosArgs, + function::{ArgBytesLike, ArgMemoryBuffer, PosArgs}, slots::{IteratorIterable, PyIter, SlotConstructor}, utils::Either, IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, VirtualMachine, diff --git a/vm/src/stdlib/socket.rs b/vm/src/stdlib/socket.rs index 65263c6fd2..581cca9971 100644 --- a/vm/src/stdlib/socket.rs +++ b/vm/src/stdlib/socket.rs @@ -1,9 +1,8 @@ use crate::common::lock::{PyMappedRwLockReadGuard, PyRwLock, PyRwLockReadGuard}; use crate::{ builtins::{PyStrRef, PyTupleRef, PyTypeRef}, - byteslike::{ArgBytesLike, ArgMemoryBuffer}, exceptions::{IntoPyException, PyBaseExceptionRef}, - function::{FuncArgs, OptionalArg, OptionalOption}, + function::{ArgBytesLike, ArgMemoryBuffer, FuncArgs, OptionalArg, OptionalOption}, utils::{Either, ToCString}, IntoPyObject, PyClassImpl, PyObjectRef, PyResult, PyValue, TryFromBorrowedObject, TryFromObject, TypeProtocol, VirtualMachine, @@ -302,7 +301,7 @@ impl PySocket { #[cfg(unix)] c::AF_UNIX => { use std::os::unix::ffi::OsStrExt; - let buf = crate::byteslike::ArgStrOrBytesLike::try_from_object(vm, addr)?; + let buf = crate::function::ArgStrOrBytesLike::try_from_object(vm, addr)?; let path = &*buf.borrow_bytes(); if cfg!(any(target_os = "linux", target_os = "android")) && path.first() == Some(&0) { diff --git a/vm/src/stdlib/ssl.rs b/vm/src/stdlib/ssl.rs index 0a196c11c4..51a73be27a 100644 --- a/vm/src/stdlib/ssl.rs +++ b/vm/src/stdlib/ssl.rs @@ -5,8 +5,8 @@ use crate::common::{ }; use crate::{ builtins::{PyStrRef, PyType, PyTypeRef, PyWeak}, - byteslike::{ArgBytesLike, ArgMemoryBuffer, ArgStrOrBytesLike}, exceptions::{self, IntoPyException, PyBaseException, PyBaseExceptionRef}, + function::{ArgBytesLike, ArgMemoryBuffer, ArgStrOrBytesLike}, function::{ArgCallable, OptionalArg}, slots::SlotConstructor, stdlib::os::PyPathLike, diff --git a/vm/src/stdlib/zlib.rs b/vm/src/stdlib/zlib.rs index a90b3a2a05..c8da644ce2 100644 --- a/vm/src/stdlib/zlib.rs +++ b/vm/src/stdlib/zlib.rs @@ -5,9 +5,8 @@ mod decl { use crate::common::lock::PyMutex; use crate::{ builtins::{PyBytes, PyBytesRef, PyIntRef, PyTypeRef}, - byteslike::ArgBytesLike, exceptions::PyBaseExceptionRef, - function::OptionalArg, + function::{ArgBytesLike, OptionalArg}, types::create_simple_type, IntoPyRef, PyResult, PyValue, VirtualMachine, }; diff --git a/wasm/lib/src/convert.rs b/wasm/lib/src/convert.rs index d5aee0dbad..3744ef9edc 100644 --- a/wasm/lib/src/convert.rs +++ b/wasm/lib/src/convert.rs @@ -2,9 +2,9 @@ use js_sys::{Array, ArrayBuffer, Object, Promise, Reflect, SyntaxError, Uint8Arr use wasm_bindgen::{closure::Closure, prelude::*, JsCast}; use rustpython_parser::error::ParseErrorType; -use rustpython_vm::byteslike::ArgBytesLike; use rustpython_vm::compile::{CompileError, CompileErrorType}; use rustpython_vm::exceptions::PyBaseExceptionRef; +use rustpython_vm::function::ArgBytesLike; use rustpython_vm::function::FuncArgs; use rustpython_vm::VirtualMachine; use rustpython_vm::{exceptions, py_serde};