expose asyncio.open_unix_connection if it exists (#879)

Also fix the one other place where hasattr() is used (which PEP 484 doesn't support).
This commit is contained in:
Jelle Zijlstra
2017-02-06 11:41:11 -08:00
committed by Guido van Rossum
parent f9d6218ab7
commit 06074e1e02
2 changed files with 8 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
"""The asyncio package, tracking PEP 3156."""
import socket
import sys
from typing import Type
@@ -85,6 +86,11 @@ from asyncio.locks import (
if sys.version_info < (3, 5):
from asyncio.queues import JoinableQueue as JoinableQueue
if sys.platform != 'win32':
from asyncio.streams import (
open_unix_connection as open_unix_connection,
start_unix_server as start_unix_server,
)
# TODO: It should be possible to instantiate these classes, but mypy
# currently disallows this.

View File

@@ -1,4 +1,4 @@
import socket
import sys
from typing import Any, Awaitable, Callable, Generator, Iterable, Optional, Tuple
from . import coroutines
@@ -38,7 +38,7 @@ def start_server(
**kwds: Any
) -> Generator[Any, None, events.AbstractServer]: ...
if hasattr(socket, 'AF_UNIX'):
if sys.platform != 'win32':
@coroutines.coroutine
def open_unix_connection(
path: str = ...,