File tree Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -811,23 +811,26 @@ able to suspend execution in its *enter* and *exit* methods.
811
811
812
812
The following code::
813
813
814
- async with EXPR as VAR :
815
- BLOCK
814
+ async with expression as target :
815
+ suite
816
816
817
- Is semantically equivalent to::
817
+ is semantically equivalent to::
818
818
819
- mgr = (EXPR)
820
- aexit = type(mgr).__aexit__
821
- aenter = type(mgr).__aenter__(mgr)
819
+ manager = (expression)
820
+ aexit = type(manager).__aexit__
821
+ value = type(manager).__aenter__(manager)
822
+ target = await value
823
+ exception = False
822
824
823
- VAR = await aenter
824
825
try:
825
- BLOCK
826
+ suite
826
827
except:
827
- if not await aexit(mgr, *sys.exc_info()):
828
+ exception = True
829
+ if not await aexit(manager, *sys.exc_info()):
828
830
raise
829
- else:
830
- await aexit(mgr, None, None, None)
831
+ finally:
832
+ if not exception:
833
+ await aexit(manager, None, None, None)
831
834
832
835
See also :meth: `__aenter__ ` and :meth: `__aexit__ ` for details.
833
836
You can’t perform that action at this time.
0 commit comments