kellyjonbrazil / jc

CLI tool and python library that converts the output of popular command-line tools, file-types, and common strings to JSON, YAML, or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.
MIT License
7.93k stars 209 forks source link

Python 3.13 test failure: `test_ip_address_ipv6_ipv4_mapped` #582

Closed suve closed 15 hours ago

suve commented 3 months ago

In Fedora Rawhide (the development branch / "eternal alpha" version) we've recently updated to Python 3.13.0b4 pre-release. With this new version, the following test failure can be observed:

FAIL: test_ip_address_ipv6_ipv4_mapped (tests.test_ip_address.MyTests.test_ip_address_ipv6_ipv4_mapped)
Test ipv6 address with ipv4 mapped string
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/jc-1.25.3-build/jc-1.25.3/tests/test_ip_address.py", line 95, in test_ip_address_ipv6_ipv4_mapped
    self.assertEqual(jc.parsers.ip_address.parse(data, quiet=True), expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: {'ver[45 chars]ffff:192.168.1.35', 'ip_compressed': '::ffff:1[2371 chars]11'}} != {'ver[45 chars]ffff:c0a8:123', 'ip_compressed': '::ffff:c0a8:[2336 chars]11'}}
  {'bin': {'broadcast': '00000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111000000101010000000000100100011',
           'first_host': '00000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111000000101010000000000100100011',
           'hostmask': '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
           'ip': '00000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111000000101010000000000100100011',
           'last_host': '00000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111000000101010000000000100100011',
           'netmask': '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111',
           'network': '00000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111000000101010000000000100100011'},
-  'broadcast': '::ffff:192.168.1.35',
?                        - ------- -

+  'broadcast': '::ffff:c0a8:123',
?                       +++++

   'cidr_netmask': 128,
-  'dns_ptr': '5.3...1...8.6.1...2.9.1.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa',
?              --  ^   ^   ^ ^ ^^^^^^^

+  'dns_ptr': '3.2.1.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa',
?                ^   ^   ^ ^ ^

-  'first_host': '::ffff:192.168.1.35',
?                         - ------- -

+  'first_host': '::ffff:c0a8:123',
?                        +++++

   'hex': {'broadcast': '00:00:00:00:00:00:00:00:00:00:ff:ff:c0:a8:01:23',
           'first_host': '00:00:00:00:00:00:00:00:00:00:ff:ff:c0:a8:01:23',
           'hostmask': '00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00',
           'ip': '00:00:00:00:00:00:00:00:00:00:ff:ff:c0:a8:01:23',
           'last_host': '00:00:00:00:00:00:00:00:00:00:ff:ff:c0:a8:01:23',
           'netmask': 'ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff',
           'network': '00:00:00:00:00:00:00:00:00:00:ff:ff:c0:a8:01:23'},
   'hostmask': '::',
   'hosts': 1,
   'int': {'broadcast': 281473913979171,
           'first_host': 281473913979171,
           'ip': 281473913979171,
           'last_host': 281473913979171,
           'network': 281473913979171},
-  'ip': '::ffff:192.168.1.35',
+  'ip': '::ffff:c0a8:123',
-  'ip_compressed': '::ffff:192.168.1.35',
?                            - ------- -

+  'ip_compressed': '::ffff:c0a8:123',
?                           +++++

-  'ip_exploded': '0000:0000:0000:0000:0000:ffff:192.168.1.35',
?                                                 - ------- -

+  'ip_exploded': '0000:0000:0000:0000:0000:ffff:c0a8:0123',
?                                                ++++++

-  'ip_split': ['0000', '0000', '0000', '0000', '0000', 'ffff', '192.168.1.35'],
?                                                                 - ------- -

+  'ip_split': ['0000', '0000', '0000', '0000', '0000', 'ffff', 'c0a8', '0123'],
?                                                                +++++++++

   'ipv4_mapped': '192.168.1.35',
   'is_global': False,
   'is_link_local': False,
   'is_loopback': False,
   'is_multicast': False,
   'is_private': True,
   'is_reserved': True,
   'is_unspecified': False,
-  'last_host': '::ffff:192.168.1.35',
?                        - ------- -

+  'last_host': '::ffff:c0a8:123',
?                       +++++

   'max_prefix_length': 128,
   'netmask': 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
-  'network': '::ffff:192.168.1.35',
?                      - ------- -

+  'network': '::ffff:c0a8:123',
?                     +++++

   'scope_id': None,
   'six_to_four': None,
   'teredo_client': None,
   'teredo_server': None,
   'version': 6}

----------------------------------------------------------------------

I'm fully aware that Python 3.13.0b4 is a pre-release, which makes testing difficult, so this issue will probably have to wait until the final 3.13.0 release. You can consider this a heads-up. ;-)

For reference, the Python 3.13 "what's new" page currently lists the following changes:

ipaddress

Sorry for not contributing a fix, but my Python knowledge doesn't really extend past FizzBuzz level.

kellyjonbrazil commented 3 months ago

Hi there - thanks for reporting this. I believe this is a duplicate of https://github.com/kellyjonbrazil/jc/issues/572 and will be fixed in the next release.

Edit: unless this is a new issue from 3.13 we need to address? It looks like the other issue fixed a change in 6to4 addresses but this is affecting mapped addresses. Will have to investigate.

suve commented 3 months ago

I think this is a new issue. It affects a different test, and applying the patch from PR #573 does not help.

kellyjonbrazil commented 3 months ago

Looks like this is caused by:

https://github.com/python/cpython/issues/87799

https://github.com/python/cpython/pull/29345

kellyjonbrazil commented 3 months ago

I'm working on a fix, but have opened a cpython issue that I think might need to be addressed as well: https://github.com/python/cpython/issues/123409

kellyjonbrazil commented 2 months ago

https://github.com/python/cpython/issues/123409 is in process of being patched: https://github.com/python/cpython/pull/123419

kellyjonbrazil commented 2 months ago

It looks like the CPython issue has been addressed and will be fixed in the next 3.13 release. I have committed some changes that should fix this issue and tests when the latest Python release comes out.

https://github.com/kellyjonbrazil/jc/commit/71af0c55553e17c598c9f43b8271bfb069795af5

suve commented 3 weeks ago

So, now that Python 3.13 is out - jc v1.25.3 builds fine and all tests pass, provided one backports the following two commits: 9eb4df34b190c57d020b70153ef3faa8984c02ca and 71af0c55553e17c598c9f43b8271bfb069795af5.

As such, this issue should be fixed for everyone in the next release.

kellyjonbrazil commented 15 hours ago

Now available in release v1.25.4