This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2009年03月05日 10:15 by helduel, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue5421.diff | nvetoshkin, 2010年11月18日 22:24 | argument parsing patch agains py3k, no test | review | |
| Messages (9) | |||
|---|---|---|---|
| msg83187 - (view) | Author: Manuel Hermann (helduel) | Date: 2009年03月05日 10:14 | |
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))
|
|||
| msg83228 - (view) | Author: Luk Knapen (lukknapen) | Date: 2009年03月06日 00:01 | |
File $python/lib/python3.0/logging/handlers.py Line 782 : a bytes object is required instead of a string. As a consequence, encoding shall be specified : but which one ? Is : self.socket.sendto(msg, self.address) Should look like : self.socket.sendto(bytes(msg,'ascii'), self.address) |
|||
| msg121496 - (view) | Author: Vetoshkin Nikita (nvetoshkin) | Date: 2010年11月18日 22:24 | |
Here's a patch, which performs argument checking in a way to be able to provide better error message like that:
>>> my_socket.sendto("No Umlaut", ("localhost", 514))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' does not support the buffer interface
|
|||
| msg131279 - (view) | Author: Vetoshkin Nikita (nvetoshkin) | Date: 2011年03月17日 19:32 | |
ping? |
|||
| msg131284 - (view) | Author: Matt Joiner (anacrolix) | Date: 2011年03月17日 21:27 | |
This bug is very misleading in Py3, as the TypeError makes one think that a string is being passed rather than bytes (how else do you get a 2 argument function call wrong?). Very difficult to determine that this is not in fact the bug in a dynamically typed language :P |
|||
| msg131288 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2011年03月17日 21:46 | |
New changeset c61b72b0650d by Antoine Pitrou in branch '3.1': Issue #5421: Fix misleading error message when one of socket.sendto()'s http://hg.python.org/cpython/rev/c61b72b0650d New changeset 2af7a6d765fd by Antoine Pitrou in branch '3.2': Issue #5421: merge fix http://hg.python.org/cpython/rev/2af7a6d765fd New changeset 90cdc371a3b8 by Antoine Pitrou in branch 'default': Issue #5421: merge fix http://hg.python.org/cpython/rev/90cdc371a3b8 |
|||
| msg131289 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年03月17日 21:47 | |
Thank you for the patch! This is now fixed in 3.x. |
|||
| msg135478 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2011年05月07日 16:51 | |
New changeset 9222c9d747c1 by Ezio Melotti in branch '3.1': #5421: add tests. http://hg.python.org/cpython/rev/9222c9d747c1 New changeset 4b3352b49483 by Ezio Melotti in branch '3.2': #5421: merge with 3.1. http://hg.python.org/cpython/rev/4b3352b49483 New changeset 20273f2195ba by Ezio Melotti in branch 'default': #5421: merge with 3.2. http://hg.python.org/cpython/rev/20273f2195ba |
|||
| msg135482 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2011年05月07日 16:55 | |
I backported the patch to 2.7 in 7c3a20b5943a, and added tests to the 3.x branches. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:46 | admin | set | github: 49671 |
| 2011年05月07日 16:55:35 | ezio.melotti | set | nosy:
+ ezio.melotti messages: + msg135482 |
| 2011年05月07日 16:51:57 | python-dev | set | messages: + msg135478 |
| 2011年03月17日 21:47:59 | pitrou | set | status: open -> closed versions: + Python 3.2, Python 3.3 nosy: + pitrou messages: + msg131289 resolution: fixed stage: needs patch -> resolved |
| 2011年03月17日 21:46:56 | python-dev | set | nosy:
+ python-dev messages: + msg131288 |
| 2011年03月17日 21:27:54 | anacrolix | set | nosy:
helduel, lukknapen, anacrolix, nvetoshkin messages: + msg131284 |
| 2011年03月17日 19:32:54 | nvetoshkin | set | nosy:
helduel, lukknapen, anacrolix, nvetoshkin messages: + msg131279 |
| 2011年02月25日 18:14:25 | anacrolix | set | nosy:
+ anacrolix |
| 2010年11月18日 22:24:40 | nvetoshkin | set | files:
+ issue5421.diff nosy: + nvetoshkin messages: + msg121496 keywords: + patch |
| 2009年03月06日 00:01:49 | lukknapen | set | nosy:
+ lukknapen messages: + msg83228 versions: + Python 3.1, - Python 2.6, Python 2.5, Python 2.4, Python 3.0 |
| 2009年03月05日 21:31:16 | benjamin.peterson | set | type: behavior stage: needs patch |
| 2009年03月05日 10:15:02 | helduel | create | |