-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Small fixes to make it work with Python 3 #158
Conversation
Note that two tests fail due to internal changes in Python 3: - test_iterable_literals_eval: The order of keys in dict changed in Py3 - test_no_evaluation: ast.literal_eval('5 -2') gives 3 in Py3
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally to your requested changes, I had to
import xml.dom.minidom
in xmlutils.py. Strange, that you didn't notice that issue.
@@ -950,7 +950,7 @@ def process_doc(doc, | |||
if do_check_order and symbols.redefined: | |||
warning("Document is incompatible to --inorder processing.") | |||
warning("The following properties were redefined after usage:") | |||
for k, v in symbols.redefined.iteritems(): | |||
for k, v in symbols.redefined.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although iteritems() is more efficient than items() in python2, I think for the sake of simplicity, we can switch to items().
@@ -50,7 +50,7 @@ | |||
this_dir_cwd = os.getcwd() | |||
os.chdir(cur_dir) | |||
# Remove this dir from path | |||
sys.path = filter(lambda a: a not in [this_dir, this_dir_cwd], sys.path) | |||
sys.path = [a for a in sys.path if a not in [this_dir, this_dir_cwd]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely more pythonic ;-)
src/xacro/xmlutils.py
Outdated
@@ -31,6 +31,7 @@ | |||
# Maintainer: Morgan Quigley <morgan@osrfoundation.org> | |||
|
|||
import xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "import xml" can be removed then.
Parsing of number and boolean literals was done with ast.literal_eval(). However, since python3 this function evaluates expressions like "5 -3" as the number result and not a string anymore. Hence resort to explicit type-casting to int, float, or boolean.
As soon as #161 is merged, I will add some more commits, cleanup and re-issue as a new PR. |
I believe all these changes (and more) were incorporated into #163, which just merged. Thanks @kartikmohta and @rhaschke for iterating on this! Cheers |
Note that two tests fail due to internal changes in Python 3: