From b43f10046d624bd1c459aa9307560add886e479a Mon Sep 17 00:00:00 2001 From: David Lee Date: Fri, 21 Feb 2025 06:16:57 -0800 Subject: [PATCH 1/2] Update config_parser.py --- pyhocon/config_parser.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pyhocon/config_parser.py b/pyhocon/config_parser.py index 4936f1e..2655ee4 100644 --- a/pyhocon/config_parser.py +++ b/pyhocon/config_parser.py @@ -755,11 +755,6 @@ def postParse(self, instring, loc, token_list): # a different object type so Python falls back to identity comparison. # We cannot compare this object to a string object. for token in token_list: - if isinstance(token, str) and token == '': - # This is the case when there was a trailing comma in the list. - # The last token is just an empty string so we can safely ignore - # it. - continue if isinstance(token, ConfigInclude): cleaned_token_list.extend(token.tokens) else: From 57e2910026a081b9af221a90c4c85419f5d19dae Mon Sep 17 00:00:00 2001 From: David Lee Date: Mon, 24 Feb 2025 12:22:58 -0800 Subject: [PATCH 2/2] Update config_parser.py Fixed token list parsing for empty strings in token list. --- pyhocon/config_parser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyhocon/config_parser.py b/pyhocon/config_parser.py index 2655ee4..c8a0861 100644 --- a/pyhocon/config_parser.py +++ b/pyhocon/config_parser.py @@ -754,6 +754,13 @@ def postParse(self, instring, loc, token_list): # relativedelta.__eq__() raises NotImplemented if it is compared with # a different object type so Python falls back to identity comparison. # We cannot compare this object to a string object. + + # If the token list is a multiline list + # Remove the first and last tokens from token list which are new lines converted to empty strings + if instring[loc - 1] in ["\n", "\r"]: + token_list.pop(0) + token_list.pop(-1) + for token in token_list: if isinstance(token, ConfigInclude): cleaned_token_list.extend(token.tokens)