Generated message fails when a fixed-size array message has a field named range (shadowing built-in)

オープン
#275 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@Rahul-cs50 がすでに取り組んでいます。

2026年11月9日 から。

  • #276 @Rahul-cs50 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
54/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python

調査の方向性

Start by locating the Python message generator code and its tests for fixed-size array fields; the issue does not name specific files or tests. Reproduce generation for a fixed-size array message with a field named range and trace the generated code that references the built-in. Done when that message generates successfully and the regression is covered by a test.

索引モデルが issue の本文から書いたものです。

説明

bug
Generated by Generative AI

Assisted by Claude (Sonnet 5.5)

Operating System:

Linux df1274dbdab4 7.0.0-42-generic #42~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 19 14:43:01 UTC 2 x86_64 GNU/Linux

ROS version or commit hash:

Rolling, Lyrical

RMW implementation (if applicable):

rmw_fastrtps_cpp

RMW Configuration (if applicable):

N/A

Client library (if applicable):

No response

'ros2 doctor --report' output
ros2 doctor --report
   ACTION LIST
action                 : none
action server count    : 0
action client count    : 0

   ROS ENVIRONMENT
ROS environment variables        : ROS_AUTOMATIC_DISCOVERY_RANGE=SUBNET, ROS_DISTRO=rolling
rcutils environment variables    : 
rmw environment variables        : 

   PACKAGE VERSIONS
