mirror of
https://github.com/python/cpython.git
synced 2025-07-18 16:55:20 +00:00
Backed out changeset c0f2b038fc12
This commit is contained in:
parent
c7c333d25d
commit
b10c71daa2
3 changed files with 7 additions and 10 deletions
|
@ -4451,7 +4451,7 @@ class TestLinuxAbstractNamespace(unittest.TestCase):
|
||||||
UNIX_PATH_MAX = 108
|
UNIX_PATH_MAX = 108
|
||||||
|
|
||||||
def testLinuxAbstractNamespace(self):
|
def testLinuxAbstractNamespace(self):
|
||||||
address = "\x00python-test-hello\x00\xff"
|
address = b"\x00python-test-hello\x00\xff"
|
||||||
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s1:
|
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s1:
|
||||||
s1.bind(address)
|
s1.bind(address)
|
||||||
s1.listen(1)
|
s1.listen(1)
|
||||||
|
@ -4462,7 +4462,7 @@ class TestLinuxAbstractNamespace(unittest.TestCase):
|
||||||
self.assertEqual(s2.getpeername(), address)
|
self.assertEqual(s2.getpeername(), address)
|
||||||
|
|
||||||
def testMaxName(self):
|
def testMaxName(self):
|
||||||
address = "\x00" + "h" * (self.UNIX_PATH_MAX - 1)
|
address = b"\x00" + b"h" * (self.UNIX_PATH_MAX - 1)
|
||||||
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
|
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
|
||||||
s.bind(address)
|
s.bind(address)
|
||||||
self.assertEqual(s.getsockname(), address)
|
self.assertEqual(s.getsockname(), address)
|
||||||
|
@ -4472,12 +4472,12 @@ class TestLinuxAbstractNamespace(unittest.TestCase):
|
||||||
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
|
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
|
||||||
self.assertRaises(OSError, s.bind, address)
|
self.assertRaises(OSError, s.bind, address)
|
||||||
|
|
||||||
def testBytesName(self):
|
def testStrName(self):
|
||||||
# Check that an abstract name can be passed as bytes.
|
# Check that an abstract name can be passed as a string.
|
||||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
try:
|
try:
|
||||||
s.bind(b"\x00python\x00test\x00")
|
s.bind("\x00python\x00test\x00")
|
||||||
self.assertEqual(s.getsockname(), "\x00python\x00test\x00")
|
self.assertEqual(s.getsockname(), b"\x00python\x00test\x00")
|
||||||
finally:
|
finally:
|
||||||
s.close()
|
s.close()
|
||||||
|
|
||||||
|
|
|
@ -99,9 +99,6 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
- Issue #17683: socket module: return AF_UNIX addresses in Linux abstract
|
|
||||||
namespace as string.
|
|
||||||
|
|
||||||
- Issue #17914: Add os.cpu_count(). Patch by Yogesh Chaudhari, based on an
|
- Issue #17914: Add os.cpu_count(). Patch by Yogesh Chaudhari, based on an
|
||||||
initial patch by Trent Nelson.
|
initial patch by Trent Nelson.
|
||||||
|
|
||||||
|
|
|
@ -1018,7 +1018,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
if (a->sun_path[0] == 0) { /* Linux abstract namespace */
|
if (a->sun_path[0] == 0) { /* Linux abstract namespace */
|
||||||
addrlen -= offsetof(struct sockaddr_un, sun_path);
|
addrlen -= offsetof(struct sockaddr_un, sun_path);
|
||||||
return PyUnicode_DecodeFSDefaultAndSize(a->sun_path, addrlen);
|
return PyBytes_FromStringAndSize(a->sun_path, addrlen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* linux */
|
#endif /* linux */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue