After some experimentation in ROS Noetic, a couple of bugs related to Python 3 were found. This PR addresses those bugs:
Install Python scripts with catkin_install_python in CMakeLists.txt:
This makes sure we can run the nodes with #!/usr/bin/env python shebangs in ROS Noetic.
Explicitly cast map and zip to list:
In Python 3, map() and zip() do not return list object types (like they do in Python 2). Some other functions in mongodb_store assume the list type, so we cast them to list explicitly.
Change buffer type for message serialization in Python 3:
In Python 2, StringIO can handle bytes. In Python 3, we need to use a different IO in message serialization.
Remove explicit string encoding in Python 3:
In Python 2, strings and byte strings are both of type str. In Python 3, str and bytes are different, incompatible types. This means that it is an error if we try to (re-)encode a str: str('a', 'utf-8').
Fix indentation, spaces, and types in the test file:
The test file had some issues like inconsistent indentation, print statements with spaces, and a range object treated as a list.
The applied changes should have no effect on mongodb_store in Python 2.
I'm making this PR into melodic-devel, since noetic-devel does not exist yet (and as far as I know it's not possible to make a PR for a non-existing branch).
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.StringIO
can handle bytes. In Python 3, we need to use a differentIO
in message serialization.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')
.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).