-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
Fix escaping brackets in setenv #1691
Conversation
c076123
to
c029347
Compare
b2303c2
to
afcd915
Compare
The macOS CI error appears to be unrelated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's unclear to me what this is actually fixing, why would you still want the backslashes in the variable?
can you show a concrete usecase?
src/tox/config/__init__.py
Outdated
# such as {} being escaped using \{\}, suitable for use with | ||
# os.environ . | ||
return { | ||
name: re.sub(r"\\({|})", r"\1", value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regex is overkill here, I'd just use .replace
-- it looks like the original code did this why did you change it? (the original code is much more readable imo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didnt pay attention to the original code, as it was in a very different area of the code exercised by different tests. I'm happy to use .replace
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah please do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done. Please review again when you have time, as this PR merge conflicts with other PRs, and is also a prerequisite for testing in other PRs using brackets in settings and their effect on the runtime environment variables present while running commands
.
assert env["ESCAPED_VAR"] == "{value}" | ||
assert env["ESCAPED_VAR2"] == r"\{value\}" | ||
assert env["COLON"] == ";" if sys.platform == "win32" else ":" | ||
assert env["TTY_VAR"] == "OFF_VALUE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these seem unrelated to the patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are testing other parts of substitution internals which are not tested in this context. If export()
is to work correctly with a stable API, all of the substitution internal values need to be converted into externally understandable values.
For the record, using {posargs}
in setenv is another case of special handling in the substitution system, and it fails strangely in setenv.
And another internal voodoo not tested is file|
- I havent tried that yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backslashes are how tox escapes If you are asking about literal backslashes in the variable value, there are many reasons people might want them. |
src/tox/config/__init__.py
Outdated
# such as {} being escaped using \{\}, suitable for use with | ||
# os.environ . | ||
return { | ||
name: re.sub(r"\\({|})", r"\1", value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah please do.
965be74
to
e641fa6
Compare
The internal state of SetenvDict depends on curly brackets being escaped.
This partially reverts commit 3c38762. Fixes tox-dev#1690
e641fa6
to
9f356b7
Compare
9f356b7
to
d62320f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixs regression in v3.20.0 that caused escaped curly braces in setenv to break usage of the variable elsewhere in tox.ini.
Fixes #1690
Contribution checklist:
(also see CONTRIBUTING.rst for details)
in message body
<issue number>.<type>.rst
for example (588.bugfix.rst)<type>
is must be one ofbugfix
,feature
,deprecation
,breaking
,doc
,misc
<your username>
"superuser
."CONTRIBUTORS
(preserving alphabetical order)