]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
python3 bindings: class resolver fix 228/head
authordogo42 <github-dog@hole.fi>
Sat, 9 Dec 2023 11:10:30 +0000 (11:10 +0000)
committerGitHub <noreply@github.com>
Sat, 9 Dec 2023 11:10:30 +0000 (11:10 +0000)
Imitating the example in the beginning of ldnsx.py results in error:

host:~/rpmbuild# python
Python 3.9.16 (main, Dec  8 2022, 00:00:00)
[GCC 11.3.1 20221121 (Red Hat 11.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ldnsx
>>> dir(ldnsx)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__version__', '_rr_types', 'calendar', 'get_rrs', 'isValidIP', 'ldns', 'packet', 'query', 'resolver', 'resource_record', 'secure_query', 'socket', 'sys', 'time', 'warnings']
>>> ldnsx.resolver("9.9.9.9").query("www.hole.fi", "A")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.9/site-packages/ldnsx.py", line 220, in __init__
    nm_list.reverse()
AttributeError: 'filter' object has no attribute 'reverse'
>>>

This patch fixes it, i.e. just add list( .. ) around the filter lambda.

contrib/ldnsx/ldnsx.py

index e2bd0e517e316b3d8083ab81bc4f1b4aad32b8a6..57400cff8b87653234eb8b2909b8d2cd524aa924 100644 (file)
@@ -216,7 +216,7 @@ class resolver:
                        self.drop_nameservers()
                        nm_list = ns.split(',')
                        nm_list = map(lambda s: s.strip(), nm_list)
-                       nm_list = filter(lambda s: s != "", nm_list)
+                       nm_list = list(filter(lambda s: s != "", nm_list))
                        nm_list.reverse()
                        for nm in nm_list:
                                self.add_nameserver(nm)