From d7c151871e4eb445676fbd18bc5cb31406cccdf6 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Tue, 15 Nov 2016 15:26:34 -0500 Subject: Issue #28704: Fix create_unix_server to support Path-like objects --- Lib/asyncio/unix_events.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Lib/asyncio/unix_events.py') diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index 788a5a09ab..77905344fb 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -39,6 +39,13 @@ def _sighandler_noop(signum, frame): pass +try: + _fspath = os.fspath +except AttributeError: + # Python 3.5 or earlier + _fspath = lambda path: path + + class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): """Unix event loop. @@ -256,6 +263,7 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): raise ValueError( 'path and sock can not be specified at the same time') + path = _fspath(path) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) # Check for abstract socket. `str` and `bytes` paths are supported. -- cgit v1.2.1