[issue18670] Using read_mime_types function from mimetypes module gives resource warning

Vajrasky Kok report at bugs.python.org
Tue Aug 6 17:31:44 CEST 2013


New submission from Vajrasky Kok:

[sky at localhost cpython]$ cat /tmp/a.txt
x-application/mimea mimea
application/mimeb mimeb
[sky at localhost cpython]$ cat /tmp/a.py
import warnings
warnings.simplefilter('default')
import mimetypes

mimetypes.read_mime_types('/tmp/a.txt')
[sky at localhost cpython]$ python3 /tmp/a.py
/tmp/a.py:7: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/a.txt' mode='r' encoding='UTF-8'>
  mimetypes.read_mime_types('/tmp/a.txt')



Attached the patch to fix the resource warning problem.

----------
components: Library (Lib)
files: fix_resource_warning_read_mime_types.patch
keywords: patch
messages: 194557
nosy: vajrasky
priority: normal
severity: normal
status: open
title: Using read_mime_types function from mimetypes module gives resource warning
type: resource usage
versions: Python 3.4
Added file: http://bugs.python.org/file31176/fix_resource_warning_read_mime_types.patch

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


More information about the Python-bugs-list mailing list