bpo-32066: Support pathlib.Path in create_unix_connection; sock arg should be optional (#4447)

diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py
index f2f2e28..e59d3d2 100644
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -362,12 +362,12 @@
         """
         raise NotImplementedError
 
-    def create_unix_connection(self, protocol_factory, path, *,
+    def create_unix_connection(self, protocol_factory, path=None, *,
                                ssl=None, sock=None,
                                server_hostname=None):
         raise NotImplementedError
 
-    def create_unix_server(self, protocol_factory, path, *,
+    def create_unix_server(self, protocol_factory, path=None, *,
                            sock=None, backlog=100, ssl=None):
         """A coroutine which creates a UNIX Domain Socket server.
 
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index bf682a1..be98f33 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -212,7 +212,7 @@
         self.call_soon_threadsafe(transp._process_exited, returncode)
 
     @coroutine
-    def create_unix_connection(self, protocol_factory, path, *,
+    def create_unix_connection(self, protocol_factory, path=None, *,
                                ssl=None, sock=None,
                                server_hostname=None):
         assert server_hostname is None or isinstance(server_hostname, str)
@@ -229,6 +229,7 @@
                 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, 0)
             try:
                 sock.setblocking(False)
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index d558842..fe758ba 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -251,7 +251,6 @@
             srv.close()
             self.loop.run_until_complete(srv.wait_closed())
 
-    @unittest.skipUnless(hasattr(os, 'fspath'), 'no os.fspath')
     def test_create_unix_server_pathlib(self):
         with test_utils.unix_socket_path() as path:
             path = pathlib.Path(path)
@@ -260,6 +259,15 @@
             srv.close()
             self.loop.run_until_complete(srv.wait_closed())
 
+    def test_create_unix_connection_pathlib(self):
+        with test_utils.unix_socket_path() as path:
+            path = pathlib.Path(path)
+            coro = self.loop.create_unix_connection(lambda: None, path)
+            with self.assertRaises(FileNotFoundError):
+                # If pathlib.Path wasn't supported, the exception would be
+                # different.
+                self.loop.run_until_complete(coro)
+
     def test_create_unix_server_existing_path_nonsock(self):
         with tempfile.NamedTemporaryFile() as file:
             coro = self.loop.create_unix_server(lambda: None, file.name)
@@ -319,7 +327,7 @@
     def test_create_unix_connection_path_inetsock(self):
         sock = socket.socket()
         with sock:
-            coro = self.loop.create_unix_connection(lambda: None, path=None,
+            coro = self.loop.create_unix_connection(lambda: None,
                                                     sock=sock)
             with self.assertRaisesRegex(ValueError,
                                         'A UNIX Domain Stream.*was expected'):