Skip to content

Commit

Permalink
Work around changes to argparse private API
Browse files Browse the repository at this point in the history
Unfortunately, achieving colcon's arbitrary argument parsing involves
reaching into argparse private API. There was recently a change to that
API which was backported to stable Python releases, and this change is
necessary to restore the desired behavior.
  • Loading branch information
cottsay committed Oct 15, 2024
1 parent faee881 commit b3154c3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions colcon_core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,13 @@ def _parse_optional(self, arg_string):
# the option. As of that PR (which is in Python 3.13, and
# backported to Python 3.12), it returns a 4-tuple. Check for
# either here.
# A similar regression later occurred when _parse_optional()
# started returning a list of tuples, brought in by
# https://github.com/python/cpython/pull/124631 .
if result in (
(None, arg_string, None),
(None, arg_string, None, None),
[(None, arg_string, None, None)],
):
# in the case there the arg is classified as an unknown 'O'
# override that and classify it as an 'A'
Expand Down

0 comments on commit b3154c3

Please sign in to comment.