Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:
I can't reproduce this on Linux machine with Python 3.7 and 3.8. Assigning the open file object shouldn't really make a difference unless you are passing the same file object that was read to initialize a different configparser object. cat review-stats.cfg [global] a = b python3.7 Python 3.7.0 (default, Jun 28 2018, 00:00:00) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 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() ['global'] python Python 3.8.0 (default, Nov 6 2019, 21:49:08) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> 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() ['global'] >>> config3 = configparser.ConfigParser() >>> config3.read_file(f) # This wouldn't work since f.read() is '' and has >>> reached file end. >>> config3.sections() [] >>> ---------- nosy: +xtreak _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39387> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com