classification
Title: Don't refer to getsockaddrarg in error messages
Type: enhancement Stage:
Components: Extension Modules Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Oren Milman, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-03-17 06:43 by serhiy.storchaka, last changed 2017-03-17 20:50 by Oren Milman.

Pull Requests
URL Status Linked Edit
PR 687 serhiy.storchaka, 2017-03-17 06:43
Messages (2)
msg289745 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-17 06:43
getsockaddrarg() is an internal C function in the socket module implementation used in a number of socket methods (bind(), connect(), connect_ex(), sendto(), sendmsg()) for creating C structure sock_addr_t from Python tuple. Error messages raised when pass incorrect socket address argument to these function contain the name "getsockaddrarg" despite the fact that it is not directly exposed at Python level, nor the name of standard C function.

>>> import socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.bind(42)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: getsockaddrarg: AF_INET address must be tuple, not int
>>> s.bind(())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: getsockaddrarg() takes exactly 2 arguments (0 given)

I think that error messages shouldn't refer to non-existing function "getsockaddrarg()".

This issue is a part of more general issue28261.
msg289784 - (view) Author: Oren Milman (Oren Milman) * Date: 2017-03-17 20:50
note that #15988 also left 3 changes for this issue to fix, as can be
seen by searching for '29832' in the comments of PR 668.

for example, this issue should also fix the following inconsistent
error messages:
>>> socket.socket(family=socket.AF_INET6).bind(('::1', -1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: getsockaddrarg: port must be 0-65535.
>>> socket.socket(family=socket.AF_INET6).bind(('::1', -1 << 1000))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C long
History
Date User Action Args
2017-03-17 20:50:11Oren Milmansetmessages: + msg289784
2017-03-17 06:43:50serhiy.storchakasetpull_requests: + pull_request564
2017-03-17 06:43:17serhiy.storchakacreate