Skip to content

Commit 32a54b2

Browse files
coolreader18youknowone
authored andcommitted
Fix compilation without compiler feature
1 parent 85030e3 commit 32a54b2

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

stdlib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ license.workspace = true
1212

1313
[features]
1414
default = ["compiler"]
15-
compiler = ["rustpython-vm/compiler"]
1615
threading = ["rustpython-common/threading", "rustpython-vm/threading"]
1716
zlib = ["libz-sys", "flate2/zlib"]
1817
bz2 = ["bzip2"]
1918
ssl = ["openssl", "openssl-sys", "foreign-types-shared"]
2019
ssl-vendor = ["ssl", "openssl/vendored", "openssl-probe"]
20+
compiler = ["rustpython-vm/compiler"]
2121

2222
[dependencies]
2323
# rustpython crates

stdlib/src/dis.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mod decl {
1313
let co = if let Ok(co) = obj.get_attr("__code__", vm) {
1414
// Method or function:
1515
PyRef::try_from_object(vm, co)?
16+
<<<<<<< HEAD
1617
} else if let Ok(_co_str) = PyStrRef::try_from_object(vm, obj.clone()) {
1718
#[cfg(not(feature = "compiler"))]
1819
return Err(vm.new_runtime_error(
@@ -25,6 +26,27 @@ mod decl {
2526
"<dis>".to_owned(),
2627
)
2728
.map_err(|err| vm.new_syntax_error(&err, Some(_co_str.as_str())))?
29+
||||||| parent of d98f13178 (Fix compilation without compiler feature)
30+
} else if let Ok(co_str) = PyStrRef::try_from_object(vm, obj.clone()) {
31+
// String:
32+
vm.compile(co_str.as_str(), compiler::Mode::Exec, "<dis>".to_owned())
33+
.map_err(|err| vm.new_syntax_error(&err))?
34+
=======
35+
} else if let Ok(co_str) = PyStrRef::try_from_object(vm, obj.clone()) {
36+
// String:
37+
#[cfg(feature = "compiler")]
38+
{
39+
vm.compile(co_str.as_str(), compiler::Mode::Exec, "<dis>".to_owned())
40+
.map_err(|err| vm.new_syntax_error(&err))?
41+
}
42+
#[cfg(not(feature = "compiler"))]
43+
{
44+
let _ = co_str;
45+
return Err(
46+
vm.new_not_implemented_error("compiler feature is turned off".to_owned())
47+
);
48+
}
49+
>>>>>>> d98f13178 (Fix compilation without compiler feature)
2850
} else {
2951
PyRef::try_from_object(vm, obj)?
3052
};

vm/src/vm/vm_new.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ impl VirtualMachine {
256256
self.new_exception_msg(overflow_error, msg)
257257
}
258258

259+
<<<<<<< HEAD
259260
#[cfg(any(feature = "rustpython-parser", feature = "rustpython-codegen"))]
260261
pub fn new_syntax_error(
261262
&self,
@@ -264,6 +265,12 @@ impl VirtualMachine {
264265
) -> PyBaseExceptionRef {
265266
use crate::source_code::SourceLocation;
266267

268+
||||||| parent of d98f13178 (Fix compilation without compiler feature)
269+
#[cfg(any(feature = "rustpython-parser", feature = "rustpython-codegen"))]
270+
pub fn new_syntax_error(&self, error: &crate::compiler::CompileError) -> PyBaseExceptionRef {
271+
=======
272+
pub fn new_syntax_error(&self, error: &crate::compiler::CompileError) -> PyBaseExceptionRef {
273+
>>>>>>> d98f13178 (Fix compilation without compiler feature)
267274
let syntax_error_type = match &error.error {
268275
#[cfg(feature = "rustpython-parser")]
269276
crate::compiler::CompileErrorType::Parse(p) if p.is_indentation_error() => {

0 commit comments

Comments
 (0)