|
1 | 1 | """Utilities for with-statement contexts. See PEP 343.""" |
2 | | -from inspect import isasyncgenfunction, iscoroutinefunction, \ |
3 | | - isgeneratorfunction |
4 | 2 |
|
5 | 3 | import abc |
6 | 4 | import os |
7 | 5 | import sys |
8 | 6 | import _collections_abc |
9 | 7 | from collections import deque |
10 | 8 | from functools import wraps |
| 9 | +from inspect import isasyncgenfunction as _isasyncgenfunction |
| 10 | +from inspect import iscoroutinefunction as _iscoroutinefunction |
| 11 | +from inspect import isgeneratorfunction as _isgeneratorfunction |
11 | 12 | from types import GenericAlias |
12 | 13 |
|
13 | 14 | __all__ = ["asynccontextmanager", "contextmanager", "closing", "nullcontext", |
@@ -101,11 +102,11 @@ async def asyncgen_inner(*args, **kwds): |
101 | 102 | yield value |
102 | 103 |
|
103 | 104 | wrapper = wraps(func) |
104 | | - if isasyncgenfunction(func): |
| 105 | + if _isasyncgenfunction(func): |
105 | 106 | return wrapper(asyncgen_inner) |
106 | | - elif iscoroutinefunction(func): |
| 107 | + elif _iscoroutinefunction(func): |
107 | 108 | return wrapper(async_inner) |
108 | | - elif isgeneratorfunction(func): |
| 109 | + elif _isgeneratorfunction(func): |
109 | 110 | return wrapper(gen_inner) |
110 | 111 | else: |
111 | 112 | return wrapper(inner) |
@@ -143,11 +144,11 @@ async def asyncgen_inner(*args, **kwds): |
143 | 144 | yield value |
144 | 145 |
|
145 | 146 | wrapper = wraps(func) |
146 | | - if isasyncgenfunction(func): |
| 147 | + if _isasyncgenfunction(func): |
147 | 148 | return wrapper(asyncgen_inner) |
148 | | - elif iscoroutinefunction(func): |
| 149 | + elif _iscoroutinefunction(func): |
149 | 150 | return wrapper(async_inner) |
150 | | - elif isgeneratorfunction(func): |
| 151 | + elif _isgeneratorfunction(func): |
151 | 152 | return wrapper(gen_inner) |
152 | 153 | else: |
153 | 154 | return wrapper(inner) |
|
0 commit comments