Determining the version of dnspython

486 views
Skip to first unread message

glenel...@gmail.com

unread,
Aug 16, 2020, 1:57:26 PM8/16/20
to dnspython-users
For 2.0.0, I found dns.version.version.  Great, awesome.

But for 1.x, is there a way other than catching an exception?

Newer machine:

FifthMacMini ~ % python3
Python 3.8.5 (default, Jul 21 2020, 10:48:26)
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dns
>>> dns.version.version
'2.0.0'

Older machine:

FourthMacMini:~$ python3
Python 3.7.0 (default, Sep 18 2018, 18:47:29)
[Clang 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dns
>>> dns.version.version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'dns' has no attribute 'version'

Use case : Need (ok, want) to determine whether I can send in domain name into the AXFR calling code or need to use resolve to convert to IP addresses.  The former accidentally worked in version 1, , the resolve is introduced in version 2.

Scott Kitterman

unread,
Aug 16, 2020, 2:02:38 PM8/16/20
to dnspython-users
How about something like:

try:
    dns.version.version
    [use resolve]
except AttributeError:
    [send domain name]

Not sure if indentation will be preserved, so ...

Scott K

Bob Halley

unread,
Aug 16, 2020, 2:08:59 PM8/16/20
to dnspython-users
Explicitly import dns.version, as all that changed in 2.0.0 was that __init__.py imported it.

>>> import dns.version
>>> print(dns.version.version)
1.16.0


glenel...@gmail.com

unread,
Aug 16, 2020, 2:09:12 PM8/16/20
to dnspython-users
That certainly would work (and is my plan B).  I just can't find the 1.x docs (anymore) to see if there was a more graceful way to determine the versoin in 1.x that might have carried forward.

glenel...@gmail.com

unread,
Aug 16, 2020, 2:11:04 PM8/16/20
to dnspython-users
Ah, thanks.  That (import dns.version.version explicitly) is now Plan A.

Bob Halley

unread,
Aug 16, 2020, 2:11:26 PM8/16/20
to dnspython-users
Old docs are still available at 

Reply all
Reply to author
Forward
0 new messages