File tree Expand file tree Collapse file tree 3 files changed +11
-13
lines changed Expand file tree Collapse file tree 3 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -155,10 +155,7 @@ impl PyAsyncGenWrappedValue {
155
155
match_class ! ( match val {
156
156
val @ Self => {
157
157
ag. running_async. store( false ) ;
158
- Err ( vm. new_exception(
159
- vm. ctx. exceptions. stop_iteration. clone( ) ,
160
- vec![ val. 0 . clone( ) ] ,
161
- ) )
158
+ Err ( vm. new_stop_iteration( Some ( val. 0 . clone( ) ) ) )
162
159
}
163
160
val => Ok ( val) ,
164
161
} )
@@ -307,7 +304,7 @@ impl PyAsyncGenAThrow {
307
304
}
308
305
if self . ag . inner . closed ( ) {
309
306
self . state . store ( AwaitableState :: Closed ) ;
310
- return Err ( vm. new_exception_empty ( vm . ctx . exceptions . stop_iteration . clone ( ) ) ) ;
307
+ return Err ( vm. new_stop_iteration ( None ) ) ;
311
308
}
312
309
if !vm. is_none ( & val) {
313
310
return Err ( vm. new_runtime_error (
@@ -398,7 +395,7 @@ impl PyAsyncGenAThrow {
398
395
&& ( exc. isinstance ( & vm. ctx . exceptions . stop_async_iteration )
399
396
|| exc. isinstance ( & vm. ctx . exceptions . generator_exit ) )
400
397
{
401
- vm. new_exception_empty ( vm . ctx . exceptions . stop_iteration . clone ( ) )
398
+ vm. new_stop_iteration ( None )
402
399
} else {
403
400
exc
404
401
}
Original file line number Diff line number Diff line change @@ -166,10 +166,7 @@ impl IntoPyResult for PyIterReturn {
166
166
fn into_pyresult ( self , vm : & VirtualMachine ) -> PyResult {
167
167
match self {
168
168
Self :: Return ( obj) => Ok ( obj) ,
169
- Self :: StopIteration ( v) => Err ( {
170
- let args = if let Some ( v) = v { vec ! [ v] } else { Vec :: new ( ) } ;
171
- vm. new_exception ( vm. ctx . exceptions . stop_iteration . clone ( ) , args)
172
- } ) ,
169
+ Self :: StopIteration ( v) => Err ( vm. new_stop_iteration ( v) ) ,
173
170
}
174
171
}
175
172
}
Original file line number Diff line number Diff line change @@ -800,9 +800,13 @@ impl VirtualMachine {
800
800
self . new_exception_msg ( memory_error_type, msg)
801
801
}
802
802
803
- pub fn new_stop_iteration ( & self ) -> PyBaseExceptionRef {
804
- let stop_iteration_type = self . ctx . exceptions . stop_iteration . clone ( ) ;
805
- self . new_exception_empty ( stop_iteration_type)
803
+ pub fn new_stop_iteration ( & self , value : Option < PyObjectRef > ) -> PyBaseExceptionRef {
804
+ let args = if let Some ( value) = value {
805
+ vec ! [ value]
806
+ } else {
807
+ Vec :: new ( )
808
+ } ;
809
+ self . new_exception ( self . ctx . exceptions . stop_iteration . clone ( ) , args)
806
810
}
807
811
808
812
#[ track_caller]
You can’t perform that action at this time.
0 commit comments