ros-infrastructure / catkin_pkg

Standalone Python library for the catkin build system.
https://github.com/ros/catkin
Other
47 stars 89 forks source link

Condition can't handle multiple sequential 'or's #281

Closed MatthijsBurgh closed 4 years ago

MatthijsBurgh commented 4 years ago

The following condition results in a list of length 5

condition = "$ROS_PYTHON_VERSION == 2 or $ROS_PYTHON_VERSION == 2 or $ROS_PYTHON_VERSION == 2"

It creates the following AssertionError, as it only accepts a list of 3.

In [18]: evaluate_condition(condition, os.environ)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-18-68713d7cacd4> in <module>()
----> 1 evaluate_condition(condition, os.environ)

/usr/lib/python2.7/dist-packages/catkin_pkg/condition.pyc in evaluate_condition(condition, context)
     27         raise ValueError(
     28             "condition '%s' failed to parse: %s" % (condition, e))
---> 29     return _evaluate(parse_results.asList()[0], context)
     30 
     31 

/usr/lib/python2.7/dist-packages/catkin_pkg/condition.pyc in _evaluate(parse_results, context)
     59 
     60     # recursion
---> 61     assert len(parse_results) == 3
     62 
     63     # handle logical operators

AssertionError: 

This is the actual result, with a length of 5.

[['$ROS_PYTHON_VERSION', '==', '2'],
 'or',
 ['$ROS_PYTHON_VERSION', '==', '2'],
 'or',
 ['$ROS_PYTHON_VERSION', '==', '2']]
dirk-thomas commented 4 years ago

This should be fixed by #279 which will be part of the next patch release.