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

Mailing List Archive: Python: Bugs

[issue15447] A file is not properly closed by webbrowser._invoke

 

 

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


report at bugs

Jul 25, 2012, 6:15 AM

Post #1 of 10 (187 views)
Permalink
[issue15447] A file is not properly closed by webbrowser._invoke

New submission from Anton Barkovsky <swarmer.pm [at] gmail>:

webbrowser._invoke opens /dev/null, never closes it and a warning is
printed.

I'm attaching a patch.
The diff looks messy, but I'm just wrapping the code in a try-finally
block, the rest is just indented.

----------
components: Library (Lib)
files: fileclose.patch
keywords: patch
messages: 166392
nosy: anton.barkovsky
priority: normal
severity: normal
status: open
title: A file is not properly closed by webbrowser._invoke
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file26511/fileclose.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15447>
_______________________________________
_______________________________________________
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

Jul 25, 2012, 6:31 AM

Post #2 of 10 (184 views)
Permalink
[issue15447] A file is not properly closed by webbrowser._invoke [In reply to]

R. David Murray <rdmurray [at] bitdance> added the comment:

Thanks. Is this warning printed by the webbrowser unit tests? If not can you see a way to add one that does?

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

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15447>
_______________________________________
_______________________________________________
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

Jul 25, 2012, 6:38 AM

Post #3 of 10 (183 views)
Permalink
[issue15447] A file is not properly closed by webbrowser._invoke [In reply to]

Anton Barkovsky <swarmer.pm [at] gmail> added the comment:

The warning is printed by the file object when it closes itself in __del__:

ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='r+' encoding='UTF-8'>

There isn't much to test, or is there?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15447>
_______________________________________
_______________________________________________
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

Jul 25, 2012, 6:39 AM

Post #4 of 10 (185 views)
Permalink
[issue15447] A file is not properly closed by webbrowser._invoke [In reply to]

Anton Barkovsky <swarmer.pm [at] gmail> added the comment:

To clarify, I discovered this when I was simply running webbrowser.open
in REPL.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15447>
_______________________________________
_______________________________________________
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

Jul 25, 2012, 6:43 AM

Post #5 of 10 (184 views)
Permalink
[issue15447] A file is not properly closed by webbrowser._invoke [In reply to]

Ross Lagerwall <rosslagerwall [at] gmail> added the comment:

Are there any webbrowser unit tests?

(this could probably use the new subprocess.DEVNULL constant in 3.3)

----------
nosy: +rosslagerwall

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15447>
_______________________________________
_______________________________________________
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

Jul 25, 2012, 6:48 AM

Post #6 of 10 (189 views)
Permalink
[issue15447] A file is not properly closed by webbrowser._invoke [In reply to]

R. David Murray <rdmurray [at] bitdance> added the comment:

@Anton: That's what I was guessing. If we had a unit test in test_webbrowser that did the same thing, we'd have seen the resource warning when running the tests and fixed it. However, it looks like there aren't *any* tests for webbrowser, not even in test_sundry (which just makes sure modules without tests are importable).

So adding a test that will trigger this resource warning requires setting up a test_webbrowser file first, even before we get to the problem of how to test something that wants to start up a web browser...(but that should be solvable with unittest.mock, I think).

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15447>
_______________________________________
_______________________________________________
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

Jul 25, 2012, 7:01 AM

Post #7 of 10 (187 views)
Permalink
[issue15447] A file is not properly closed by webbrowser._invoke [In reply to]

Anton Barkovsky <swarmer.pm [at] gmail> added the comment:

Adding a patch that uses subprocess.DEVNULL instead.

Writing tests for webbrowser should be a separate issue, right?

----------
Added file: http://bugs.python.org/file26513/fileclose_devnull.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15447>
_______________________________________
_______________________________________________
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

Jul 25, 2012, 7:27 AM

Post #8 of 10 (182 views)
Permalink
[issue15447] A file is not properly closed by webbrowser._invoke [In reply to]

R. David Murray <rdmurray [at] bitdance> added the comment:

You could do it either way. Normally we prefer to have a test along with any fix; in this case adding a test involves adding the test module as well, but it is not different in principle. If you want to work on it and prefer to have it as a separate issue that's fine, we'll just make the test issue dependent on this one.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15447>
_______________________________________
_______________________________________________
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

Jul 30, 2012, 7:07 AM

Post #9 of 10 (182 views)
Permalink
[issue15447] A file is not properly closed by webbrowser._invoke [In reply to]

Anton Barkovsky added the comment:

An updated patch with the same issue fixed in Konqueror class.

----------
Added file: http://bugs.python.org/file26602/fileclose_devnull_v2.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15447>
_______________________________________
_______________________________________________
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 4, 2012, 10:54 AM

Post #10 of 10 (174 views)
Permalink
[issue15447] A file is not properly closed by webbrowser._invoke [In reply to]

Anton Barkovsky added the comment:

Added tests in #15557.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15447>
_______________________________________
_______________________________________________
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.