Skip to content
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
4 changes: 2 additions & 2 deletions stdlib/src/binascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mod decl {
}

#[pyattr(name = "Error")]
fn get_binascii_error(vm: &VirtualMachine) -> PyTypeRef {
fn error_type(vm: &VirtualMachine) -> PyTypeRef {
rustpython_common::static_cell! {
static BINASCII_ERROR: PyTypeRef;
}
Expand All @@ -66,7 +66,7 @@ mod decl {
}

#[pyattr(name = "Incomplete")]
fn get_binascii_incomplete(vm: &VirtualMachine) -> PyTypeRef {
fn incomplete_type(vm: &VirtualMachine) -> PyTypeRef {
rustpython_common::static_cell! {
static BINASCII_INCOMPLTE: PyTypeRef;
}
Expand Down
6 changes: 3 additions & 3 deletions stdlib/src/keyword.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// Testing if a string is a keyword.
pub(crate) use decl::make_module;
pub(crate) use keyword::make_module;

#[pymodule(name = "keyword")]
mod decl {
#[pymodule]
mod keyword {
use crate::vm::{builtins::PyStr, PyObjectRef, VirtualMachine};
use itertools::Itertools;
use rustpython_parser::lexer;
Expand Down
21 changes: 10 additions & 11 deletions stdlib/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ mod math {
};
use num_bigint::BigInt;
use num_traits::{One, Signed, Zero};
use puruspe::{erf, erfc, gamma, ln_gamma};
use rustpython_common::float_ops;
use std::cmp::Ordering;

Expand Down Expand Up @@ -367,31 +366,31 @@ mod math {
}

// Special functions:
#[pyfunction(name = "erf")]
fn py_erf(x: IntoPyFloat) -> f64 {
#[pyfunction]
fn erf(x: IntoPyFloat) -> f64 {
let x = x.to_f64();
if x.is_nan() {
x
} else {
erf(x)
puruspe::erf(x)
}
}

#[pyfunction(name = "erfc")]
fn py_erfc(x: IntoPyFloat) -> f64 {
#[pyfunction]
fn erfc(x: IntoPyFloat) -> f64 {
let x = x.to_f64();
if x.is_nan() {
x
} else {
erfc(x)
puruspe::erfc(x)
}
}

#[pyfunction(name = "gamma")]
fn py_gamma(x: IntoPyFloat) -> f64 {
#[pyfunction]
fn gamma(x: IntoPyFloat) -> f64 {
let x = x.to_f64();
if x.is_finite() {
gamma(x)
puruspe::gamma(x)
} else if x.is_nan() || x.is_sign_positive() {
x
} else {
Expand All @@ -403,7 +402,7 @@ mod math {
fn lgamma(x: IntoPyFloat) -> f64 {
let x = x.to_f64();
if x.is_finite() {
ln_gamma(x)
puruspe::ln_gamma(x)
} else if x.is_nan() {
x
} else {
Expand Down
4 changes: 2 additions & 2 deletions stdlib/src/termios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ mod termios {

fn termios_error(err: std::io::Error, vm: &VirtualMachine) -> PyBaseExceptionRef {
vm.new_exception(
get_termios_error(vm),
error_type(vm),
vec![
err.raw_os_error().into_pyobject(vm),
vm.ctx.new_utf8_str(err.to_string()),
Expand All @@ -105,7 +105,7 @@ mod termios {
}

#[pyattr(name = "error")]
fn get_termios_error(vm: &VirtualMachine) -> PyTypeRef {
fn error_type(vm: &VirtualMachine) -> PyTypeRef {
rustpython_common::static_cell! {
static TERMIOS_ERROR: PyTypeRef;
}
Expand Down
6 changes: 3 additions & 3 deletions stdlib/src/zlib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub(crate) use decl::make_module;
pub(crate) use zlib::make_module;

#[pymodule(name = "zlib")]
mod decl {
#[pymodule]
mod zlib {
use crate::common::lock::PyMutex;
use crate::vm::{
builtins::{PyBaseExceptionRef, PyBytes, PyBytesRef, PyIntRef, PyTypeRef},
Expand Down
16 changes: 8 additions & 8 deletions vm/src/builtins/traceback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ impl PyTraceback {
}
}

#[pyproperty(name = "tb_frame")]
fn frame(&self) -> FrameRef {
#[pyproperty]
fn tb_frame(&self) -> FrameRef {
self.frame.clone()
}

#[pyproperty(name = "tb_lasti")]
fn lasti(&self) -> u32 {
#[pyproperty]
fn tb_lasti(&self) -> u32 {
self.lasti
}

#[pyproperty(name = "tb_lineno")]
fn lineno(&self) -> usize {
#[pyproperty]
fn tb_lineno(&self) -> usize {
self.lineno
}

#[pyproperty(name = "tb_next")]
fn next_get(&self) -> Option<PyRef<Self>> {
#[pyproperty]
fn tb_next(&self) -> Option<PyRef<Self>> {
self.next.as_ref().cloned()
}
}
Expand Down
6 changes: 3 additions & 3 deletions vm/src/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ impl PyBaseException {
self.traceback.read().clone()
}

#[pyproperty(name = "__traceback__", setter)]
#[pyproperty(magic, setter)]
pub fn set_traceback(&self, traceback: Option<PyTracebackRef>) {
*self.traceback.write() = traceback;
}
Expand All @@ -464,7 +464,7 @@ impl PyBaseException {
self.cause.read().clone()
}

#[pyproperty(name = "__cause__", setter)]
#[pyproperty(magic, setter)]
pub fn set_cause(&self, cause: Option<PyRef<Self>>) {
let mut c = self.cause.write();
self.set_suppress_context(true);
Expand All @@ -476,7 +476,7 @@ impl PyBaseException {
self.context.read().clone()
}

#[pyproperty(name = "__context__", setter)]
#[pyproperty(magic, setter)]
pub fn set_context(&self, context: Option<PyRef<Self>>) {
*self.context.write() = context;
}
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod _collections {
PyDeque::default().into_pyresult_with_type(vm, cls)
}

#[pymethod(name = "__init__")]
#[pymethod(magic)]
fn init(
zelf: PyRef<Self>,
PyDequeOptions { iterable, maxlen }: PyDequeOptions,
Expand Down
4 changes: 2 additions & 2 deletions vm/src/stdlib/pystruct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ pub(crate) mod _struct {
fn _clearcache() {}

#[pyattr(name = "error")]
fn struct_error(vm: &VirtualMachine) -> PyTypeRef {
fn error_type(vm: &VirtualMachine) -> PyTypeRef {
rustpython_common::static_cell! {
static STRUCT_ERROR: PyTypeRef;
}
Expand All @@ -965,7 +965,7 @@ pub(crate) mod _struct {
fn new_struct_error(vm: &VirtualMachine, msg: String) -> PyBaseExceptionRef {
// can't just STRUCT_ERROR.get().unwrap() cause this could be called before from buffer
// machinery, independent of whether _struct was ever imported
vm.new_exception_msg(struct_error(vm), msg)
vm.new_exception_msg(error_type(vm), msg)
}
}

Expand Down
6 changes: 3 additions & 3 deletions vm/src/stdlib/symtable.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub(crate) use decl::make_module;
pub(crate) use symtable::make_module;

#[pymodule(name = "symtable")]
mod decl {
#[pymodule]
mod symtable {
use crate::{
builtins::PyStrRef,
compile::{self, Symbol, SymbolScope, SymbolTable, SymbolTableType},
Expand Down