diff options
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-x | Lib/cgi.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py index 06e03b5858..1d8040cc7a 100755 --- a/Lib/cgi.py +++ b/Lib/cgi.py @@ -80,7 +80,7 @@ def initlog(*allargs): if logfile and not logfp: try: logfp = open(logfile, "a") - except IOError: + except OSError: pass if not logfp: log = nolog @@ -552,6 +552,12 @@ class FieldStorage: else: self.read_single() + def __del__(self): + try: + self.file.close() + except AttributeError: + pass + def __repr__(self): """Return a printable representation.""" return "FieldStorage(%r, %r, %r)" % ( @@ -670,7 +676,6 @@ class FieldStorage: encoding=self.encoding, errors=self.errors) for key, value in query: self.list.append(MiniFieldStorage(key, value)) - FieldStorageClass = None klass = self.FieldStorageClass or self.__class__ first_line = self.fp.readline() # bytes @@ -958,8 +963,8 @@ def print_directory(): print("<H3>Current Working Directory:</H3>") try: pwd = os.getcwd() - except os.error as msg: - print("os.error:", html.escape(str(msg))) + except OSError as msg: + print("OSError:", html.escape(str(msg))) else: print(html.escape(pwd)) print() |