From 29025829b5471aaa0e6cebc27165e3d9c5ef0024 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Tue, 14 Jan 2020 13:46:33 -0800 Subject: [PATCH] fix: add try/except for deleting file handler in destructor --- googleapiclient/http.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/googleapiclient/http.py b/googleapiclient/http.py index 5b5ea159897..8f3dbcfc665 100644 --- a/googleapiclient/http.py +++ b/googleapiclient/http.py @@ -575,7 +575,10 @@ def __init__( ) def __del__(self): - self._fd.close() + try: + self._fd.close() + except AttributeError: + pass def to_json(self): """Creating a JSON representation of an instance of MediaFileUpload.