◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ members = [
version = "0.4.0"
authors = ["RustPython Team"]
edition = "2024"
rust-version = "1.87.0"
repository = "https://github.com/RustPython/RustPython"
license = "MIT"

Expand Down
11 changes: 5 additions & 6 deletions common/src/fileutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,13 @@ pub mod windows {
.next_back()
.and_then(|s| String::from_utf16(s).ok());

if let Some(file_extension) = file_extension {
if file_extension.eq_ignore_ascii_case("exe")
|| file_extension.eq_ignore_ascii_case("bat")
|| file_extension.eq_ignore_ascii_case("cmd")
|| file_extension.eq_ignore_ascii_case("com")
{
self.st_mode |= 0o111;
}
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions derive-impl/src/compile_bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ impl CompilationSource {
let mut code_map = HashMap::new();
let paths = fs::read_dir(path)
.or_else(|e| {
if cfg!(windows) {
if let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) {
return fs::read_dir(real_path.trim());
}
}
Err(e)
})
Expand Down Expand Up @@ -195,14 +195,14 @@ impl CompilationSource {
})
};
let code = compile_path(&path).or_else(|e| {
if cfg!(windows) {
if let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) {
let joined = path.parent().unwrap().join(real_path.trim());
if joined.exists() {
return compile_path(&joined);
} else {
return Err(e);
}
}
}
Err(e)
Expand Down
17 changes: 9 additions & 8 deletions jit/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,11 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
let target_block = self.get_or_create_block(label);

// If the current block isn't terminated, jump:
if let Some(cur) = self.builder.current_block() {
if cur != target_block && self.builder.func.layout.last_inst(cur).is_none() {
self.builder.ins().jump(target_block, &[]);
}
}
// Switch to the target block
if self.builder.current_block() != Some(target_block) {
Expand Down Expand Up @@ -207,10 +208,10 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
}

// After processing, if the current block is unterminated, insert a trap or fallthrough
if let Some(cur) = self.builder.current_block() {
if self.builder.func.layout.last_inst(cur).is_none() {
self.builder.ins().trap(TrapCode::user(0).unwrap());
}
}
Ok(())
}
Expand Down
18 changes: 9 additions & 9 deletions pylib/build.rs
Original file line number Diff line number Diff line change
@@ -9,15 +9,15 @@ fn main() {
process_python_libs("./Lib/**/*");
}

if cfg!(windows) {
if let Ok(real_path) = std::fs::read_to_string("Lib") {
let canonicalized_path = std::fs::canonicalize(real_path)
.expect("failed to resolve RUSTPYTHONPATH during build time");
println!(
"cargo:rustc-env=win_lib_path={}",
canonicalized_path.to_str().unwrap()
);
}
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ fn shell_exec(
{
let loc = raw_location.start().to_usize();
let mut iter = source.chars();
if let Some(quote) = iter.nth(loc) {
if iter.next() == Some(quote) && iter.next() == Some(quote) {
return ShellExecResult::ContinueLine;
}
}
};

11 changes: 5 additions & 6 deletions stdlib/src/contextvars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,11 @@ mod _contextvars {
let ctx = ctxs.last()?;
let cached_ptr = zelf.cached.as_ptr();
debug_assert!(!cached_ptr.is_null());
if let Some(cached) = unsafe { &*cached_ptr } {
if zelf.cached_id.load(Ordering::SeqCst) == ctx.get_id()
&& cached.idx + 1 == ctxs.len()
{
return Some(cached.object.clone());
}
}
let vars = ctx.borrow_vars();
let obj = vars.get(zelf)?;
20 changes: 10 additions & 10 deletions stdlib/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,23 +518,23 @@ mod math {
#[pyfunction]
fn ceil(x: PyObjectRef, vm: &VirtualMachine) -> PyResult {
let result_or_err = try_magic_method(identifier!(vm, __ceil__), vm, &x);
if result_or_err.is_err() {
if let Some(v) = x.try_float_opt(vm) {
let v = try_f64_to_bigint(v?.to_f64().ceil(), vm)?;
return Ok(vm.ctx.new_int(v).into());
}
}
result_or_err
}

#[pyfunction]
fn floor(x: PyObjectRef, vm: &VirtualMachine) -> PyResult {
let result_or_err = try_magic_method(identifier!(vm, __floor__), vm, &x);
if result_or_err.is_err() {
if let Some(v) = x.try_float_opt(vm) {
let v = try_f64_to_bigint(v?.to_f64().floor(), vm)?;
return Ok(vm.ctx.new_int(v).into());
}
}
result_or_err
}
Expand Down
27 changes: 13 additions & 14 deletions stdlib/src/scproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,22 @@ mod _scproxy {
.and_then(|v| v.downcast::<CFNumber>())
.and_then(|v| v.to_i32())
.unwrap_or(0);
if enabled {
if let Some(host) = proxy_dict
.find(host_key)
.and_then(|v| v.downcast::<CFString>())
{
let h = std::borrow::Cow::<str>::from(&host);
let v = if let Some(port) = proxy_dict
.find(port_key)
.and_then(|v| v.downcast::<CFNumber>())
.and_then(|v| v.to_i32())
{
format!("http://{h}:{port}")
} else {
format!("http://{h}")
};
result.set_item(proto, vm.new_pyobj(v), vm)?;
}
}
Ok(())
};
Expand Down
Loading
Loading
Toggle all file notes Toggle all file annotations