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

Fix Python 3 bugs in mongodb_store #272

Merged
merged 1 commit into from
Aug 5, 2022

Conversation

ggorjup
Copy link
Collaborator

@ggorjup ggorjup commented Jul 5, 2022

After some experimentation in ROS Noetic, a couple of bugs related to Python 3 were found. This PR addresses those bugs:

  1. 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.
  2. 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.
  3. 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.
  4. 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').
  5. 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).

The following was changed:
- Install Python scripts with catkin_install_python
- Explicitly cast map and zip to list
- Change buffer type for message serialization in Python 3
- Remove explicit string encoding in Python 3
- Fix indentation, spaces, and types in the test file
@hawesie hawesie merged commit ecbed56 into strands-project:melodic-devel Aug 5, 2022
alex-mitrevski added a commit to b-it-bots/mongodb_store that referenced this pull request Aug 12, 2022
alex-mitrevski added a commit to b-it-bots/mongodb_store that referenced this pull request Aug 12, 2022
The fixes use changes introduced with strands-project#272
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

Successfully merging this pull request may close these issues.

None yet

2 participants