infosec-au/altdns

Compatibility with Python 3

Closed this issue · 7 comments

When running in Python 3, there is an error message:
File "/usr/local/lib/python3.8/site-packages/altdns/main.py", line 10, in
from Queue import Queue as Queue
ModuleNotFoundError: No module named 'Queue'

That is because in Python 3 some changes happened.

Correct statement in usr/local/lib/python3.8/site-packages/altdns/main.py:
from queue import Queue as queue

also change, right after main():
q = queue()

Thank you @pallyndr!

I also got syntax warnings for using "is not" and "is" when comparing values.

/usr/local/lib/python3.8/site-packages/altdns/__main__.py:45: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if actual_sub[-1:] is not ".":
/usr/local/lib/python3.8/site-packages/altdns/__main__.py:102: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if len(current_sub[0]) > 0 and actual_sub[:1] is not "-":
/usr/local/lib/python3.8/site-packages/altdns/__main__.py:112: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if actual_sub[-1:] is not "-":
/usr/local/lib/python3.8/site-packages/altdns/__main__.py:175: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if len(result) is 1:

This workaround fix the warnings and the Queue issue as well for me.

sed -i 's/from Queue import/from queue import/g' /usr/local/lib/python3.8/dist-packages/altdns/__main__.py
sed -i 's/if len(result) is 1/if len(result) == 1/g' /usr/local/lib/python3.8/dist-packages/altdns/__main__.py
sed -i 's/is not/!=/g' /usr/local/lib/python3.8/dist-packages/altdns/__main__.py

The code in the github repository seems to reflect the fix that @bewniac used for substituting the "from Queue" to "from queue".
Theres no need to change the "as Queue" to "as queue" like @pallyndr suggested.
I just used the pip install, and the code still has this issue.

The code in the github repository seems to reflect the fix that @bewniac used for substituting the "from Queue" to "from queue".
Theres no need to change the "as Queue" to "as queue" like @pallyndr suggested.
I just used the pip install, and the code still has this issue.

Yes, it seems they haven't updated the package, last update was on May 23, 2019.

@infosec-au, could you please update the package on PyPi.

Thanks.

The solution provided by @bewniac works perfectly.
Be aware to adjust the right path, in my case ~/.local/lib/python3.9/site-packages/...

PR #38 could also be helpful.
Looks like the project owner is still active on GitHub, @infosec-au would you like to take a quick look at #31 and #38? Forgive me if this is disturbing you.

Hi @PeterDaveHello - I have merged #38