[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

Vajrasky Kok report at bugs.python.org
Sat Aug 3 15:45:19 CEST 2013


New submission from Vajrasky Kok:

This python is compiled with --with-pydebug option.

[sky at localhost cpython]$ cat /tmp/a.txt
manly man likes cute cat.
[sky at localhost cpython]$ ./python
Python 3.4.0a0 (default:e408e821d6c8, Jul 27 2013, 10:49:54) 
[GCC 4.7.2 20121109 (Red Hat 4.7.2-8)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from formatter import test
>>> test('/tmp/a.txt')
manly man likes cute cat.
__main__:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/a.txt' mode='r' encoding='UTF-8'>
>>> 
[sky at localhost cpython]$ ./python Lib/formatter.py /tmp/a.txt
manly man likes cute cat.
Lib/formatter.py:445: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/a.txt' mode='r' encoding='UTF-8'>
  test()

----------
components: Tests
files: formatter_fix_resource_warning.patch
keywords: patch
messages: 194260
nosy: vajrasky
priority: normal
severity: normal
status: open
title: Got ResourceWarning: unclosed file when using test function from formatter module
type: resource usage
versions: Python 3.4
Added file: http://bugs.python.org/file31138/formatter_fix_resource_warning.patch

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


More information about the Python-bugs-list mailing list