[issue37560] with cgi.FieldStorage(...) fails on cleanup with AttributeError, missing try/except in __exit__

2019-07-17 Thread Ngalim Siregar


Change by Ngalim Siregar :


--
keywords: +patch
pull_requests: +14609
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/14815

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37560] with cgi.FieldStorage(...) fails on cleanup with AttributeError, missing try/except in __exit__

2019-07-11 Thread Stefanik Gábor

New submission from Stefanik Gábor :

cgi.FieldStorage has this for its __del__ method:

def __del__(self):
try:
self.file.close()
except AttributeError:
pass

By contrast, __exit__ is missing the exception handler:

def __exit__(self, *args):
self.file.close()

Because self.file isn't populated in every instance of the FieldStorage class, 
this can cause FieldStorage to fail with AttributeError when used in a with 
statement.

--
components: Library (Lib)
messages: 347667
nosy: Stefanik Gábor
priority: normal
severity: normal
status: open
title: with cgi.FieldStorage(...) fails on cleanup with AttributeError, missing 
try/except in __exit__
type: behavior
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com