mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Merge 3.5 (issue #28399)
This commit is contained in:
commit
88e8aca78d
3 changed files with 21 additions and 5 deletions
|
@ -258,6 +258,17 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
|
||||||
|
|
||||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
|
|
||||||
|
# Check for abstract socket. `str` and `bytes` paths are supported.
|
||||||
|
if path[0] not in (0, '\x00'):
|
||||||
|
try:
|
||||||
|
if stat.S_ISSOCK(os.stat(path).st_mode):
|
||||||
|
os.remove(path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
except OSError as err:
|
||||||
|
# Directory may have permissions only to create socket.
|
||||||
|
logger.error('Unable to check or remove stale UNIX socket %r: %r', path, err)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sock.bind(path)
|
sock.bind(path)
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
|
|
|
@ -241,11 +241,13 @@ class SelectorEventLoopUnixSocketTests(test_utils.TestCase):
|
||||||
with test_utils.unix_socket_path() as path:
|
with test_utils.unix_socket_path() as path:
|
||||||
sock = socket.socket(socket.AF_UNIX)
|
sock = socket.socket(socket.AF_UNIX)
|
||||||
sock.bind(path)
|
sock.bind(path)
|
||||||
with sock:
|
sock.listen(1)
|
||||||
|
sock.close()
|
||||||
|
|
||||||
coro = self.loop.create_unix_server(lambda: None, path)
|
coro = self.loop.create_unix_server(lambda: None, path)
|
||||||
with self.assertRaisesRegex(OSError,
|
srv = self.loop.run_until_complete(coro)
|
||||||
'Address.*is already in use'):
|
srv.close()
|
||||||
self.loop.run_until_complete(coro)
|
self.loop.run_until_complete(srv.wait_closed())
|
||||||
|
|
||||||
def test_create_unix_server_existing_path_nonsock(self):
|
def test_create_unix_server_existing_path_nonsock(self):
|
||||||
with tempfile.NamedTemporaryFile() as file:
|
with tempfile.NamedTemporaryFile() as file:
|
||||||
|
|
|
@ -216,6 +216,9 @@ Library
|
||||||
|
|
||||||
- Issue #28372: Fix asyncio to support formatting of non-python coroutines.
|
- Issue #28372: Fix asyncio to support formatting of non-python coroutines.
|
||||||
|
|
||||||
|
- Issue #28399: Remove UNIX socket from FS before binding.
|
||||||
|
Patch by Коренберг Марк.
|
||||||
|
|
||||||
Windows
|
Windows
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue