11use super :: code:: PyCodeRef ;
2- use super :: pytype:: { self , PyTypeRef } ;
2+ use super :: pytype:: PyTypeRef ;
33use crate :: coroutine:: { Coro , Variant } ;
44use crate :: exceptions:: PyBaseExceptionRef ;
55use crate :: frame:: FrameRef ;
66use crate :: function:: OptionalArg ;
7- use crate :: pyobject:: { PyClassImpl , PyContext , PyObjectRef , PyRef , PyResult , PyValue } ;
7+ use crate :: pyobject:: {
8+ PyClassImpl , PyContext , PyObjectRef , PyRef , PyResult , PyValue , TypeProtocol ,
9+ } ;
810use crate :: vm:: VirtualMachine ;
911
1012use crossbeam_utils:: atomic:: AtomicCell ;
@@ -15,7 +17,7 @@ pub struct PyAsyncGen {
1517 inner : Coro ,
1618 running_async : AtomicCell < bool > ,
1719}
18- pub type PyAsyncGenRef = PyRef < PyAsyncGen > ;
20+ type PyAsyncGenRef = PyRef < PyAsyncGen > ;
1921
2022impl PyValue for PyAsyncGen {
2123 fn class ( vm : & VirtualMachine ) -> PyTypeRef {
@@ -29,7 +31,7 @@ impl PyAsyncGen {
2931 & self . inner
3032 }
3133
32- pub fn new ( frame : FrameRef , vm : & VirtualMachine ) -> PyAsyncGenRef {
34+ pub fn new ( frame : FrameRef , vm : & VirtualMachine ) -> PyRef < Self > {
3335 PyAsyncGen {
3436 inner : Coro :: new ( frame, Variant :: AsyncGen ) ,
3537 running_async : AtomicCell :: new ( false ) ,
@@ -127,8 +129,8 @@ impl PyAsyncGenWrappedValue {}
127129impl PyAsyncGenWrappedValue {
128130 fn unbox ( ag : & PyAsyncGen , val : PyResult , vm : & VirtualMachine ) -> PyResult {
129131 if let Err ( ref e) = val {
130- if pytype :: isinstance ( & e , & vm. ctx . exceptions . stop_async_iteration )
131- || pytype :: isinstance ( & e , & vm. ctx . exceptions . generator_exit )
132+ if e . isinstance ( & vm. ctx . exceptions . stop_async_iteration )
133+ || e . isinstance ( & vm. ctx . exceptions . generator_exit )
132134 {
133135 ag. inner . closed . store ( true ) ;
134136 }
@@ -385,8 +387,8 @@ impl PyAsyncGenAThrow {
385387 self . ag . running_async . store ( false ) ;
386388 self . state . store ( AwaitableState :: Closed ) ;
387389 if self . aclose
388- && ( pytype :: isinstance ( & exc , & vm. ctx . exceptions . stop_async_iteration )
389- || pytype :: isinstance ( & exc , & vm. ctx . exceptions . generator_exit ) )
390+ && ( exc . isinstance ( & vm. ctx . exceptions . stop_async_iteration )
391+ || exc . isinstance ( & vm. ctx . exceptions . generator_exit ) )
390392 {
391393 vm. new_exception_empty ( vm. ctx . exceptions . stop_iteration . clone ( ) )
392394 } else {
0 commit comments