Skip to content

Configs with values with percent signs (%) can't be loadfile'd-> TypeError #40

@gyermolenko

Description

@gyermolenko

Yaml values containing % can cause TypeErrors.

$ cat file.yaml
uri: "amqp://localhost:5672/%2F"

$ python
Python 3.7.4 (default, Oct  1 2019, 17:17:01)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymlconf import Root
>>> Root().loadfile('file.yaml')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../site-packages/pymlconf/models.py", line 236, in loadfile
    loadedyaml = yaml_.load(filename, self.context)
  File ".../site-packages/pymlconf/yaml_.py", line 30, in load
    return loads(f.read(), context)
  File ".../site-packages/pymlconf/yaml_.py", line 20, in loads
    str_data = preprocess(str_data, context)
  File ".../site-packages/pymlconf/yaml_.py", line 15, in preprocess
    return data % context
TypeError: must be real number, not dict

Because %2F is considered string format specifier (if not escaped, e.g. with another %).

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