Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning: please use dns.resolver.resolve() instead #581

Closed
Phoenix1112 opened this issue Sep 10, 2020 · 5 comments
Closed

DeprecationWarning: please use dns.resolver.resolve() instead #581

Phoenix1112 opened this issue Sep 10, 2020 · 5 comments

Comments

@Phoenix1112
Copy link

hello. thanks for great project. I have made a program before and it was working without any problems. but for the past few days I've started seeing an error like this. "DeprecationWarning: please use dns.resolver.resolve() instead"

Can we no longer query with dns.resolver.query? Should we use dns.resolver.resolve instead of dns.resolver.query?

@rthalley
Copy link
Owner

Thanks for the kind words!

You may still use dns.resolver.query(); it is only a deprecation warning and it will not be removed for some time yet. It would be better, however, to switch to using dns.resolve.resolve() and explicitly enabling search if you need it. Calling dns.resolver.query() is equivalent to calling dns.resolver.resolve() with the same arguments and also passing search=True.

See the description of the 'search' parameter in the documentation for more details. Basically dnspython is using a safer default as searching can be insecure or surprising. If your application needs the search behavior, and you are satisfied with its safety and security, then simply pass search=True to dns.resolver.resolve().

@Phoenix1112
Copy link
Author

thanks.

tripleee added a commit to tripleee/SmokeDetector that referenced this issue Nov 12, 2020
Where previously we used dns.resolver.query(), switch to d.r.resolve()

Complete compatibility would require d.r.resolve(search=True) but this works without it so far.

Perhaps see also rthalley/dnspython#581
@Phoenix1112
Copy link
Author

@rthalley hello. Did you switch back to the dns.resolver.resolve method? because now I am using dns.resolver.query in my program and I got a warning.

/root/programlar/subtakeover/takeover.py:122: DeprecationWarning: please use dns.resolver.Resolver.resolve() instead
  dns_query = self.Dnspython_Resolver.query(target, "A")

Can you please explain whether you are using the query method anymore?

@rthalley
Copy link
Owner

dns.resolver.Resolver.resolve() is the newer, safer method that you should use. You are getting a deprecation warning because your code is using the older query() method.

@Phoenix1112
Copy link
Author

thanks

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

No branches or pull requests

2 participants