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

cymru/core/dns.py bytes/unicode error interfacing with ipaddress #1

Open
dogwynn opened this issue Aug 20, 2014 · 3 comments
Open

cymru/core/dns.py bytes/unicode error interfacing with ipaddress #1

dogwynn opened this issue Aug 20, 2014 · 3 comments

Comments

@dogwynn
Copy link

dogwynn commented Aug 20, 2014

Greetings,
I tried running the example code in the README for cymru-services, and I kept running into an issue with the line "client.lookup(ip,qType='IP')" giving me an AddressValueError from the ipaddress module. It ended up being a problem in cymru/core/dns.py

Below is the patch to fix:

--- cymru/core/dns.py   2014-08-20 15:39:39.000000000 -0400
+++ cymru.delta/core/dns.py 2014-08-20 15:40:18.000000000 -0400
@@ -51,7 +51,7 @@
     # clean values and type IP values
     if qType is None:
       qType=self.QTYPES[0]
-    values = [str(value).strip() for value in values]
+    values = [unicode(value).strip() for value in values]
     log.debug("values :%s" % (values)) 
     if qType in ['IP','IP6']:
       values = [ip_expand(value) for value in values]
@trolldbois
Copy link
Owner

Can you share your test case, python version, IPy version (or not) ipaddress version ?

unicode is not a supported python3 keyword from what I know.
Or you using a ipaddress backport to python 2 ?

@dogwynn
Copy link
Author

dogwynn commented Aug 24, 2014

I'm using Python 2.7 and have installed the back-port of ipaddress. My test case is the example in the README. I hadn't realized that your codebase is Python3-only. Your code works fine in Python2 except for the call to "str(value)", which converts unicode to bytes, which ipaddress balks at.

@trolldbois
Copy link
Owner

You can also install python-IPy which is supposed to be the python 2
solution.
The code is working with 2.7+IPy or python 3
Le 23 août 2014 18:59, "dogwynn" [email protected] a écrit :

I'm using Python 2.7 and have installed the back-port of ipaddress. My
test case is the example in the README. I hadn't realized that your
codebase is Python3-only. Your code works fine in Python2 except for the
call to "str(value)", which converts unicode to bytes, which ipaddress
balks at.


Reply to this email directly or view it on GitHub
#1 (comment)
.

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