8000 Rectify mock socket setup for Windows; add news entry · python/cpython@5097ec0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5097ec0

Browse files
author
Ross Rhodes
committed
Rectify mock socket setup for Windows; add news entry
1 parent b09e617 commit 5097ec0

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

Lib/smtplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ def __init__(self, host='', port=LMTP_PORT, local_hostname=None,
10701070
"""Initialize a new instance."""
10711071
super().__init__(host, port, local_hostname=local_hostname,
10721072
source_address=source_address, timeout=timeout)
1073-
1073+
10741074
def connect(self, host='localhost', port=0, source_address=None):
10751075
"""Connect to the LMTP daemon, on either a Unix or a TCP socket."""
10761076
if host[0] != '/':

Lib/test/mock_socket.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ def getaddrinfo(*args, **kw):
155155
_GLOBAL_DEFAULT_TIMEOUT = socket_module._GLOBAL_DEFAULT_TIMEOUT
156156
AF_INET = socket_module.AF_INET
157157
AF_INET6 = socket_module.AF_INET6
158-
AF_UNIX = socket_module.AF_UNIX
159158
SOCK_STREAM = socket_module.SOCK_STREAM
160159
SOL_SOCKET = None
161160
SO_REUSEADDR = None
161+
162+
if hasattr(socket_module, 'AF_UNIX'):
163+
AF_UNIX = socket_module.AF_UNIX

Lib/test/test_smtplib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ class LMTPGeneralTests(GeneralTests, unittest.TestCase):
165165

166166
client = smtplib.LMTP
167167

168-
def testTimeoutDefault(self):
169-
super().testTimeoutDefault()
168+
def testUnixDomainSocketTimeoutDefault(self):
169+
if not hasattr(socket, "AF_UNIX"):
170+
self.skipTest("requires Unix domain socket")
171+
170172
local_host = '/some/local/lmtp/delivery/program'
171173
mock_socket.reply_with(b"220 Hello world")
172174

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Configure LMTP Unix-domain socket to use socket global default timeout when
2+
a timeout is not explicitly provided.

0 commit comments

Comments
 (0)
0