[issue11577] testcase for exception binhex.Error

2011-03-17 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

This is fixed on default as well, I just stuffed the merge so the history looks 
odd and the integration script didn't pick it up.

You can see the additional changes I made in the linked changeset:
- try/except with a flag to clean up implicitly created file objects when 
binhex.__init__ fails
- change the getfileinfo code to use a with statement so it is also more 
exception tolerant

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11577
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11577] testcase for exception binhex.Error

2011-03-16 Thread Arkady Koplyarov

New submission from Arkady Koplyarov akoplya...@rim.com:

Testcase for exception binhex.Error to increase test coverage.

--
components: Library (Lib), Tests
files: testcase_for_binhex_module.patch
keywords: patch
messages: 131159
nosy: arkady.koplyarov
priority: normal
severity: normal
status: open
title: testcase for exception binhex.Error
versions: Python 2.7
Added file: http://bugs.python.org/file21248/testcase_for_binhex_module.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11577
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11577] testcase for exception binhex.Error

2011-03-16 Thread Brian Curtin

Changes by Brian Curtin br...@python.org:


--
nosy: +brian.curtin

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11577
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11577] testcase for exception binhex.Error

2011-03-16 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
nosy: +ncoghlan

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11577
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11577] testcase for exception binhex.Error

2011-03-16 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

unittest provides a utility to help with testing that correct exceptions are 
raised:

http://docs.python.org/dev/library/unittest#unittest.TestCase.assertRaises

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11577
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11577] testcase for exception binhex.Error

2011-03-16 Thread Arkady Koplyarov

Arkady Koplyarov akoplya...@rim.com added the comment:

The testcase updated accordingly to Nick Coghlan's suggestion to use 
assertRaises() since the testcase deals with an exception.

--
Added file: http://bugs.python.org/file21252/testcase_for_binhex_module_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11577
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11577] testcase for exception binhex.Error

2011-03-16 Thread Arkady Koplyarov

Arkady Koplyarov akoplya...@rim.com added the comment:

The testcase provided shows up a resource leakage:
-
C:\_cpython\cpythonPCbuild\python_d.exe  -m test.regrtest test_binhex
[1/1] test_binhex
C:\_cpython\cpython\lib\unittest\case.py:574: ResourceWarning: unclosed file 
_io.BufferedWriter name='@test_5592_tmp2'
  callableObj(*args, **kwargs)
1 test OK.
-
The resource leakage occurs in module binhex.py in binhex(inp,out)  
BinHex.__init__()  _writeinfo() when the exception binhex.Error is raised in 
_writeinfo() at the code line:
raise Error('Filename too long')
The issue is that when the exception is thrown the file is left unclosed.

One of possible fixes is to catch the thrown exception and close the unclosed 
file in the BinHex.__init__().

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11577
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11577] testcase for exception binhex.Error

2011-03-16 Thread SilentGhost

SilentGhost ghost@gmail.com added the comment:

Arkady, I don't see why you need to catch exception. Just wrap the _writeinfo 
call into a try-finally block, and close ofp in the finally.

--
nosy: +SilentGhost

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11577
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11577] testcase for exception binhex.Error

2011-03-16 Thread Arkady Koplyarov

Arkady Koplyarov akoplya...@rim.com added the comment:

Well, I believe that in BinHex.__init__() I cannot just wrap the _writeinfo 
call into a try-finally block, and close ofp in the finally.

I see that in the case of normal operation when the exception is not thrown, 
the output file descriptor ofp is used in binhex(inp,out) as a result of 
BinHex.__init__() and so need remain open until binhex(inp,out) close it 
explicitly.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11577
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11577] testcase for exception binhex.Error

2011-03-16 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset 5c2d15c6007e by Nick Coghlan in branch '3.2':
Close #11577: Improve binhex test coverage and fix ResourceWarning
http://hg.python.org/cpython/rev/5c2d15c6007e

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11577
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com