ros2topic                                 : latest=0.42.2, local=0.42.0
statistics_msgs                           : latest=2.5.2, local=2.5.1
spdlog_vendor                             : latest=1.9.0, local=1.9.0
rosidl_typesupport_cpp                    : latest=3.5.1, local=3.5.0
lifecycle_msgs                            : latest=2.5.2, local=2.5.1
ament_cmake_lint_cmake                    : latest=0.21.4, local=0.21.3
ament_cmake_ros                           : latest=0.16.1, local=0.16.0
launch_testing_ros                        : latest=0.30.3, local=0.30.2
ament_mypy                                : latest=0.21.4, local=0.21.3
ament_cmake_libraries                     : latest=2.9.3, local=2.9.2
ament_cmake_export_dependencies           : latest=2.9.3, local=2.9.2
rclcpp_lifecycle                          : latest=33.2.0, local=33.1.0
ament_cmake_python                        : latest=2.9.3, local=2.9.2
rosidl_buffer_py                          : latest=5.3.2, local=5.3.1
ament_uncrustify                          : latest=0.21.4, local=0.21.3
rosidl_typesupport_introspection_c        : latest=5.3.2, local=5.3.1
rosidl_generator_rs                       : latest=0.5.0, local=0.5.0
ament_lint_auto                           : latest=0.21.4, local=0.21.3
composition_interfaces                    : latest=2.5.2, local=2.5.1
rosidl_dynamic_typesupport_fastrtps       : latest=0.6.1, local=0.6.0
ament_cmake_pep257                        : latest=0.21.4, local=0.21.3
ament_cmake_gmock                         : latest=2.9.3, local=2.9.2
rosidl_buffer_backend                     : latest=5.3.2, local=5.3.1
ament_index_python                        : latest=1.14.2, local=1.14.2
ament_cmake_pytest                        : latest=2.9.3, local=2.9.2
ros2doctor                                : latest=0.42.2, local=0.42.0
ament_cmake_uncrustify                    : latest=0.21.4, local=0.21.3
ament_cmake_export_include_directories    : latest=2.9.3, local=2.9.2
ros2pkg                                   : latest=0.42.2, local=0.42.0
rcl_logging_interface                     : latest=3.5.1, local=3.5.0
rcpputils                                 : latest=2.15.4, local=2.15.2
rosidl_parser                             : latest=5.3.2, local=5.3.1
ros2plugin                                : latest=6.0.3, local=6.0.2
launch_ros                                : latest=0.30.3, local=0.30.2
class_loader                              : latest=3.0.3, local=3.0.2
rcl                                       : latest=10.5.3, local=10.5.2
rmw                                       : latest=7.11.3, local=7.11.2
type_description_interfaces               : latest=2.5.2, local=2.5.1
shape_msgs                                : latest=5.10.3, local=5.10.2
rmw_implementation_cmake                  : latest=7.11.3, local=7.11.2
ros2param                                 : latest=0.42.2, local=0.42.0
rclcpp_components                         : latest=33.2.0, local=33.1.0
trajectory_msgs                           : latest=5.10.3, local=5.10.2
rosidl_core_generators                    : latest=0.5.0, local=0.5.0
service_msgs                              : latest=2.5.2, local=2.5.1
ament_cmake_test                          : latest=2.9.3, local=2.9.2
ament_lint                                : latest=0.21.4, local=0.21.3
pluginlib                                 : latest=6.0.3, local=6.0.2
geometry_msgs                             : latest=5.10.3, local=5.10.2
ament_cpplint                             : latest=0.21.4, local=0.21.3
rosidl_dynamic_typesupport                : latest=0.5.1, local=0.5.0
ament_flake8                              : latest=0.21.4, local=0.21.3
ros2multicast                             : latest=0.42.2, local=0.42.0
ament_cmake_gen_version_h                 : latest=2.9.3, local=2.9.2
ros_core                                  : latest=0.13.0, local=0.13.0
ament_pep257                              : latest=0.21.4, local=0.21.3
sros2                                     : latest=0.17.1, local=0.17.0
ament_cmake_flake8                        : latest=0.21.4, local=0.21.3
launch                                    : latest=3.10.3, local=3.10.2
rosidl_pycommon                           : latest=5.3.2, local=5.3.1
uncrustify_vendor                         : latest=3.3.0, local=3.3.0
sros2_cmake                               : latest=0.17.1, local=0.17.0
ament_cmake_export_targets                : latest=2.9.3, local=2.9.2
ros_environment                           : latest=5.0.0, local=5.0.0
ament_index_cpp                           : latest=1.14.2, local=1.14.2
ament_package                             : latest=0.19.1, local=0.19.1
rmw_dds_common                            : latest=6.1.3, local=6.1.2
builtin_interfaces                        : latest=2.5.2, local=2.5.1
rcl_lifecycle                             : latest=10.5.3, local=10.5.2
rosidl_cmake                              : latest=5.3.2, local=5.3.1
ament_cmake_export_definitions            : latest=2.9.3, local=2.9.2
ros2log                                   : latest=0.42.2, local=0.42.0
ament_cmake_export_libraries              : latest=2.9.3, local=2.9.2
rcl_interfaces                            : latest=2.5.2, local=2.5.1
rosidl_core_runtime                       : latest=0.5.0, local=0.5.0
rosidl_default_generators                 : latest=1.9.0, local=1.9.0
ament_cmake_mypy                          : latest=0.21.4, local=0.21.3
sensor_msgs                               : latest=5.10.3, local=5.10.2
rosidl_generator_c                        : latest=5.3.2, local=5.3.1
ament_xmllint                             : latest=0.21.4, local=0.21.3
rosidl_typesupport_c                      : latest=3.5.1, local=3.5.0
unique_identifier_msgs                    : latest=2.9.1, local=2.9.0
rcl_yaml_param_parser                     : latest=10.5.3, local=10.5.2
nav_msgs                                  : latest=5.10.3, local=5.10.2
ament_cmake_gtest                         : latest=2.9.3, local=2.9.2
rosidl_buffer_backend_registry            : latest=5.3.2, local=5.3.1
ament_cmake_xmllint                       : latest=0.21.4, local=0.21.3
rosidl_generator_cpp                      : latest=5.3.2, local=5.3.1
rmw_implementation                        : latest=3.2.2, local=3.2.1
rmw_test_fixture                          : latest=0.16.1, local=0.16.0
rosidl_typesupport_interface              : latest=5.3.2, local=5.3.1
ros2cli                                   : latest=0.42.2, local=0.42.0
console_bridge_vendor                     : latest=1.10.0, local=1.10.0
ament_copyright                           : latest=0.21.4, local=0.21.3
ament_cmake_export_link_flags             : latest=2.9.3, local=2.9.2
rclcpp_action                             : latest=33.2.0, local=33.1.0
rmw_fastrtps_cpp                          : latest=9.6.1, local=9.6.0
ament_cmake_core                          : latest=2.9.3, local=2.9.2
ros2cli_common_extensions                 : latest=0.6.1, local=0.6.1
ros2node                                  : latest=0.42.2, local=0.42.0
rcl_logging_spdlog                        : latest=3.5.1, local=3.5.0
tracetools                                : latest=9.0.0, local=9.0.0
ros2action                                : latest=0.42.2, local=0.42.0
rclcpp                                    : latest=33.2.0, local=33.1.0
rosidl_generator_type_description         : latest=5.3.2, local=5.3.1
rosidl_default_runtime                    : latest=1.9.0, local=1.9.0
visualization_msgs                        : latest=5.10.3, local=5.10.2
ament_cmake_version                       : latest=2.9.3, local=2.9.2
rmw_security_common                       : latest=7.11.3, local=7.11.2
rosidl_generator_py                       : latest=0.28.1, local=0.28.0
ros2component                             : latest=0.42.2, local=0.42.0
launch_xml                                : latest=3.10.3, local=3.10.2
rosidl_runtime_c                          : latest=5.3.2, local=5.3.1
ros2lifecycle                             : latest=0.42.2, local=0.42.0
rmw_test_fixture_implementation           : latest=0.16.1, local=0.16.0
diagnostic_msgs                           : latest=5.10.3, local=5.10.2
libyaml_vendor                            : latest=1.9.0, local=1.9.0
action_msgs                               : latest=2.5.2, local=2.5.1
ament_cmake_copyright                     : latest=0.21.4, local=0.21.3
rosidl_typesupport_introspection_cpp      : latest=5.3.2, local=5.3.1
ament_cmake_auto                          : latest=2.9.3, local=2.9.2
common_interfaces                         : latest=5.10.3, local=5.10.2
rosidl_typesupport_fastrtps_c             : latest=3.10.2, local=3.10.1
launch_testing                            : latest=3.10.3, local=3.10.2
ament_cmake_target_dependencies           : latest=2.9.3, local=2.9.2
std_srvs                                  : latest=5.10.3, local=5.10.2
ament_lint_common                         : latest=0.21.4, local=0.21.3
rcutils                                   : latest=7.2.3, local=7.2.2
rosidl_typesupport_fastrtps_cpp           : latest=3.10.2, local=3.10.1
rcl_logging_implementation                : latest=3.5.1, local=3.5.0
rclpy                                     : latest=11.0.4, local=11.0.3
ros2service                               : latest=0.42.2, local=0.42.0
ros2run                                   : latest=0.42.2, local=0.42.0
ament_cmake_cppcheck                      : latest=0.21.4, local=0.21.3
rosidl_adapter                            : latest=5.3.2, local=5.3.1
ros2interface                             : latest=0.42.2, local=0.42.0
launch_testing_ament_cmake                : latest=3.10.3, local=3.10.2
libstatistics_collector                   : latest=3.0.0, local=3.0.0
ros2launch                                : latest=0.30.3, local=0.30.2
rosidl_runtime_cpp                        : latest=5.3.2, local=5.3.1
ament_cmake_ros_core                      : latest=0.16.1, local=0.16.0
ament_cmake                               : latest=2.9.3, local=2.9.2
ament_lint_cmake                          : latest=0.21.4, local=0.21.3
rpyutils                                  : latest=0.8.0, local=0.8.0
ros_workspace                             : latest=1.0.3, local=1.0.3
ament_cmake_cpplint                       : latest=0.21.4, local=0.21.3
rmw_fastrtps_shared_cpp                   : latest=N/A, local=9.6.0
ament_cmake_include_directories           : latest=2.9.3, local=2.9.2
rosidl_runtime_py                         : latest=0.16.1, local=0.16.0
rosgraph_msgs                             : latest=2.5.2, local=2.5.1
stereo_msgs                               : latest=5.10.3, local=5.10.2
rosidl_cli                                : latest=5.3.2, local=5.3.1
std_msgs                                  : latest=5.10.3, local=5.10.2
rosidl_buffer                             : latest=5.3.2, local=5.3.1
ament_cppcheck                            : latest=0.21.4, local=0.21.3
rcl_action                                : latest=10.5.3, local=10.5.2
launch_yaml                               : latest=3.10.3, local=3.10.2
tf2_eigen_kdl                             : latest=0.46.5, local=0.46.4
tf2_kdl                                   : latest=0.46.5, local=0.46.4
robot_state_publisher                     : latest=3.6.3, local=3.6.2
tf2_geometry_msgs                         : latest=0.46.5, local=0.46.4
eigen3_cmake_module                       : latest=0.6.0, local=0.6.0
lz4_cmake_module                          : latest=0.35.0, local=0.35.0
geometry2                                 : latest=0.46.5, local=0.46.4
yaml_cpp_vendor                           : latest=9.3.0, local=9.3.0
tf2_py                                    : latest=0.46.5, local=0.46.4
kdl_parser                                : latest=3.1.0, local=3.1.0
tf2_eigen                                 : latest=0.46.5, local=0.46.4
ros2bag                                   : latest=0.35.0, local=0.35.0
rosbag2_storage                           : latest=0.35.0, local=0.35.0
rosbag2_cpp                               : latest=0.35.0, local=0.35.0
tf2_tools                                 : latest=0.46.5, local=0.46.4
tf2_sensor_msgs                           : latest=0.46.5, local=0.46.4
rosbag2_compression                       : latest=0.35.0, local=0.35.0
keyboard_handler                          : latest=0.6.0, local=0.6.0
urdf                                      : latest=2.14.1, local=2.14.1
tf2_ros                                   : latest=0.46.5, local=0.46.4
rosbag2_storage_sqlite3                   : latest=0.35.0, local=0.35.0
rosbag2_py                                : latest=0.35.0, local=0.35.0
tf2_msgs                                  : latest=0.46.5, local=0.46.4
rosbag2                                   : latest=0.35.0, local=0.35.0
tf2_bullet                                : latest=0.46.5, local=0.46.4
message_filters                           : latest=8.0.5, local=8.0.4
mcap_vendor                               : latest=0.35.0, local=0.35.0
urdf_parser_plugin                        : latest=2.14.1, local=2.14.1
sensor_msgs_py                            : latest=5.10.3, local=5.10.2
zstd_cmake_module                         : latest=0.35.0, local=0.35.0
rosbag2_transport                         : latest=0.35.0, local=0.35.0
ros_base                                  : latest=0.13.0, local=0.13.0
rosbag2_storage_default_plugins           : latest=0.35.0, local=0.35.0
rosbag2_storage_mcap                      : latest=0.35.0, local=0.35.0
tf2                                       : latest=0.46.5, local=0.46.4
rosbag2_interfaces                        : latest=0.35.0, local=0.35.0
rosbag2_compression_zstd                  : latest=0.35.0, local=0.35.0
tf2_ros_py                                : latest=0.46.5, local=0.46.4

   PLATFORM INFORMATION
