Title: ipaddress: Wrong behavior with ::ffff: style IPs
Type: behavior Stage:
Components: Documentation, Library (Lib) Versions: Python 3.6, Python 3.5
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: ThiefMaster, arp11, docs@python, pmoody, socketpair
Priority: normal Keywords:

Created on 2016-06-08 14:55 by ThiefMaster, last changed 2017-05-23 00:08 by arp11.

Pull Requests
URL Status Linked Edit
PR 1741 open arp11, 2017-05-23 00:08
Messages (4)
msg267861 - (view) Author: ThiefMaster (ThiefMaster) Date: 2016-06-08 14:55
I'd expect the IPv4 address to be considered part of that network (or actually parsed as an IPv4Address and not IPv6Address) even if it's written in IPv6 notation. It's an IPv4 after all.

Python 3.5.1 (default, Jun  7 2016, 09:20:44)
[GCC 4.9.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipaddress
>>> ipaddress.ip_address('::ffff:')
>>> ipaddress.ip_address('::ffff:') in ipaddress.ip_network('')
>>> ipaddress.ip_address('') in ipaddress.ip_network('')
msg269984 - (view) Author: Марк Коренберг (socketpair) * Date: 2016-07-08 11:03
see also issue20446
msg269986 - (view) Author: Марк Коренберг (socketpair) * Date: 2016-07-08 11:09
Also, it should be marked explicitly, if cross-type lookup is safe. I mean code like that:

    some_net = ipaddress.ip_network(some_input1)
    some_addr = ipaddress.ip_address(some_input2)
    return some_addr in some_net

Is it safe to write such code? Docs say: Operators
    Address objects support some operators. Unless stated otherwise,
    operators can only be applied between compatible objects
    (i.e. IPv4 with IPv4, IPv6 with IPv6).

1. It is not said if exception will be raised if incompatible objects are used, and not said if result is defined.
2. "Unless stated otherwise" - Seem it is stated nowhere.
msg294198 - (view) Author: Alex Perry (arp11) * Date: 2017-05-22 23:06

... seems to implement the principle in this bug, but I'm not convinced this is a good idea.
Date User Action Args
2017-05-23 00:08:58arp11setpull_requests: + pull_request1831
2017-05-22 23:06:47arp11setnosy: + arp11
messages: + msg294198
2016-07-08 11:09:38socketpairsetnosy: + docs@python
messages: + msg269986

assignee: docs@python
components: + Documentation
2016-07-08 11:03:43socketpairsetnosy: + socketpair
messages: + msg269984
2016-06-08 15:04:31SilentGhostsetnosy: + pmoody

versions: - Python 3.3, Python 3.4
2016-06-08 14:55:23ThiefMastercreate