New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression in logging configuration #77983
Comments
This looks like a serious regression in 3.7. @ned.deily - I'm marking this as a release blocker, but feel free of course to downgrade it. Run the following as $ python3.6 badconfig.py
Hey, it works! $ python3.7 badconfig.py
Traceback (most recent call last):
File "../badconfig.py", line 77, in <module>
fileConfig(inifile.name, defaults=GUNICORN_DEFAULTS)
File "/Users/barry/projects/python/cpython/Lib/logging/config.py", line 65, in fileConfig
cp = configparser.ConfigParser(defaults)
File "/Users/barry/projects/python/cpython/Lib/configparser.py", line 639, in __init__
self._read_defaults(defaults)
File "/Users/barry/projects/python/cpython/Lib/configparser.py", line 1212, in _read_defaults
self.read_dict({self.default_section: defaults})
File "/Users/barry/projects/python/cpython/Lib/configparser.py", line 754, in read_dict
self.set(section, key, value)
File "/Users/barry/projects/python/cpython/Lib/configparser.py", line 1200, in set
super().set(section, option, value)
File "/Users/barry/projects/python/cpython/Lib/configparser.py", line 895, in set
value)
File "/Users/barry/projects/python/cpython/Lib/configparser.py", line 403, in before_set
"position %d" % (value, tmp_value.find('%')))
ValueError: invalid interpolation syntax in "{'generic': {'format': '%(asctime)s [%(process)d] [%(levelname)s] %(message)s', 'datefmt': '[%Y-%m-%d %H:%M:%S %z]', 'class': 'logging.Formatter'}}" at position 26 I'm still investigating, but wanted to get the bug filed asap. |
I think the regression is caused by the fix for bpo-23835 |
I'm very sorry for the trouble! And impressed at Barry's quick diagnosis. |
It seems like this regression has not completely been fixed: there are still issues with "None": $ python3.6 -c 'import configparser; configparser.ConfigParser(defaults={"a": None})'
$ python3.7 -c 'import configparser; configparser.ConfigParser(defaults={"a": 1})' $ python3.7 -c 'import configparser; configparser.ConfigParser(defaults={"a": None})'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.7/configparser.py", line 638, in __init__
self._read_defaults(defaults)
File "/usr/lib/python3.7/configparser.py", line 1216, in _read_defaults
self.read_dict({self.default_section: defaults})
File "/usr/lib/python3.7/configparser.py", line 753, in read_dict
self.set(section, key, value)
File "/usr/lib/python3.7/configparser.py", line 1197, in set
self._validate_value_types(option=option, value=value)
File "/usr/lib/python3.7/configparser.py", line 1182, in _validate_value_types
raise TypeError("option values must be strings")
TypeError: option values must be strings Should "None" not be used, or should this bug be reopened? |
None is an invalid value in the configparser. It only accepts strings. See: >>> cp = ConfigParser()
>>> cp['asd'] = {'a': None}
Traceback (most recent call last):
...
TypeError: option values must be strings The DEFAULT section was an omission which is now fixed. You can use a RawConfigParser if you want to put invalid types as option values:
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: