Skip to content

Commit

Permalink
Work around changes to argparse private API (#673)
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 authored Oct 16, 2024
1 parent faee881 commit ed3ffb5
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 ed3ffb5

Please sign in to comment.