[pypy-commit] pypy py3.5: Support bytearrays in unix domain socket names

arigo pypy.commits at gmail.com
Tue Jan 3 11:58:22 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r89340:d1e27385329f
Date: 2017-01-03 17:57 +0100
http://bitbucket.org/pypy/pypy/changeset/d1e27385329f/

Log:	Support bytearrays in unix domain socket names

diff --git a/pypy/module/_socket/interp_socket.py b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -136,6 +136,8 @@
         # Not using space.fsencode_w since Linux allows embedded NULs.
         if space.isinstance_w(w_address, space.w_unicode):
             w_address = space.fsencode(w_address)
+        elif space.isinstance_w(w_address, space.w_bytearray):
+            w_address = space.newbytes(space.charbuf_w(w_address))
         bytelike = space.bytes_w(w_address) # getarg_w('y*', w_address)
         return rsocket.UNIXAddress(bytelike)
     if rsocket.HAS_AF_NETLINK and family == rsocket.AF_NETLINK:
diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -577,7 +577,9 @@
         oldcwd = os.getcwd()
         os.chdir(self.udir)
         try:
-            sockpath = 'app_test_unix_socket_connect'
+          for sockpath in ['app_test_unix_socket_connect',
+                           b'b_app_test_unix_socket_connect',
+                           bytearray(b'ba_app_test_unix_socket_connect')]:
 
             serversock = _socket.socket(_socket.AF_UNIX)
             serversock.bind(sockpath)


More information about the pypy-commit mailing list