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

Interpolation of integers #156

Open
sergeygrigorev opened this issue Aug 3, 2017 · 4 comments
Open

Interpolation of integers #156

sergeygrigorev opened this issue Aug 3, 2017 · 4 comments
Labels

Comments

@sergeygrigorev
Copy link

Assume this config:

# config
a = 1
b = 2
c = "$a + $a = $b"
# spec
a = integer
b = integer
c = string

It finds that c matches with Template regex, tries to substitute a into c, finds a and tries to match Template regex with a that is integer because of spec applied. So, it raises TypeError: expected string or bytes-like object.

@hanschen
Copy link

Sounds like a duplicate of #129.

@jhermann
Copy link
Collaborator

Related to #129, not a duplicate. It's the exact inverse.

@jhermann jhermann added the bug label Feb 18, 2018
@WeatherGod
Copy link

WeatherGod commented Jun 2, 2018

Actually, I suspect this is exactly the same issue. The problem is that the configspec turned the values into non-strings. But the string interpolation stage only supports string-like inputs and does no coercion at all.

In fact, you don't even need a configspec to cause this problem:

foo = 1, 2, 3
bar = This list: ${foo}

is sufficient to cause the issue if list_values=True.

I want to fix this problem for a work project. I don't think the right thing to do is to perform coercion. Rather, perhaps the original strings could be stored along side the stored values and those values are used for string interpolation instead. Maybe fall back to using str() on the value in the case where there is no stored string representation (such as when the configobj didn't come from a string buffer or the user sets a non-string value after construction).

@robdennis
Copy link
Member

optimistically putting this in 5.1.0 assuming that the referenced PR helps me understand what's being requested

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

No branches or pull requests

5 participants