mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Merge pull request #5222 from youknowone/vm-build
Fix rustpython-vm --no-default-features build
This commit is contained in:
4 files changed
+12
-11
No files matched your search
+1
-1
@@ -19,7 +19,7 @@ ssl-vendor = ["ssl", "openssl/vendored", "openssl-probe"]
|
||||
[dependencies]
|
||||
# rustpython crates
|
||||
rustpython-derive = { workspace = true }
|
||||
rustpython-vm = { workspace = true, features = ["compiler"] }
|
||||
rustpython-vm = { workspace = true }
|
||||
rustpython-common = { workspace = true }
|
||||
|
||||
ahash = { workspace = true }
|
||||
|
||||
+7
-6
@@ -1,14 +1,14 @@
|
||||
use crate::{builtins::PyBaseExceptionRef, convert::ToPyException, VirtualMachine};
|
||||
|
||||
#[cfg(feature = "rustpython-codegen")]
|
||||
pub use rustpython_codegen::CompileOpts;
|
||||
#[cfg(feature = "rustpython-compiler")]
|
||||
pub use rustpython_compiler::*;
|
||||
#[cfg(not(feature = "rustpython-compiler"))]
|
||||
pub use rustpython_compiler_core::Mode;
|
||||
|
||||
#[cfg(not(feature = "rustpython-compiler"))]
|
||||
pub use rustpython_compiler_core as core;
|
||||
|
||||
#[cfg(all(not(feature = "rustpython-compiler"), feature = "rustpython-parser"))]
|
||||
#[cfg(not(feature = "rustpython-compiler"))]
|
||||
pub use rustpython_parser_core as parser;
|
||||
|
||||
#[cfg(not(feature = "rustpython-compiler"))]
|
||||
@@ -26,13 +26,14 @@ mod error {
|
||||
Parse(#[from] rustpython_parser::error::ParseErrorType),
|
||||
}
|
||||
|
||||
pub type CompileError = rustpython_compiler_core::CompileError<CompileErrorType>;
|
||||
pub type CompileError = rustpython_parser_core::source_code::LocatedError<CompileErrorType>;
|
||||
}
|
||||
#[cfg(not(feature = "rustpython-compiler"))]
|
||||
pub use error::{CompileError, CompileErrorType};
|
||||
|
||||
impl ToPyException for (CompileError, Option<&str>) {
|
||||
fn to_pyexception(&self, vm: &VirtualMachine) -> PyBaseExceptionRef {
|
||||
#[cfg(any(feature = "rustpython-parser", feature = "rustpython-codegen"))]
|
||||
impl crate::convert::ToPyException for (CompileError, Option<&str>) {
|
||||
fn to_pyexception(&self, vm: &crate::VirtualMachine) -> crate::builtins::PyBaseExceptionRef {
|
||||
vm.new_syntax_error(&self.0, self.1)
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ mod builtins {
|
||||
PyByteArray, PyBytes, PyDictRef, PyStr, PyStrRef, PyTuple, PyTupleRef, PyType,
|
||||
},
|
||||
common::{hash::PyHash, str::to_ascii},
|
||||
convert::ToPyException,
|
||||
function::{
|
||||
ArgBytesLike, ArgCallable, ArgIndex, ArgIntoBool, ArgIterable, ArgMapping,
|
||||
ArgStrOrBytesLike, Either, FsPath, FuncArgs, KwArgs, OptionalArg, OptionalOption,
|
||||
@@ -147,7 +146,7 @@ mod builtins {
|
||||
}
|
||||
#[cfg(feature = "rustpython-parser")]
|
||||
{
|
||||
use crate::builtins::PyBytesRef;
|
||||
use crate::{builtins::PyBytesRef, convert::ToPyException};
|
||||
use num_traits::Zero;
|
||||
use rustpython_parser as parser;
|
||||
|
||||
|
||||
+3
-2
@@ -8,8 +8,6 @@ use crate::{
|
||||
convert::ToPyObject,
|
||||
function::{IntoPyNativeFn, PyMethodFlags},
|
||||
scope::Scope,
|
||||
source::AtLocation,
|
||||
source_code::SourceLocation,
|
||||
vm::VirtualMachine,
|
||||
AsObject, Py, PyObject, PyObjectRef, PyRef,
|
||||
};
|
||||
@@ -255,6 +253,9 @@ impl VirtualMachine {
|
||||
error: &crate::compiler::CompileError,
|
||||
source: Option<&str>,
|
||||
) -> PyBaseExceptionRef {
|
||||
use crate::source::AtLocation;
|
||||
use crate::source_code::SourceLocation;
|
||||
|
||||
let syntax_error_type = match &error.error {
|
||||
#[cfg(feature = "rustpython-parser")]
|
||||
crate::compiler::CompileErrorType::Parse(p) if p.is_indentation_error() => {
|
||||
|
||||
Reference in new issue
Block a user