[issue28632] configparser does not close files in read

2016-11-13 Thread SilentGhost

Changes by SilentGhost :


--
stage:  -> resolved

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28632] configparser does not close files in read

2016-11-13 Thread Petr

Petr added the comment:

Thanks for your comments, I am myself quite puzzled how is it possible that the 
file is not closed after having been read. I suspect this to be an OS problem, 
therefore I am closing the bug for now.

--
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28632] configparser does not close files in read

2016-11-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Given that the open is context managed
with open(filename, encoding=encoding) as fp:
self._read(fp, filename)
how could fp not be closed?

--
nosy: +terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28632] configparser does not close files in read

2016-11-08 Thread Petr

Petr added the comment:

I am sorry, I can only reproduce it in the production environment so far, it 
does only occur on Ubuntu Linux (Python 3.5.1) and I am developing on Windows. 
So right now I cannot narrow it down (it does not occur with simple code, 
unfortunately). This is what I get after some experimentation:

Exception ignored in: <_io.FileIO name='config.ini' mode='rb' closefd=True>
ResourceWarning: unclosed file <_io.TextIOWrapper name='config.ini' mode='r' 
encoding='UTF-8'>

The only place when I work with config.ini is the read method of ConfigParser, 
so it definitely should be an issue in ConfigParser.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28632] configparser does not close files in read

2016-11-07 Thread Łukasz Langa

Ł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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28632] configparser does not close files in read

2016-11-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I can't reproduce the issue. Looking at the code it seems to me that the file 
is always closed. Could you please provide more information Petr?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28632] configparser does not close files in read

2016-11-07 Thread R. David Murray

Changes by R. David Murray :


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28632] configparser does not close files in read

2016-11-07 Thread Petr

New submission from Petr:

When using configparser read method, the file(s) remains opened and cannot be 
closed, causing ResourceWarning: unclosed file.

For example in the following code:

config = configparser.ConfigParser()
config.read(cfg_fn)
...

the file cfg_fn remains opened and is only closed upon destruction of the 
underlying file object. At some point in history the method read used to close 
the file, but this has been changed for some reason.

--
components: Library (Lib)
messages: 280209
nosy: PetrPy
priority: normal
severity: normal
status: open
title: configparser does not close files in read
type: resource usage
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com