Skip to content

Commit 92cb58b

Browse files
committed
Remove _vm parameter - remove unused functions
1 parent 6ddb690 commit 92cb58b

File tree

2 files changed

+11
-43
lines changed

2 files changed

+11
-43
lines changed

vm/src/exceptions.rs

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ impl PyBaseException {
6767
Ok(())
6868
}
6969

70-
#[pyproperty(name = "args")]
71-
fn get_args(&self) -> PyTupleRef {
70+
#[pyproperty]
71+
pub fn args(&self) -> PyTupleRef {
7272
self.args.borrow().clone()
7373
}
7474

@@ -80,7 +80,7 @@ impl PyBaseException {
8080
}
8181

8282
#[pyproperty(name = "__traceback__")]
83-
fn get_traceback(&self) -> Option<PyTracebackRef> {
83+
pub fn traceback(&self) -> Option<PyTracebackRef> {
8484
self.traceback.borrow().clone()
8585
}
8686

@@ -90,25 +90,23 @@ impl PyBaseException {
9090
}
9191

9292
#[pyproperty(name = "__cause__")]
93-
fn get_cause(&self) -> Option<PyBaseExceptionRef> {
93+
pub fn cause(&self) -> Option<PyBaseExceptionRef> {
9494
self.cause.borrow().clone()
9595
}
9696

9797
#[pyproperty(name = "__cause__", setter)]
98-
fn setter_cause(&self, cause: Option<PyBaseExceptionRef>) -> PyResult<()> {
98+
pub fn set_cause(&self, cause: Option<PyBaseExceptionRef>) {
9999
self.cause.replace(cause);
100-
Ok(())
101100
}
102101

103102
#[pyproperty(name = "__context__")]
104-
fn get_context(&self) -> Option<PyBaseExceptionRef> {
103+
pub fn context(&self) -> Option<PyBaseExceptionRef> {
105104
self.context.borrow().clone()
106105
}
107106

108107
#[pyproperty(name = "__context__", setter)]
109-
fn setter_context(&self, context: Option<PyBaseExceptionRef>) -> PyResult<()> {
108+
pub fn set_context(&self, context: Option<PyBaseExceptionRef>) {
110109
self.context.replace(context);
111-
Ok(())
112110
}
113111

114112
#[pyproperty(name = "__suppress_context__")]
@@ -146,28 +144,6 @@ impl PyBaseException {
146144
Err(i) => format!("{}({})", cls.name, i.format(", ")),
147145
}
148146
}
149-
150-
pub fn args(&self) -> PyTupleRef {
151-
self.args.borrow().clone()
152-
}
153-
154-
pub fn traceback(&self) -> Option<PyTracebackRef> {
155-
self.traceback.borrow().clone()
156-
}
157-
158-
pub fn cause(&self) -> Option<PyBaseExceptionRef> {
159-
self.cause.borrow().clone()
160-
}
161-
pub fn set_cause(&self, cause: Option<PyBaseExceptionRef>) {
162-
self.cause.replace(cause);
163-
}
164-
165-
pub fn context(&self) -> Option<PyBaseExceptionRef> {
166-
self.context.borrow().clone()
167-
}
168-
pub fn set_context(&self, context: Option<PyBaseExceptionRef>) {
169-
self.context.replace(context);
170-
}
171147
}
172148

173149
/// Print exception chain

vm/src/stdlib/socket.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -445,14 +445,6 @@ fn socket_inet_ntoa(packed_ip: PyBytesRef, vm: &VirtualMachine) -> PyResult {
445445
Ok(vm.new_str(Ipv4Addr::from(ip_num).to_string()))
446446
}
447447

448-
fn socket_hton<U: num_traits::int::PrimInt>(host: U) -> U {
449-
U::to_be(host)
450-
}
451-
452-
fn socket_ntoh<U: num_traits::int::PrimInt>(network: U) -> U {
453-
U::from_be(network)
454-
}
455-
456448
#[derive(FromArgs)]
457449
struct GAIOptions {
458450
#[pyarg(positional_only)]
@@ -618,10 +610,10 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
618610
"inet_aton" => ctx.new_function(socket_inet_aton),
619611
"inet_ntoa" => ctx.new_function(socket_inet_ntoa),
620612
"gethostname" => ctx.new_function(socket_gethostname),
621-
"htonl" => ctx.new_function(socket_hton::<u32>),
622-
"htons" => ctx.new_function(socket_hton::<u16>),
623-
"ntohl" => ctx.new_function(socket_ntoh::<u32>),
624-
"ntohs" => ctx.new_function(socket_ntoh::<u16>),
613+
"htonl" => ctx.new_function(u32::to_be),
614+
"htons" => ctx.new_function(u16::to_be),
615+
"ntohl" => ctx.new_function(u32::from_be),
616+
"ntohs" => ctx.new_function(u16::from_be),
625617
"getdefaulttimeout" => ctx.new_function(|vm: &VirtualMachine| vm.get_none()),
626618
"has_ipv6" => ctx.new_bool(false),
627619
// constants

0 commit comments

Comments
 (0)