File tree 4 files changed +17
-1
lines changed
4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
16
16
17
17
* Implemented ` IntoIterator ` for ` PySet ` and ` PyFrozenSet ` . [ #716 ] ( https://github.com/PyO3/pyo3/pull/716 )
18
18
19
+ ### Fixed
20
+
21
+ * Clear error indicator when the exception is handled on the Rust side. [ #719 ] ( https://github.com/PyO3/pyo3/pull/719 )
22
+
19
23
## [ 0.8.5]
20
24
21
25
* Support for ` #[name = "foo"] ` attribute for ` #[pyfunction] ` and in ` #[pymethods] ` . [ #692 ] ( https://github.com/PyO3/pyo3/pull/692 )
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ impl<'p> PyIterator<'p> {
42
42
let ptr = ffi:: PyObject_GetIter ( obj. as_ptr ( ) ) ;
43
43
// Returns NULL if an object cannot be iterated.
44
44
if ptr. is_null ( ) {
45
+ PyErr :: fetch ( py) ;
45
46
return Err ( PyDowncastError ) ;
46
47
}
47
48
Original file line number Diff line number Diff line change @@ -93,7 +93,12 @@ impl PySet {
93
93
94
94
/// Remove and return an arbitrary element from the set
95
95
pub fn pop ( & self ) -> Option < PyObject > {
96
- unsafe { PyObject :: from_owned_ptr_or_opt ( self . py ( ) , ffi:: PySet_Pop ( self . as_ptr ( ) ) ) }
96
+ let element =
97
+ unsafe { PyObject :: from_owned_ptr_or_err ( self . py ( ) , ffi:: PySet_Pop ( self . as_ptr ( ) ) ) } ;
98
+ match element {
99
+ Ok ( e) => Some ( e) ,
100
+ Err ( _) => None ,
101
+ }
97
102
}
98
103
99
104
/// Returns an iterator of values in this set.
@@ -324,6 +329,9 @@ mod test {
324
329
assert ! ( val. is_some( ) ) ;
325
330
let val2 = set. pop ( ) ;
326
331
assert ! ( val2. is_none( ) ) ;
332
+ assert ! ( py
333
+ . eval( "print('Exception state should not be set.')" , None , None )
334
+ . is_ok( ) ) ;
327
335
}
328
336
329
337
#[ test]
Original file line number Diff line number Diff line change @@ -179,4 +179,7 @@ fn incorrect_iter() {
179
179
let int_ref = int. as_ref ( py) ;
180
180
// Should not segfault.
181
181
assert ! ( int_ref. iter( ) . is_err( ) ) ;
182
+ assert ! ( py
183
+ . eval( "print('Exception state should not be set.')" , None , None )
184
+ . is_ok( ) ) ;
182
185
}
You can’t perform that action at this time.
0 commit comments