-
-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: unix socket bind does not work with a PathLike argument #3041
Labels
Comments
regnarg
added a commit
to regnarg/trio
that referenced
this issue
Jul 31, 2024
You can fix this by doing this: import socket, trio.socket
from pathlib import Path
async def main():
sock = trio.socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
await sock.bind(str(Path('/tmp/x.sock')))
trio.run(main) |
You can fix this by doing this:
I am of course aware of that. But still: (1) it broke my existing code,
(2) it makes for a much less nice API when the caller has to think of
this, (3) the code was clearly meant to accept Path objects, as the
surrounding comments and the call to os.fspath suggest.
|
regnarg
added a commit
to regnarg/trio
that referenced
this issue
Jul 31, 2024
regnarg
added a commit
to regnarg/trio
that referenced
this issue
Jul 31, 2024
regnarg
added a commit
to regnarg/trio
that referenced
this issue
Jul 31, 2024
regnarg
added a commit
to regnarg/trio
that referenced
this issue
Jul 31, 2024
I don't think this passed, or passes, typing? The method is typed as Address: TypeAlias = Union[
str, bytes, Tuple[str, int], Tuple[str, int, int], Tuple[str, int, int, int]
]
async def bind(self, address: Address) -> None:
... and was previously async def bind(self, address: tuple[object, ...] | str | bytes) -> None: But yeah you're totally right that the comment mentions "path-likes", and as such the typing should be updated to include |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
trio.socket.SocketType.bind no longer works with a PathLike (e.g. pathlib.Path) argument.
Simple test program:
Results in:
This bugs seems to have been introduced in cf1f3c745, released in v0.23.0.
The text was updated successfully, but these errors were encountered: