mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Closes #16110: fileConfig now accepts a pre-initialised ConfigParser instance.
This commit is contained in:
parent
96df7da0ac
commit
cf9e2f2420
3 changed files with 52 additions and 9 deletions
|
@ -61,11 +61,14 @@ def fileConfig(fname, defaults=None, disable_existing_loggers=True):
|
|||
"""
|
||||
import configparser
|
||||
|
||||
cp = configparser.ConfigParser(defaults)
|
||||
if hasattr(fname, 'readline'):
|
||||
cp.read_file(fname)
|
||||
if isinstance(fname, configparser.RawConfigParser):
|
||||
cp = fname
|
||||
else:
|
||||
cp.read(fname)
|
||||
cp = configparser.ConfigParser(defaults)
|
||||
if hasattr(fname, 'readline'):
|
||||
cp.read_file(fname)
|
||||
else:
|
||||
cp.read(fname)
|
||||
|
||||
formatters = _create_formatters(cp)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue