From 06074e1e02249a366b314acb3938022f82f116a0 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 6 Feb 2017 11:41:11 -0800 Subject: [PATCH] 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). --- stdlib/3.4/asyncio/__init__.pyi | 6 ++++++ stdlib/3.4/asyncio/streams.pyi | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/stdlib/3.4/asyncio/__init__.pyi b/stdlib/3.4/asyncio/__init__.pyi index 3f88dac01..2364ff6cf 100644 --- a/stdlib/3.4/asyncio/__init__.pyi +++ b/stdlib/3.4/asyncio/__init__.pyi @@ -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. diff --git a/stdlib/3.4/asyncio/streams.pyi b/stdlib/3.4/asyncio/streams.pyi index 21f468bd0..fd677ab75 100644 --- a/stdlib/3.4/asyncio/streams.pyi +++ b/stdlib/3.4/asyncio/streams.pyi @@ -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 = ...,