test_log_config_append_invalid fails with python 3.11.4 "configparser.MissingSectionHeaderError: File contains no section headers"

Bug #2023684 reported by Corey Bryant
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
oslo.log
Fix Released
Undecided
Unassigned

Bug Description

lxc launch ubuntu-daily:mantic m1
lxc exec m1 /bin/bash
root@m1:~# git clone https://github.com/openstack/oslo.log
root@m1:~# cd oslo.log
root@m1:~/oslo.log# python3 --version
Python 3.11.4
root@m1:~/oslo.log# tox -e py311 -- oslo_log.tests.unit.test_log.LogConfigTestCase.test_log_config_append_invalid
...
{0} oslo_log.tests.unit.test_log.LogConfigTestCase.test_log_config_append_invalid [0.004787s] ... FAILED

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/usr/lib/python3.11/logging/config.py", line 78, in fileConfig
    cp.read(fname, encoding=encoding)

      File "/usr/lib/python3.11/configparser.py", line 713, in read
    self._read(fp, filename)

      File "/usr/lib/python3.11/configparser.py", line 1101, in _read
    raise MissingSectionHeaderError(fpname, lineno, line)

    configparser.MissingSectionHeaderError: File contains no section headers.
file: '/tmp/tmpujx8ubx4/logging_pku4gn_.conf', line: 1
'squawk'

During handling of the above exception, another exception occurred:

    Traceback (most recent call last):

      File "/root/oslo.log/oslo_log/tests/unit/test_log.py", line 1806, in test_log_config_append_invalid
    self.assertRaises(log.LogConfigError, log.setup,

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 468, in assertRaises
    self.assertThat(our_callable, matcher)

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 479, in assertThat
    mismatch_error = self._matchHelper(matchee, matcher, message, verbose)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 531, in _matchHelper
    mismatch = matcher.match(matchee)
               ^^^^^^^^^^^^^^^^^^^^^^

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/matchers/_exception.py", line 104, in match
    mismatch = self.exception_matcher.match(exc_info)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/matchers/_higherorder.py", line 62, in match
    mismatch = matcher.match(matchee)
               ^^^^^^^^^^^^^^^^^^^^^^

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 458, in match
    reraise(*matchee)

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/compat.py", line 26, in reraise
    raise exc_obj.with_traceback(exc_tb)

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/matchers/_exception.py", line 97, in match
    result = matchee()
             ^^^^^^^^^

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 1040, in __call__
    return self._callable_object(*self._args, **self._kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/root/oslo.log/oslo_log/log.py", line 289, in setup
    _load_log_config(conf.log_config_append)

      File "/root/oslo.log/oslo_log/log.py", line 231, in _load_log_config
    logging.config.fileConfig(log_config_append,

      File "/usr/lib/python3.11/logging/config.py", line 80, in fileConfig
    raise RuntimeError(f'{fname} is invalid: {e}')

    RuntimeError: /tmp/tmpujx8ubx4/logging_pku4gn_.conf is invalid: File contains no section headers.
file: '/tmp/tmpujx8ubx4/logging_pku4gn_.conf', line: 1
'squawk'

No tests were successful during the run

==============================
Failed 1 tests - output below:
==============================

oslo_log.tests.unit.test_log.LogConfigTestCase.test_log_config_append_invalid
-----------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/usr/lib/python3.11/logging/config.py", line 78, in fileConfig
    cp.read(fname, encoding=encoding)

      File "/usr/lib/python3.11/configparser.py", line 713, in read
    self._read(fp, filename)

      File "/usr/lib/python3.11/configparser.py", line 1101, in _read
    raise MissingSectionHeaderError(fpname, lineno, line)

    configparser.MissingSectionHeaderError: File contains no section headers.
file: '/tmp/tmpujx8ubx4/logging_pku4gn_.conf', line: 1
'squawk'

During handling of the above exception, another exception occurred:

    Traceback (most recent call last):

      File "/root/oslo.log/oslo_log/tests/unit/test_log.py", line 1806, in test_log_config_append_invalid
    self.assertRaises(log.LogConfigError, log.setup,

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 468, in assertRaises
    self.assertThat(our_callable, matcher)

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 479, in assertThat
    mismatch_error = self._matchHelper(matchee, matcher, message, verbose)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 531, in _matchHelper
    mismatch = matcher.match(matchee)
               ^^^^^^^^^^^^^^^^^^^^^^

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/matchers/_exception.py", line 104, in match
    mismatch = self.exception_matcher.match(exc_info)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/matchers/_higherorder.py", line 62, in match
    mismatch = matcher.match(matchee)
               ^^^^^^^^^^^^^^^^^^^^^^

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 458, in match
    reraise(*matchee)

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/compat.py", line 26, in reraise
    raise exc_obj.with_traceback(exc_tb)

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/matchers/_exception.py", line 97, in match
    result = matchee()
             ^^^^^^^^^

      File "/root/oslo.log/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 1040, in __call__
    return self._callable_object(*self._args, **self._kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/root/oslo.log/oslo_log/log.py", line 289, in setup
    _load_log_config(conf.log_config_append)

      File "/root/oslo.log/oslo_log/log.py", line 231, in _load_log_config
    logging.config.fileConfig(log_config_append,

      File "/usr/lib/python3.11/logging/config.py", line 80, in fileConfig
    raise RuntimeError(f'{fname} is invalid: {e}')

    RuntimeError: /tmp/tmpujx8ubx4/logging_pku4gn_.conf is invalid: File contains no section headers.
file: '/tmp/tmpujx8ubx4/logging_pku4gn_.conf', line: 1
'squawk'

description: updated
Revision history for this message
Matěj Cepl (mcepl) wrote :

Just to add +1 from me (a packager for Python packages in openSUSE), and yes our troubles are also with Python 3.11. We are using testtools 2.6.0 and oslo.log 5.2.0 from the tarball on PyPI.

Revision history for this message
Ivan Melnikov (imelnikov) wrote :
Revision history for this message
Corey Bryant (corey.bryant) wrote :

Thanks Ivan, that patch works for me.

Changed in oslo.log:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.