File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -73,9 +73,14 @@ async def inner(*args: Any, **kwargs: Any) -> Any:
73
73
aiter = builtins .aiter
74
74
else :
75
75
76
- async def anext (cls : Any ) -> Any :
76
+ async def anext (cls : Any , default : Any ) -> Any :
77
77
"""Compatibility function until we drop 3.9 support: https://docs.python.org/3/library/functions.html#anext."""
78
- return await cls .__anext__ ()
78
+ try :
79
+ return await cls .__anext__ ()
80
+ except StopAsyncIteration :
81
+ if default :
82
+ return default
83
+ raise
79
84
80
85
def aiter (cls : Any ) -> Any :
81
86
"""Compatibility function until we drop 3.9 support: https://docs.python.org/3/library/functions.html#anext."""
Original file line number Diff line number Diff line change @@ -73,9 +73,14 @@ def inner(*args: Any, **kwargs: Any) -> Any:
73
73
iter = builtins .iter
74
74
else :
75
75
76
- def next (cls : Any ) -> Any :
76
+ def next (cls : Any , default : Any ) -> Any :
77
77
"""Compatibility function until we drop 3.9 support: https://docs.python.org/3/library/functions.html#next."""
78
- return cls .__next__ ()
78
+ try :
79
+ return cls .__next__ ()
80
+ except StopIteration :
81
+ if default :
82
+ return default
83
+ raise
79
84
80
85
def iter (cls : Any ) -> Any :
81
86
"""Compatibility function until we drop 3.9 support: https://docs.python.org/3/library/functions.html#next."""
You can’t perform that action at this time.
0 commit comments