[New-bugs-announce] [issue4275] socketserver example code not correctly ported to py3k

Don MacMillen report at bugs.python.org
Fri Nov 7 04:29:48 CET 2008


New submission from Don MacMillen <don at macmillen.net>:

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
import sys

HOST, PORT = "localhost", 9999
data = " ".join(sys.argv[1:])

# Create a socket (SOCK_STREAM means a TCP socket)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Connect to server and send data
sock.connect((HOST, PORT))
sock.send(data + "\n")

# Receive data from the server and shut down
received = sock.recv(1024)
sock.close()

print "Sent:     %s" % data
print "Received: %s" % received

----------
messages: 75595
nosy: macd
severity: normal
status: open
title: socketserver example code not correctly ported to py3k
versions: Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4275>
_______________________________________


More information about the New-bugs-announce mailing list