From 5f383414b391fb50656dfdab43496884dff45460 Mon Sep 17 00:00:00 2001 From: "guangjun.hgj" Date: Thu, 25 May 2023 20:14:32 +0800 Subject: [PATCH] update code. --- oss2/api.py | 2 ++ oss2/xml_utils.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/oss2/api.py b/oss2/api.py index 07d7f8fe..1b4b6860 100644 --- a/oss2/api.py +++ b/oss2/api.py @@ -1085,6 +1085,8 @@ def object_exists(self, key, headers=None): self.get_object_meta(key, headers=headers) except exceptions.NoSuchKey: return False + except exceptions.NoSuchBucket: + raise except exceptions.NotFound: return False except: diff --git a/oss2/xml_utils.py b/oss2/xml_utils.py index 1cc7b9f3..6528505e 100644 --- a/oss2/xml_utils.py +++ b/oss2/xml_utils.py @@ -223,7 +223,7 @@ def parse_list_buckets(result, body): if result.is_truncated: result.next_marker = _find_tag(root, 'NextMarker') - if root.find('Owner'): + if root.find('Owner') is not None: result.owner = Owner(_find_tag_with_default(root, 'Owner/DisplayName', None), _find_tag_with_default(root, 'Owner/ID', None)) for bucket_node in root.findall('Buckets/Bucket'):