Skip to content

Fixed parsing for empty strings in lists getting dropped #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pyhocon/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,12 +754,14 @@ 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, 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:
Expand Down