From 9ec44f2f96babb1ee17bae0a2b14861d149a0146 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Tue, 9 Apr 2024 09:52:01 -0400 Subject: [PATCH 1/3] Fix argument parsing in newer Python. The comment in the code has more details, but as of https://github.com/python/cpython/pull/114180 we need to check for both a 3-tuple and a 4-tuple. Signed-off-by: Chris Lalancette --- colcon_core/command.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/colcon_core/command.py b/colcon_core/command.py index fd159be1..413ae563 100644 --- a/colcon_core/command.py +++ b/colcon_core/command.py @@ -226,7 +226,14 @@ class CustomArgumentParser(argparse.ArgumentParser): def _parse_optional(self, arg_string): result = super()._parse_optional(arg_string) - if result == (None, arg_string, None): + # Up until https://github.com/python/cpython/pull/114180 , + # _parse_optional() returned a 3-tuple when it couldn't classify + # 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. + if result in ( + (None, arg_string, 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' return None From f04372bbf25e7757d3c0037cd4734d9817c1e593 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Tue, 9 Apr 2024 10:06:45 -0400 Subject: [PATCH 2/3] Add words to the spellchecker. Signed-off-by: Chris Lalancette --- test/spell_check.words | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/spell_check.words b/test/spell_check.words index 96051a0f..83548464 100644 --- a/test/spell_check.words +++ b/test/spell_check.words @@ -3,6 +3,7 @@ apache argparse asyncio autouse +backported basepath bazqux blocklist @@ -17,6 +18,7 @@ configparser contextlib coroutine coroutines +cpython datetime debian debinfo From e25fc8e14a50a15ceb2bb96f22da529839701e1a Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Tue, 9 Apr 2024 12:05:39 -0400 Subject: [PATCH 3/3] Update colcon_core/command.py Signed-off-by: Chris Lalancette Co-authored-by: Scott K Logan --- colcon_core/command.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/colcon_core/command.py b/colcon_core/command.py index 413ae563..228d3b36 100644 --- a/colcon_core/command.py +++ b/colcon_core/command.py @@ -232,7 +232,8 @@ def _parse_optional(self, arg_string): # backported to Python 3.12), it returns a 4-tuple. Check for # either here. if result in ( - (None, arg_string, None), (None, arg_string, None, None) + (None, arg_string, 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'