Skip to content

Fix AddressListExclude with collapse_addrs=False on mixed IPv4/IPv6 l… - #379

Open
Shriraj1901 wants to merge 1 commit into
google:masterfrom
Shriraj1901:fix-address-list-exclude-no-collapse-mixed
Open

Shriraj1901 wants to merge 1 commit into
google:masterfrom
Shriraj1901:fix-address-list-exclude-no-collapse-mixed

Conversation

@Shriraj1901

Copy link
Copy Markdown

…ists

AddressListExclude sorted its inputs with plain sorted() when collapse_addrs was False. Comparing an IPv4 and an IPv6 network with < raises "TypeError: ... are not of the same version", so any call that mixed families crashed, while the default collapse_addrs=True path (CollapseAddrList) already sorts with ipaddress.get_mixed_type_key and handles mixed lists.

Use the same key for the two input sorts and for the final sort so both paths accept the same inputs. Ordering for single-family lists is unchanged because get_mixed_type_key is the same key the network comparison operators use.

…ists

AddressListExclude sorted its inputs with plain sorted() when
collapse_addrs was False. Comparing an IPv4 and an IPv6 network with <
raises "TypeError: ... are not of the same version", so any call that
mixed families crashed, while the default collapse_addrs=True path
(CollapseAddrList) already sorts with ipaddress.get_mixed_type_key and
handles mixed lists.

Use the same key for the two input sorts and for the final sort so both
paths accept the same inputs. Ordering for single-family lists is
unchanged because get_mixed_type_key is the same key the network
comparison operators use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant