Issue #375: kallithea 0.6.0 under python3: alembic configparser crashes when smtp_password contains % symbols (conservancy/kallithea)

Maximilian Kerst issues-reply at bitbucket.org
Thu May 21 14:30:07 UTC 2020


New issue 375: kallithea 0.6.0 under python3: alembic configparser crashes when smtp_password contains % symbols
https://bitbucket.org/conservancy/kallithea/issues/375/kallithea-060-under-python3-alembic

Maximilian Kerst:

As the title suggests, running `alembic -c my.ini current` on Python 3.7.3 fails with a configparser.InterpolationSyntaxError if it encounters a % sign:

```
(kallithea-venv) xxx at xxx:/usb/kallithea/kallithea $ alembic -c my.ini current
Traceback (most recent call last):
  File "/usb/kallithea/kallithea-venv/bin/alembic", line 8, in <module>
    sys.exit(main())
  File "/usb/kallithea/kallithea-venv/lib/python3.7/site-packages/alembic/config.py", line 577, in main
    CommandLine(prog=prog).main(argv=argv)
  File "/usb/kallithea/kallithea-venv/lib/python3.7/site-packages/alembic/config.py", line 571, in main
    self.run_cmd(cfg, options)
  File "/usb/kallithea/kallithea-venv/lib/python3.7/site-packages/alembic/config.py", line 551, in run_cmd
    **dict((k, getattr(options, k, None)) for k in kwarg)
  File "/usb/kallithea/kallithea-venv/lib/python3.7/site-packages/alembic/command.py", line 515, in current
    script.run_env()
  File "/usb/kallithea/kallithea-venv/lib/python3.7/site-packages/alembic/script/base.py", line 489, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/usb/kallithea/kallithea-venv/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 98, in load_python_file
    module = load_module_py(module_id, path)
  File "/usb/kallithea/kallithea-venv/lib/python3.7/site-packages/alembic/util/compat.py", line 184, in load_module_py
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usb/kallithea/kallithea-venv/lib/python3.7/site-packages/kallithea/alembic/env.py", line 108, in <module>
    run_migrations_online()
  File "/usb/kallithea/kallithea-venv/lib/python3.7/site-packages/kallithea/alembic/env.py", line 83, in run_migrations_online
    cfg = config.get_section(config.config_ini_section)
  File "/usb/kallithea/kallithea-venv/lib/python3.7/site-packages/alembic/config.py", line 225, in get_section
    return dict(self.file_config.items(name))
  File "/usr/lib/python3.7/configparser.py", line 857, in items
    return [(option, value_getter(option)) for option in d.keys()]
  File "/usr/lib/python3.7/configparser.py", line 857, in <listcomp>
    return [(option, value_getter(option)) for option in d.keys()]
  File "/usr/lib/python3.7/configparser.py", line 854, in <lambda>
    section, option, d[option], d)
  File "/usr/lib/python3.7/configparser.py", line 394, in before_get
    self._interpolate_some(parser, option, L, value, section, defaults, 1)
  File "/usr/lib/python3.7/configparser.py", line 444, in _interpolate_some
    "found: %r" % (rest,))
configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%&CENSORED'
```

The affected config was smtp\_password, which is why i unfortunately cannot provide the complete field.

Fortunately, **there is a workaround**: the % sign needs to be escaped, e.g. replace ‘%' with '%%’.  
After applying the workaround, alembic could successfully upgrade my database.

The bug was found while upgrading from 0.5.2.

System information:  
Host: Raspberry Pi 4 \(armv71\)  
OS: Raspbian 10, Kernel 4.19.97  
Python: 3.7.3  
Kallithea installed via Python venv and pip.

Please excuse my unprofessional report here, for I am still a student and not a professional.




More information about the kallithea-general mailing list