Title: IP address returned from socket.accept() is unicode
Type: behaviour Severity: minor
Components: Library Versions: 2.5.3b1, 2.5.3b2, 2.5.2, 2.7a1, 2.7a2
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: amak Nosy List: alekstorm, amak, fwierzbicki
Priority: Keywords:

Created on 2012-06-18.00:12:28 by alekstorm, last changed 2012-08-13.21:10:18 by amak.

msg7240 (view) Author: Alek Storm (alekstorm) Date: 2012-06-18.00:12:25
The `ip` member of the `(ip, port)` address tuple, which is itself a member of the `(conn, address)` tuple returned from socket.accept(), is unicode, when it should be str (or at least, it is in CPython, and I can't think of a reason it should be unicode).
msg7328 (view) Author: Alan Kennedy (amak) Date: 2012-07-17.20:11:42
Practically speaking, there is no difference between unicode strings and strings on jython, both are implemented using java strings.

In terms of python code, there should no difference either.

For example, a test for 'stringness' should always be conducted with isinstance(ip_address, basestring), not (isinstance(ip_address, str).

The only area where it might conceivably make a diference is when converting to bytes, as in inet_aton and inet_pton. But when passing unicode ip addresses to these functions, the correct byte array is returned: there are specific unit tests for this.

Lastly, the distinction between 'str' and 'unicode' is really a legacy of cpython, one which was done away in python 3, which has only 'bytes' and 'unicode'.

So I think it best to leave things as is.

But I am open to dissenting opinions.

I am also adding Frank to see if wants to cast his BDFL casting vote.
msg7329 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-07-17.20:24:54
I tend to agree with Alan on this - CPython compatibility isn't "at all costs" -- and the trouble goes away with Python 3.
msg7330 (view) Author: Alan Kennedy (amak) Date: 2012-07-17.21:02:34
OK, we'll leave the report open for a few days to give the requester an opportunity to protest, i.e. to illustrate where it makes a material difference to actual python code.

Otherwise, I'll close this as "won't fix".
msg7399 (view) Author: Alan Kennedy (amak) Date: 2012-08-13.21:10:18
Closing this issue as "wont fix"
Date User Action Args
2012-08-13 21:10:18amaksetstatus: open -> closed
resolution: wont fix
messages: + msg7399
2012-07-17 21:02:34amaksetmessages: + msg7330
2012-07-17 20:24:54fwierzbickisetmessages: + msg7329
2012-07-17 20:11:42amaksetnosy: + fwierzbicki
messages: + msg7328
2012-07-17 05:05:59amaksetassignee: amak
nosy: + amak
2012-06-18 00:12:28alekstormcreate