mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
asyncio: Add asyncio.compat module
Move compatibility helpers for the different Python versions to a new asyncio.compat module.
This commit is contained in:
parent
f05b79dbd2
commit
71080fc351
8 changed files with 35 additions and 30 deletions
|
@ -17,12 +17,11 @@ import sys
|
|||
import threading
|
||||
import traceback
|
||||
|
||||
|
||||
_PY34 = sys.version_info >= (3, 4)
|
||||
from asyncio import compat
|
||||
|
||||
|
||||
def _get_function_source(func):
|
||||
if _PY34:
|
||||
if compat.PY34:
|
||||
func = inspect.unwrap(func)
|
||||
elif hasattr(func, '__wrapped__'):
|
||||
func = func.__wrapped__
|
||||
|
@ -31,7 +30,7 @@ def _get_function_source(func):
|
|||
return (code.co_filename, code.co_firstlineno)
|
||||
if isinstance(func, functools.partial):
|
||||
return _get_function_source(func.func)
|
||||
if _PY34 and isinstance(func, functools.partialmethod):
|
||||
if compat.PY34 and isinstance(func, functools.partialmethod):
|
||||
return _get_function_source(func.func)
|
||||
return None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue