File tree Expand file tree Collapse file tree 3 files changed +10
-17
lines changed Expand file tree Collapse file tree 3 files changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -47,14 +47,14 @@ impl SlotConstructor for PyWeakProxy {
47
47
impl PyWeakProxy {
48
48
// TODO: callbacks
49
49
#[ pymethod( magic) ]
50
- fn getattr ( & self , attr_name : PyObjectRef , vm : & VirtualMachine ) -> PyResult {
51
- match self . weak . upgrade ( ) {
52
- Some ( obj) => vm. get_attribute ( obj, attr_name) ,
53
- None => Err ( vm. new_exception_msg (
50
+ fn getattr ( & self , attr_name : PyStrRef , vm : & VirtualMachine ) -> PyResult {
51
+ let obj = self . weak . upgrade ( ) . ok_or_else ( || {
52
+ vm. new_exception_msg (
54
53
vm. ctx . exceptions . reference_error . clone ( ) ,
55
54
"weakly-referenced object no longer exists" . to_owned ( ) ,
56
- ) ) ,
57
- }
55
+ )
56
+ } ) ?;
57
+ vm. get_attribute ( obj, attr_name)
58
58
}
59
59
}
60
60
Original file line number Diff line number Diff line change @@ -626,15 +626,6 @@ impl<T: PyObjectPayload> TryIntoRef<T> for PyRef<T> {
626
626
}
627
627
}
628
628
629
- impl < T > TryIntoRef < T > for PyObjectRef
630
- where
631
- T : PyValue ,
632
- {
633
- fn try_into_ref ( self , vm : & VirtualMachine ) -> PyResult < PyRef < T > > {
634
- TryFromObject :: try_from_object ( vm, self )
635
- }
636
- }
637
-
638
629
/// Implemented by any type that can be created from a Python object.
639
630
///
640
631
/// Any type that implements `TryFromObject` is automatically `FromArgs`, and
Original file line number Diff line number Diff line change @@ -7,9 +7,11 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
7
7
"errorcode" => errorcode. clone( ) ,
8
8
} ) ;
9
9
for ( name, code) in ERROR_CODES {
10
- let name = vm. new_pyobj ( * name) ;
10
+ let name = vm. ctx . new_str ( * name) ;
11
11
let code = vm. new_pyobj ( * code) ;
12
- errorcode. set_item ( code. clone ( ) , name. clone ( ) , vm) . unwrap ( ) ;
12
+ errorcode
13
+ . set_item ( code. clone ( ) , name. clone ( ) . into ( ) , vm)
14
+ . unwrap ( ) ;
13
15
vm. set_attr ( & module, name, code) . unwrap ( ) ;
14
16
}
15
17
module
You can’t perform that action at this time.
0 commit comments