Strip scope_id from IPv6 address if given.#1020
Conversation
This prevents a crash on Python versions < 3.9.
|
I think @bdraco should be looking at this. It is as a preparation fixing home-assistant/core#56723, and better supporting IPv6 in https://github.com/StevenLooman/async_upnp_client. |
|
Related PR from |
|
|
||
|
|
||
| def ip6_to_address_and_index(adapters: List[Any], ip: str) -> Tuple[Tuple[str, int, int], int]: | ||
| ip = ip[:ip.index('%')] # Strip scope_id. |
There was a problem hiding this comment.
Is it possible it will be passed in without the '%' and we should only strip it if present?
There was a problem hiding this comment.
Oh certainly, not sure why I thought this was a good idea. Thank you for noticing.
Codecov Report
@@ Coverage Diff @@
## master #1020 +/- ##
=======================================
Coverage 99.68% 99.68%
=======================================
Files 23 23
Lines 2524 2526 +2
Branches 412 413 +1
=======================================
+ Hits 2516 2518 +2
Misses 5 5
Partials 3 3
Continue to review full report at Codecov.
|
|
Should be good to go once coverage is added. We have 100% coverage here sans python 3.6 (which is being dropped in #1009) |
|
I'll be AFK for a bit Feel free to ping me on discord if you need the CI started. |
|
I think its ok now. No rush, later is ok for me. Doubt this'll land in next hass release anyway? Like the CI, on my TODO list: add to async-upnp-client. :) |
Looks good now. I'll do a release now and bump it in HASS so it doesn't block you later. |
Great, thanks! Though I'll create the PR for the mentioned part in home assistant for release 2022.1 as Python3.8 support is dropped only then. Again, no rush. |
This prevents a crash on Python versions < 3.9 when scope_id is supplied in the address, and also fixes finding the related interface.
In preparation of home assistant moving to minimal-Python 3.9 requirement, and enabling scope_ids via https://github.com/home-assistant/core/blob/a90c8ab5584ce50e8dfae67790cb56f3d1d1ea86/homeassistant/components/network/__init__.py#L55.