Skip to content
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

Assignment of variables with underscore in their name causes pyparsing exception #312

Open
gafniguy opened this issue Jul 12, 2023 · 4 comments

Comments

@gafniguy
Copy link

gafniguy commented Jul 12, 2023

With the following config file,

model{
    d_in = 3
    d_out = 2
}

I ran ConfigFactory.parse_file('./confs/test2.conf') and get an exception:

pyparsing.exceptions.ParseSyntaxException: , found '=' (at char 30), (line:3, col:11)

If I change d_out to e_out, or comment one of them out, or remove the underscore in at least one of their names, I will get no exception.

I get this with Python 3.11.3, Python 3.8.17 and pyparsing 3.1.0 and pyparsing 3.0.8

@GuillaumeLeclerc
Copy link

Cam for the exact same problem and from the name of the variables I assume from the same repository 😉 I guess the best is to just rename the parameters at this point

@GuillaumeLeclerc
Copy link

Actually pip install pyhocon==0.3.57 works

@viktor-dolniik
Copy link

Happens to me with this config

x = 1
y = 1

so the issue is probably not related to underscores or nestedness.

When I reorder the parameters:

y = 1
x = 1

it is parsed correctly. Changing the values to float solves the issue as well.

@pierresouchay
Copy link
Contributor

pierresouchay commented May 31, 2024

That's a duplicate of #324 and has been fixed by #326 -> fixed in version 0.3.61: https://github.com/chimpler/pyhocon/releases/tag/0.3.61

=> Basically, variables with names starting with possible durations (ex: d_hello (d=day) or y_me (y=year) were incorrectly parsed if using "\n" with values, but fixed now

=> You can close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants