[issue28632] configparser does not close files in read

Łukasz Langa report at bugs.python.org
Mon Nov 7 17:28:37 EST 2016


Łukasz Langa added the comment:

Cannot repro:
```
$ python3
Python 3.5.2 (default, Jul 28 2016, 21:28:00)
>>> with open('/tmp/someconfig.py', 'w') as w:
...   w.write("""[section]
... option=value
... """)
...
23
>>> import configparser
>>> cp = configparser.ConfigParser()
>>> cp.read('/tmp/someconfig.py')
['/tmp/someconfig.py']
>>> [CTRL+D]
$
```

If I leave a file unclosed, I get warning:
```
$ python3
Python 3.5.2 (default, Jul 28 2016, 21:28:00)
>>> open('/tmp/someconfig.py')
<_io.TextIOWrapper name='/tmp/someconfig.py' mode='r' encoding='UTF-8'>
>>> [CTRL+D]
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/someconfig.py' mode='r' encoding='UTF-8'>
$
```

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28632>
_______________________________________


More information about the Python-bugs-list mailing list