STINNER Victor [EMAIL PROTECTED] added the comment:
Why not using bytes() instead of bytearray()? Eg. replace
s.send('Hello, world') by s.send(b'Hello, world').
--
nosy: +haypo
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4275
Brad Miller [EMAIL PROTECTED] added the comment:
For the example in unixclient.py using b'Hello World' works fine. But for
the example in the socketserver documentation the strings to convert come
from argv[1:]
On Sat, Nov 8, 2008 at 5:48 AM, STINNER Victor [EMAIL PROTECTED]wrote:
STINNER
Brad Miller [EMAIL PROTECTED] added the comment:
Here's a combined patch that fixes:
Doc/library/socketserver.rst examples tested and working
Demo/sockets/udpecho.py
Demo/sockets/unixclient.py
Added file: http://bugs.python.org/file11967/socketpatches.patch
Benjamin Peterson [EMAIL PROTECTED] added the comment:
Thanks! Fixed in r67168.
--
nosy: +benjamin.peterson
resolution: - fixed
status: open - closed
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4275
Brad Miller [EMAIL PROTECTED] added the comment:
I found a similar problem in the Demo/sockets/unixclient.py code.
from socket import *
FILE = 'unix-socket'
s = socket(AF_UNIX, SOCK_STREAM)
s.connect(FILE)
s.send('Hello, world')
data = s.recv(1024)
s.close()
print('Received', repr(data))
Brad Miller [EMAIL PROTECTED] added the comment:
After looking at the socket documentation pointed to from another issue
it looks like the right solution is to convert to a byte array.
I've attached a patch with fixes for all the examples in
socketserver.rst there were several other problems
New submission from Don MacMillen [EMAIL PROTECTED]:
code examples in socketserver do not run in py3k
Obvious errors with print stmt (not function call)
Less obvious errors with socket.send that does not
accept str type (bytearray works fine). Client example
below shows problems.
import socket