classification
Title: with cgi.FieldStorage(...) fails on cleanup with AttributeError, missing try/except in __exit__
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Stefanik Gábor
Priority: normal Keywords: patch

Created on 2019-07-11 10:02 by Stefanik Gábor, last changed 2019-07-17 15:48 by nsiregar.

Pull Requests
URL Status Linked Edit
PR 14815 open nsiregar, 2019-07-17 15:48
Messages (1)
msg347667 - (view) Author: Stefanik Gábor (Stefanik Gábor) Date: 2019-07-11 10:02
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.
History
Date User Action Args
2019-07-17 15:48:46nsiregarsetkeywords: + patch
stage: patch review
pull_requests: + pull_request14609
2019-07-11 10:02:13Stefanik Gáborcreate