Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

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

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Aug 6, 2013, 8:31 AM

Post #1 of 4 (20 views)
Permalink
[issue18670] Using read_mime_types function from mimetypes module gives resource warning

New submission from Vajrasky Kok:

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

mimetypes.read_mime_types('/tmp/a.txt')
[sky [at] localhos 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>
<http://bugs.python.org/issue18670>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 9, 2013, 9:28 AM

Post #2 of 4 (12 views)
Permalink
[issue18670] Using read_mime_types function from mimetypes module gives resource warning [In reply to]

R. David Murray added the comment:

Since the TESTFN file is created only in this test, rather than use a tearDown method, it would be better to use addCleanup in the test method itself.

----------
nosy: +r.david.murray

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue18670>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 11, 2013, 9:00 AM

Post #3 of 4 (11 views)
Permalink
[issue18670] Using read_mime_types function from mimetypes module gives resource warning [In reply to]

Vajrasky Kok added the comment:

Attached the second patch to use addCleanup rather than tear down method. Also, I added the non-existent file case.

----------
Added file: http://bugs.python.org/file31232/fix_resource_warning_read_mime_types_v2.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue18670>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 11, 2013, 9:20 AM

Post #4 of 4 (11 views)
Permalink
[issue18670] Using read_mime_types function from mimetypes module gives resource warning [In reply to]

Changes by Ezio Melotti <ezio.melotti [at] gmail>:


----------
nosy: +ezio.melotti
stage: -> patch review
versions: +Python 3.3

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue18670>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.