Fix Python 3 bugs in mongodb_store #272
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After some experimentation in ROS Noetic, a couple of bugs related to Python 3 were found. This PR addresses those bugs:
catkin_install_python
inCMakeLists.txt
:This makes sure we can run the nodes with
#!/usr/bin/env python
shebangs in ROS Noetic.map
andzip
tolist
:In Python 3,
map()
andzip()
do not returnlist
object types (like they do in Python 2). Some other functions inmongodb_store
assume thelist
type, so we cast them tolist
explicitly.In Python 2,
StringIO
can handle bytes. In Python 3, we need to use a differentIO
in message serialization.In Python 2, strings and byte strings are both of type
str
. In Python 3,str
andbytes
are different, incompatible types. This means that it is an error if we try to (re-)encode astr
:str('a', 'utf-8')
.The test file had some issues like inconsistent indentation,
print
statements with spaces, and arange
object treated as alist
.The applied changes should have no effect on
mongodb_store
in Python 2.I'm making this PR into
melodic-devel
, sincenoetic-devel
does not exist yet (and as far as I know it's not possible to make a PR for a non-existing branch).