Skip to content

Ensure zeroconf can be loaded when the system disables IPv6#933

Merged
bdraco merged 4 commits into
python-zeroconf:masterfrom
che0:master
Aug 6, 2021
Merged

Ensure zeroconf can be loaded when the system disables IPv6#933
bdraco merged 4 commits into
python-zeroconf:masterfrom
che0:master

Conversation

@che0

@che0 che0 commented Aug 3, 2021

Copy link
Copy Markdown

related to #234

The current error on 0.32.1 up to 0.33.2:

>>> import zeroconf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/zeroconf/__init__.py", line 25, in <module>
    from ._cache import DNSCache  # noqa # import needed for backwards compat
  File "/usr/lib/python3.9/site-packages/zeroconf/_cache.py", line 26, in <module>
    from ._dns import (
  File "/usr/lib/python3.9/site-packages/zeroconf/_dns.py", line 28, in <module>
    from ._utils.net import _is_v6_address
  File "/usr/lib/python3.9/site-packages/zeroconf/_utils/net.py", line 34, in <module>
    from ..const import _IPPROTO_IPV6, _MDNS_ADDR6_BYTES, _MDNS_ADDR_BYTES, _MDNS_PORT
ImportError: cannot import name '_MDNS_ADDR6_BYTES' from 'zeroconf.const' (/usr/lib/python3.9/site-packages/zeroconf/const.py)

related to #234

The current error on 0.32.1 up to 0.33.2:

>>> import zeroconf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/zeroconf/__init__.py", line 25, in <module>
    from ._cache import DNSCache  # noqa # import needed for backwards compat
  File "/usr/lib/python3.9/site-packages/zeroconf/_cache.py", line 26, in <module>
    from ._dns import (
  File "/usr/lib/python3.9/site-packages/zeroconf/_dns.py", line 28, in <module>
    from ._utils.net import _is_v6_address
  File "/usr/lib/python3.9/site-packages/zeroconf/_utils/net.py", line 34, in <module>
    from ..const import _IPPROTO_IPV6, _MDNS_ADDR6_BYTES, _MDNS_ADDR_BYTES, _MDNS_PORT
ImportError: cannot import name '_MDNS_ADDR6_BYTES' from 'zeroconf.const' (/usr/lib/python3.9/site-packages/zeroconf/const.py)
@codecov-commenter

codecov-commenter commented Aug 4, 2021

Copy link
Copy Markdown

Codecov Report

Merging #933 (eed2a47) into master (4d30c25) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #933   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         2315      2358   +43     
  Branches       383       388    +5     
=========================================
+ Hits          2315      2358   +43     
Impacted Files Coverage Δ
zeroconf/const.py 100.00% <ø> (ø)
zeroconf/_utils/net.py 100.00% <100.00%> (ø)
zeroconf/_core.py 100.00% <0.00%> (ø)
zeroconf/_logger.py 100.00% <0.00%> (ø)
zeroconf/_protocol.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d30c25...eed2a47. Read the comment docs.

Comment thread zeroconf/const.py Outdated
There's no point in faking result in inet_pton(AF_INET6) if we're not using it.

Co-authored-by: J. Nick Koston <nick@koston.org>
@che0

che0 commented Aug 4, 2021

Copy link
Copy Markdown
Author

Oh :/

zeroconf/const.py:51: error: Incompatible types in assignment (expression has type "None", variable has type "bytes")

@bdraco bdraco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be good to merge once the test coverage is added

The results were used only once and I didn't find any way to mock their results.
@che0

che0 commented Aug 6, 2021

Copy link
Copy Markdown
Author

Unfortunately I did not find any way to mock _MDNS_ADDR6_BYTES from outside the package, nor how to cover whole module-level try/except block. I tried to work around it by moving both inet_ calls directly to _utils.net. Hopefully this should give us better coverage numbers.

Comment thread zeroconf/const.py
@bdraco bdraco merged commit 496ac44 into python-zeroconf:master Aug 6, 2021
@bdraco

bdraco commented Aug 6, 2021

Copy link
Copy Markdown
Member

Do you need a new release ?

@bdraco

bdraco commented Aug 6, 2021

Copy link
Copy Markdown
Member

https://github.com/jstasiak/python-zeroconf/releases/tag/0.33.4

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.

3 participants