Skip to content

Commit b10c71d

Browse files
committed
Backed out changeset c0f2b038fc12
1 parent c7c333d commit b10c71d

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

‎Lib/test/test_socket.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4451,7 +4451,7 @@ class TestLinuxAbstractNamespace(unittest.TestCase):
44514451
UNIX_PATH_MAX = 108
44524452

44534453
def testLinuxAbstractNamespace(self):
4454-
address = "\x00python-test-hello\x00\xff"
4454+
address = b"\x00python-test-hello\x00\xff"
44554455
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s1:
44564456
s1.bind(address)
44574457
s1.listen(1)
@@ -4462,7 +4462,7 @@ def testLinuxAbstractNamespace(self):
44624462
self.assertEqual(s2.getpeername(), address)
44634463

44644464
def testMaxName(self):
4465-
address = "\x00" + "h" * (self.UNIX_PATH_MAX - 1)
4465+
address = b"\x00" + b"h" * (self.UNIX_PATH_MAX - 1)
44664466
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
44674467
s.bind(address)
44684468
self.assertEqual(s.getsockname(), address)
@@ -4472,12 +4472,12 @@ def testNameOverflow(self):
44724472
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
44734473
self.assertRaises(OSError, s.bind, address)
44744474

4475-
def testBytesName(self):
4476-
# Check that an abstract name can be passed as bytes.
4475+
def testStrName(self):
4476+
# Check that an abstract name can be passed as a string.
44774477
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
44784478
try:
4479-
s.bind(b"\x00python\x00test\x00")
4480-
self.assertEqual(s.getsockname(), "\x00python\x00test\x00")
4479+
s.bind("\x00python\x00test\x00")
4480+
self.assertEqual(s.getsockname(), b"\x00python\x00test\x00")
44814481
finally:
44824482
s.close()
44834483

‎Misc/NEWS‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ Core and Builtins
9999
Library
100100
-------
101101

102-
- Issue #17683: socket module: return AF_UNIX addresses in Linux abstract
103-
namespace as string.
104-
105102
- Issue #17914: Add os.cpu_count(). Patch by Yogesh Chaudhari, based on an
106103
initial patch by Trent Nelson.
107104

‎Modules/socketmodule.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
10181018
#ifdef linux
10191019
if (a->sun_path[0] == 0) { /* Linux abstract namespace */
10201020
addrlen -= offsetof(struct sockaddr_un, sun_path);
1021-
return PyUnicode_DecodeFSDefaultAndSize(a->sun_path, addrlen);
1021+
return PyBytes_FromStringAndSize(a->sun_path, addrlen);
10221022
}
10231023
else
10241024
#endif /* linux */

0 commit comments

Comments
 (0)