This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: ConfigParser parsing failures with default_section and ExtendedInterpolation options
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: SilentGhost, frispete, lukasz.langa
Priority: normal Keywords:

Created on 2016-04-22 22:37 by frispete, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit frispete, 2016-04-22 22:37 show parsing failures
Messages (3)
msg264031 - (view) Author: Hans-Peter Jansen (frispete) * Date: 2016-04-22 22:37
ConfigParser fails in interesting ways, when using default_section and ExtendedInterpolation options. Running the attached script results in: 

ConfigParser() with expected result:
global: [('loglevel', 'WARNING'), ('logfile', '-')]
section1: [('key_a', 'value'), ('key_b', 'morevalue')]
section2: [('key_c', 'othervalue'), ('key_d', 'differentvalue')]

ConfigParser(default_section='global') mangles section separation:
section1: [('loglevel', 'WARNING'), ('logfile', '-'), ('key_a', 'value'), ('key_b', 'morevalue')]
section2: [('loglevel', 'WARNING'), ('logfile', '-'), ('key_c', 'othervalue'), ('key_d', 'differentvalue')]

ConfigParser(interpolation=ExtendedInterpolation) fails with strange error:
Traceback (most recent call last):
  File "", line 36, in <module>
  File "", line 21, in print_sections
  File "/usr/lib64/python3.4/", line 696, in read_string
    self.read_file(sfile, source)
  File "/usr/lib64/python3.4/", line 691, in read_file
    self._read(f, source)
  File "/usr/lib64/python3.4/", line 1089, in _read
  File "/usr/lib64/python3.4/", line 1101, in _join_multiline_values
    name, val)
TypeError: before_read() missing 1 required positional argument: 'value'

while it is expected to behave identical.
msg264059 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2016-04-23 08:53
I think there is some misunderstanding of what default_section is supposed to do, in fact in provides default values for *other* section, as the documentation says, it doesn't mangle section separation.

In case of ExtendedInterpolation, the interpolation argument needs to be instantiated, i.e. the call should be:
msg413399 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2022-02-17 12:22
Note: the problem here was due to passing `ExtendedInterpolation` (the class) instead of `ExtendedInterpolation()` (the object). This is now fixed through BPO-41086.
Date User Action Args
2022-04-11 14:58:30adminsetgithub: 71018
2022-02-17 12:22:23lukasz.langasetmessages: + msg413399
2016-04-23 08:53:44SilentGhostsetstatus: open -> closed

type: behavior

nosy: + SilentGhost, lukasz.langa
messages: + msg264059
resolution: not a bug
stage: resolved
2016-04-22 22:37:37frispetecreate