New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the textual representation of IPv4-mapped IPv6 addresses #87799
Comments
Python supports IPv4-mapped IPv6 addresses as defined by RFC 4038: The current behavior is as follows: from ipaddress import ip_address
addr = ip_address('::ffff:8.8.4.4') # IPv6Address('::ffff:808:404')
addr.ipv4_mapped # IPv4Address('8.8.4.4') Note that the textual representation of the IPv6Address is *not* in IPv4-mapped format. 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('::ffff:8.8.4.4')
# Current behavior
str(addr) # '::ffff:808:404'
repr(addr) # IPv6Address('::ffff:808:404')
# Proposed behavior
str(addr) # '::ffff:8.8.4.4'
repr(addr) # IPv6Address('::ffff:8.8.4.4') A few data points:
|
@maxmouchet, thank you for creating the issue. I'll try to fix this, if you don't mind. |
…esses (#29345) Represent IPv4-mapped IPv6 address as x❌x❌x❌d.d.d.d, where the 'x's are the hexadecimal values of the six high-order 16-bit pieces of the address, and the 'd's are the decimal values of the four low-order 8-bit pieces of the address (standard IPv4 representation). --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Done by #29345 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: