Pull requests

#93 Merged
Repository
hpk42
Branch
default

Allow backslashing curly braces to prevent expansion

Author
  1. Marc Abramowitz
Reviewers
Description

Without this:

 marca@marca-mac2.local ⮀ hg-repos/tox ⮀ tox ⮀
 ❯ hg update default
resolving manifests
getting tox/_config.py
1 files updated, 0 files merged, 0 files removed, 0 files unresolved

 marca@marca-mac2.local ⮀ hg-repos/tox ⮀ tox ⮀
 ❯ cat foo1.ini
[tox]
envlist = foo1, foo2, foo3

[testenv]
whitelist_externals = echo

[testenv:foo1]
commands =
    echo "posargs = " "{posargs}"

[testenv:foo2]
commands =
    echo "\{posargs\}" = {posargs}

[testenv:foo3]
# commands =
#     echo --testr-args='{posargs}'

 marca@marca-mac2.local ⮀ hg-repos/tox ⮀ tox ⮀
 ❯ tox -c foo1.ini -- foo bar dog
Traceback (most recent call last):
  File "/Users/marca/python/virtualenvs/tox/bin/tox", line 9, in <module>
    load_entry_point('tox==1.7.1', 'console_scripts', 'tox')()
  File "/Users/marca/dev/hg-repos/tox/tox/_cmdline.py", line 25, in main
    config = parseconfig(args, 'tox')
  File "/Users/marca/dev/hg-repos/tox/tox/_config.py", line 47, in parseconfig
    parseini(config, inipath)
  File "/Users/marca/dev/hg-repos/tox/tox/_config.py", line 281, in __init__
    config)
  File "/Users/marca/dev/hg-repos/tox/tox/_config.py", line 346, in _makeenvconfig
    vc.commands = reader.getargvlist(section, "commands")
  File "/Users/marca/dev/hg-repos/tox/tox/_config.py", line 518, in getargvlist
    commandlist.append(self._processcommand(current_command))
  File "/Users/marca/dev/hg-repos/tox/tox/_config.py", line 550, in _processcommand
    new_word = self._replace(word)
  File "/Users/marca/dev/hg-repos/tox/tox/_config.py", line 666, in _replace
    return RE_ITEM_REF.sub(self._replace_match, x)
  File "/Users/marca/dev/hg-repos/tox/tox/_config.py", line 662, in _replace_match
    return handler(match)
  File "/Users/marca/dev/hg-repos/tox/tox/_config.py", line 633, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/Users/marca/dev/hg-repos/tox/tox/_config.py", line 627, in _substitute_from_other_section
    "substitution key %r not found" % key)
tox.ConfigError: ConfigError: substitution key 'posargs\\' not found

With this:

 marca@marca-mac2.local ⮀ hg-repos/tox ⮀ tox ⮀
 ❯ hg update allow_backslash_escape_curly_braces_msabramo_2
resolving manifests
getting tox/_config.py
1 files updated, 0 files merged, 0 files removed, 0 files unresolved

 marca@marca-mac2.local ⮀ hg-repos/tox ⮀ tox ⮀
 ❯ tox -c foo1.ini -- foo bar dog
GLOB sdist-make: /Users/marca/dev/hg-repos/tox/setup.py
foo1 inst-nodeps: /Users/marca/dev/hg-repos/tox/.tox/dist/tox-1.7.1.zip
foo1 runtests: PYTHONHASHSEED='3871973815'
foo1 runtests: commands[0] | echo posargs = foo bar dog
posargs = foo bar dog
foo2 inst-nodeps: /Users/marca/dev/hg-repos/tox/.tox/dist/tox-1.7.1.zip
foo2 runtests: PYTHONHASHSEED='3871973815'
foo2 runtests: commands[0] | echo \{posargs\} = foo bar dog
\{posargs\} = foo bar dog
foo3 inst-nodeps: /Users/marca/dev/hg-repos/tox/.tox/dist/tox-1.7.1.zip
foo3 runtests: PYTHONHASHSEED='3871973815'
___________________________________________________________________________________ summary ____________________________________________________________________________________
  foo1: commands succeeded
  foo2: commands succeeded
  foo3: commands succeeded
  congratulations :)
  • Learn about pull requests

Comments (4)

  1. holger krekel repo owner

    Thanks, Marc. I realize that Clark's merged PR on issue150 seems to not go well with your change here. Could you make a new branch from the current master/default and maybe also add a mention in the docs about the escaping mechanism?