8000 Fix rustpython-vm --no-default-features build by youknowone · Pull Request #5222 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Fix rustpython-vm --no-default-features build #5222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix rustpython-vm --no-default-features build
  • Loading branch information
youknowone committed Apr 10, 2024
commit ccf650d4caae0c6e0cbfeefe102fea1698d26056
2 changes: 1 addition & 1 deletion stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ssl-vendor = ["ssl", "openssl/vendored", "openssl-probe"]
[dependencies]
# rustpython crates
rustpython-derive = { workspace = true }
8000 rustpython-vm = { workspace = true, features = ["compiler"] }
rustpython-vm = { workspace = true }
rustpython-common = { workspace = true }

ahash = { workspace = true }
Expand Down
13 changes: 7 additions & 6 deletions vm/src/compiler.rs
Original file line number Diff line number Diff line change
@@ -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"))]
Expand All @@ -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)
}
}
3 changes: 1 addition & 2 deletions vm/src/stdlib/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions vm/src/vm/vm_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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() => {
Expand Down
0