Skip to content

unsolved token crash #7

@antirotor

Description

@antirotor

I've run into curious bug:

data = {'A': 'A', 'B': '{A}', 'C': '{C[x]}'}
result = acre.compute(data)

expected result is:

{'A': 'A', 'B': 'A', 'C': '{C[x]}'}

C should be unresolved and stay the same. But:

>>> data = {'A': 'A', 'B': '{A};B', 'C': '{C[x]}'}
>>> a = acre.compute(data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:/Users/annat/Documents/pype/pype-setup/vendor/python/acre\acre\core.py", line 71, in compute
    env[key] = lib.partial_format(env[key], data=data)
  File "C:/Users/annat/Documents/pype/pype-setup/vendor/python/acre\acre\lib.py", line 45, in partial_format
    return formatter.vformat(s, (), mapping)
  File "C:\Users\annat\Documents\pype\docker\volume\bin\windows\python36\lib\string.py", line 190, in vformat
    result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
  File "C:\Users\annat\Documents\pype\docker\volume\bin\windows\python36\lib\string.py", line 230, in _vformat
    obj, arg_used = self.get_field(field_name, args, kwargs)
  File "C:\Users\annat\Documents\pype\docker\volume\bin\windows\python36\lib\string.py", line 303, in get_field
    obj = obj[i]
TypeError: string indices must be integers

This could be fixed with:

return formatter.vformat(s, (), mapping)

to:

try:
      f = formatter.vformat(s, (), mapping)
except ValueError:
      return s
except TypeError:
      return s
return f

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions