Issue 32562: Support fspath protocol in AF_UNIX sockaddr resolution (original) (raw)

In 3.6, trying to connect to a AF_UNIX socket using a pathlib.Path object doesn't work:

Python 3.6.4 (default, Dec 27 2017, 13:02:49) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

import socket, pathlib s = socket.socket(family=socket.AF_UNIX) s.connect(pathlib.Path("asdf")) Traceback (most recent call last): File "", line 1, in TypeError: a bytes-like object is required, not 'PosixPath'

It would be good to fix this to use the fspath protocol.