system           : Linux
platform info    : Linux-7.0.0-42-generic-x86_64-with-glibc2.43
release          : 7.0.0-42-generic
processor        : 

   QOS COMPATIBILITY LIST
compatibility status    : No publisher/subscriber pairs found

   RMW MIDDLEWARE
middleware name    : rmw_fastrtps_cpp

   ROS 2 INFORMATION
distribution name      : rolling
distribution type      : ros2
distribution status    : rolling
release platforms      : {'debian': ['trixie'], 'fedora': ['44'], 'rhel': ['10'], 'ubuntu': ['resolute']}

   SERVICE LIST
service          : none
service count    : 0
client count     : 0

   TOPIC LIST
topic               : none
publisher count     : 0
subscriber count    : 0

================================================================================
                                !!! WARNING !!!                                 
================================================================================
The report includes all ROS 2 endpoint information and system platform information.
Please review the report before sharing, as it may contain sensitive or private data.
================================================================================
Steps to reproduce issue

A message with a field named range that sits alongside a fixed-size array of a non-numeric type can’t be instantiated in Python.
The generated init has a parameter called range, which shadows the builtin. The template then calls range(N) to build the array default, which fails.

In ROS2 Lyrical and Rolling:

  1. Create a message:
    bool[2] range
  2. Build it
  3. Run it: from ros_range_msg_issue.msg import RangeMsg; RangeMsg()

This is a MVE for a real problem I am experiencing trying to instantiate and use a DVL message where I can't use the message (although the package builds):

$ ros2 topic echo /dvl
Unable to convert call argument '0' to Python object (#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)
Expected behavior

This should work without issue, and does work on pre-Lyrical version of ROS.

Actual behavior
File ".../ros_range_msg_issue/msg/_range_msg.py", line 102, in __init__
    self.range = range if range is not None else [bool() for x in range(2)]
TypeError: 'NoneType' object is not callable
Additional information

I've created an easily reproducible repo here: https://github.com/micat001/ros_range_msg_issue that tests the msg generator against different ROS versions. Clone the repo, run ./run.sh ROS_DISTRO and it will build and test.

It looks like this: https://github.com/ros2/rosidl_python/pull/206 is the cause of the change of behavior.

主要言語
EmberScript
スター
26
フォーク
75
平均マージ
6日 7時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ros2/rosidl_python のほかの issue

ros2/rosidl_python の issue をすべて見る

似ている issue

Build System の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。