[New-bugs-announce] [issue39387] configparser read_file() with variable
Mattia Verga
report at bugs.python.org
Sun Jan 19 07:59:22 EST 2020
New submission from Mattia Verga <mattia.verga at gmail.com>:
I'm trying to assign a file object to a variable and then pass this variable to configparse.read_file(), but for some reason that doesn't work:
>>> import configparser
>>> config = configparser.ConfigParser()
>>> config.read_file(open('review-stats.cfg'))
>>> config.sections()
['global']
>>>
>>> config2 = configparser.ConfigParser()
>>> f = open('review-stats.cfg')
>>> f
<_io.TextIOWrapper name='review-stats.cfg' mode='r' encoding='UTF-8'>
>>> config2.read_file(f)
>>> config2.sections()
[]
Shouldn't those results be the same?
----------
components: Library (Lib)
messages: 360257
nosy: Mattia Verga
priority: normal
severity: normal
status: open
title: configparser read_file() with variable
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39387>
_______________________________________
More information about the New-bugs-announce
mailing list