classification
Title: IPv6 support for logging.handlers
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Thomas Bartelmess, cblp, gregory.p.smith, loewis, pitrou, vinay.sajip
Priority: normal Keywords: patch

Created on 2012-05-19 09:49 by cblp, last changed 2015-02-26 16:51 by Thomas Bartelmess.

Files
File name Uploaded Description Edit
mywork.patch cblp, 2012-05-19 09:49 Patch that adds IPv6 support to logging.handlers review
mywork2.patch cblp, 2012-05-23 13:46 socket.create_connection supports UDP; DatagramHandler supports IPv6 review
Messages (13)
msg161101 - (view) Author: Yuriy Syrovetskiy (cblp) Date: 2012-05-19 09:49
IPv4 operations may fail on IPv6 systems, and vice versa. So we have to create sockets with the proper address family.

Maybe this behaviour could be incapsulated in socket object, but didn't find a good way to do it.

No documentation changed, because I just eliminate lack of implementation of already documented feature.

Please help to write tests.

I worked on the 3.2 branch, because the default branch has broken test_logging.
msg161102 - (view) Author: Yuriy Syrovetskiy (cblp) Date: 2012-05-19 09:52
More correct description: IPv4 operations may fail on IPv6 systems, and vice versa; so we have to detect the proper address family before creating a socket.
msg161103 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-05-19 09:56
For TCP, socket.create_connection() is your friend. For UDP I'm not sure, but adding a helper to the socket module might also be a good idea.
msg161104 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-05-19 10:00
The Linux getaddrinfo() man page has an UDP client example which uses connect() to decide whether the target address is valid or not.
msg161106 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-05-19 10:26
Apparently, connecting the socket is better because some systems (BSDs in particular) only report ICMP errors to connected UDP sockets. The Linux man page claims that this reporting is necessary regardless of whether the socket is connected.

I wonder what will happen under this patch if the server has both v4 and v6 connectivity, and the client supports v6, but has no connectivity (other than, say, on the local link).
msg161127 - (view) Author: Yuriy Syrovetskiy (cblp) Date: 2012-05-19 14:53
On my computer, connect() on a UDP socket always finishes successfully. What's wrong?

I tried that C example from man getaddrinfo(3).
msg161128 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-05-19 14:56
> On my computer, connect() on a UDP socket always finishes
> successfully. What's wrong?

Nothing wrong I guess, since connect() on an UDP socket doesn't actually
do anything, network-wise (UDP being an unconnected protocol).
msg161132 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-05-19 15:47
> On my computer, connect() on a UDP socket always finishes  
> successfully. What's wrong?

Nothing is wrong. UDP is connection-less, so connect() is a no-op,
except that it remembers the address so you can use send() instead
of sendto(). Any errors due to non-reachability will only happen when
you actually try to send.
msg161136 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2012-05-19 16:39
> I worked on the 3.2 branch, because the default branch has broken
> test_logging.

What breakage are you referring to? There's a race condition test that fails on Windows sometimes, but that's on the 2.7 branch. Apart from that, I don't know what breakage you're referring to, so please elaborate.
msg161408 - (view) Author: Yuriy Syrovetskiy (cblp) Date: 2012-05-23 13:46
Can the datagramHandler.host change during execution? If so, the address family of the socket can change. So, we should create a socket for every new message. Check my patch #2.

Also I extended socket.create_connection to support UDP.
msg161410 - (view) Author: Yuriy Syrovetskiy (cblp) Date: 2012-05-23 13:59
test_logging is not broken, but just fails.

test test_logging failed -- Traceback (most recent call last):
  File "/home/cblp/my/cpython_default/Lib/test/test_logging.py", line 2903, in test_time
    self.assertEqual(f.formatTime(r), '1993-04-21 08:03:00,123')
AssertionError: '1993-04-21 09:03:00,123' != '1993-04-21 08:03:00,123'
- 1993-04-21 09:03:00,123
?             ^
+ 1993-04-21 08:03:00,123
?             ^

Or should it go to the separate ticket?
msg161492 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2012-05-24 09:31
> Or should it go to the separate ticket?

Yes, please.
msg236687 - (view) Author: Thomas Bartelmess (Thomas Bartelmess) Date: 2015-02-26 16:51
The datagram handler seems still not useable with IPv6 in Python 3.4. Is this patch still under consideration ?
History
Date User Action Args
2015-02-26 16:51:07Thomas Bartelmesssetnosy: + Thomas Bartelmess
messages: + msg236687
2012-05-24 09:31:24vinay.sajipsetmessages: + msg161492
2012-05-23 13:59:27cblpsetmessages: + msg161410
2012-05-23 13:46:07cblpsetfiles: + mywork2.patch

messages: + msg161408
2012-05-19 16:39:43vinay.sajipsetmessages: + msg161136
2012-05-19 15:47:44loewissetmessages: + msg161132
2012-05-19 14:56:22pitrousetmessages: + msg161128
2012-05-19 14:53:43cblpsetmessages: + msg161127
2012-05-19 10:26:40loewissetnosy: + loewis
messages: + msg161106
2012-05-19 10:00:07pitrousetmessages: + msg161104
2012-05-19 09:56:51pitrousetnosy: + gregory.p.smith, pitrou

messages: + msg161103
versions: - Python 2.6, Python 3.1, Python 2.7, Python 3.2, Python 3.4
2012-05-19 09:52:39cblpsetmessages: + msg161102
2012-05-19 09:49:33cblpcreate