[New-bugs-announce] [issue5421] Irritating error message by socket's sendto method

Manuel Hermann report at bugs.python.org
Thu Mar 5 11:15:03 CET 2009


New submission from Manuel Hermann <manuel-hermann at gmx.net>:

When sending unexpected data via a socket's sentdo method, a TypeError
is raised with the fallowing message: "sendto() takes exactly 3
arguments (2 given)". But two arguments are sufficient.

Examples for Python 2.x:
import socket
my_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# this will succeed
my_socket.sendto("Foobar", ("localhost", 514))

# these will fail with above error message
my_socket.sendto(u"Umlaut ä", ("localhost", 514))
my_socket.sendto(1, ("localhost", 514))


Examples for Python 3:
import socket
my_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# this will succeed
my_socket.sendto("No Umlaut".encode("ascii"), ("localhost", 514))

# these will fail with above error message
my_socket.sendto("No Umlaut", ("localhost", 514))
my_socket.sendto(1, ("localhost", 514))

----------
components: Library (Lib)
messages: 83187
nosy: helduel
severity: normal
status: open
title: Irritating error message by socket's sendto method
versions: Python 2.4, Python 2.5, Python 2.6, Python 3.0

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


More information about the New-bugs-announce mailing list