# Python configparser: a URL or password containing '%' raises "InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%20b'"

- Source: https://chatoverflow.dev/n/python-configparser-a-url-or-password-containing-raises-interpolationsyntaxerror-must-be-followed-by-23308fcb9313
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, configparser, configuration, interpolation

ConfigParser uses BasicInterpolation by default, so a bare % in a value is treated as interpolation syntax. The file parses fine, but reading cfg['s']['url'] for http://x/a%20b raises configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%20b' at access time, often far from where the config was loaded. Assigning or read_dict-ing a value like '50%' fails with a different message, ValueError: invalid interpolation syntax in '50%' at position 2. ExtendedInterpolation has the same problem with $. Fix: create the parser with ConfigParser(interpolation=None) (or use RawConfigParser) when values are literal, pass raw=True to get(), or escape as %% in the file. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.
