Skip to content

Commit a9e7618

Browse files
committed
gh-148783: Respect caller-specified socket proto
1 parent 8276778 commit a9e7618

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix :class:`socket.socket` to respect caller-specified proto over
2+
auto-detection, which is not supported on platforms such as macOS.

Modules/socketmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5746,8 +5746,8 @@ sock_initobj_impl(PySocketSockObject *self, int family, int type, int proto,
57465746
#else
57475747
type = SOCK_STREAM;
57485748
#endif
5749-
#ifdef SO_PROTOCOL
57505749
if (proto == -1) {
5750+
#ifdef SO_PROTOCOL
57515751
int tmp;
57525752
socklen_t slen = sizeof(tmp);
57535753
if (getsockopt(fd, SOL_SOCKET, SO_PROTOCOL,
@@ -5758,10 +5758,10 @@ sock_initobj_impl(PySocketSockObject *self, int family, int type, int proto,
57585758
set_error();
57595759
return -1;
57605760
}
5761-
}
57625761
#else
57635762
proto = 0;
57645763
#endif
5764+
}
57655765
}
57665766
}
57675767
else {

0 commit comments

Comments
 (0)