Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.
This repository was archived by the owner on May 31, 2025. It is now read-only.

NameError on Python 3 #2012

Closed
Closed

Description

@janstrohbeck

If I run rostopic hz with two or more topics as arguments, it crashes:

Traceback (most recent call last):
  File "/opt/ros/noetic/bin/rostopic", line 35, in <module>
    rostopic.rostopicmain()
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 2132, in rostopicmain
    _rostopic_cmd_hz(argv)
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 1523, in _rostopic_cmd_hz
    _rostopic_hz(topics, window_size=window_size, filter_expr=filter_expr,
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 323, in _rostopic_hz
    rt.print_hz(topics)
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 270, in print_hz
    print(_get_ascii_table(header, stats))
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 285, in _get_ascii_table
    body = '\n'.join('   '.join(cols[h][i] for h in header) for i in xrange(n_rows))
NameError: name 'xrange' is not defined

I get this in ROS noetic with Python 3.8 and with Melodic with Python 3.6. xrange is not supported anymore in Python 3. rostopic hz with just one topic works fine, because it does not print the ASCII table.

Activity

  1. dirk-thomas commented on Jul 31, 2020

    @dirk-thomas
    Member

    xrange is not supported anymore in Python 3

    Please see #2013 for the fix. Please consider to contribute a pull request for trivial changes like this in the future.

    with Melodic with Python 3.6

    Please note that Melodic does not officially support Python 3 - only Noetic does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions