[issue43633] Improve the textual representation of IPv4-mapped IPv6 addresses

2021-10-31 Thread Oleksandr Pavliuk


Change by Oleksandr Pavliuk :


--
keywords: +patch
nosy: +opavlyuk
nosy_count: 1.0 -> 2.0
pull_requests: +27610
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29345

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43633] Improve the textual representation of IPv4-mapped IPv6 addresses

2021-11-01 Thread Oleksandr Pavliuk


Oleksandr Pavliuk  added the comment:

@maxmouchet, thank you for creating the issue.
For me it makes sense, and RFC 4291 calls such IPv6 text representation 
approach as "more convenient".

I'll try to fix this, if you don't mind.
P.S.: Sorry for providing PR before I asked.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43633] Improve the textual representation of IPv4-mapped IPv6 addresses

2021-03-26 Thread Maxime Mouchet

New submission from Maxime Mouchet :

Python supports IPv4-mapped IPv6 addresses as defined by RFC 4038:
 "the IPv6 address :::x.y.z.w represents the IPv4 address x.y.z.w.”

The current behavior is as follows:

   from ipaddress import ip_address
   addr = ip_address(':::8.8.4.4') # IPv6Address(':::808:404')
   addr.ipv4_mapped # IPv4Address('8.8.4.4')

Note that the textual representation of the IPv6Address is *not* in IPv4-mapped 
format.
It prints :::808:404 instead of :::8.8.4.4.
This is technically correct, but it’s somewhat frustrating as it makes it 
harder to read IPv4s embedded in IPv6 addresses.

My proposal would be to check, in __str__, if an IPv6 is an IPv4-mapped, and to 
return the appropriate representation :

   from ipaddress import ip_address
   addr = ip_address(':::8.8.4.4')

   # Current behavior
   str(addr)  # ':::808:404'
   repr(addr) # IPv6Address(':::808:404')

   # Proposed behavior
   str(addr)  # ':::8.8.4.4'
   repr(addr) # IPv6Address(':::8.8.4.4')

A few data points:
- Julia prints :::808:404 (current behavior)
- C (glibc) and ClickHouse prints :::8.8.4.4 (proposed behavior)

--
components: Library (Lib)
messages: 389556
nosy: maxmouchet
priority: normal
severity: normal
status: open
title: Improve the textual representation of IPv4-mapped IPv6 addresses
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com