fix(s3): check whether key is None or not to avoid exception.
``` AttributeError: 'NoneType' object has no attribute 'multipart' ```
This commit is contained in:
parent
4da9ec1346
commit
98f33740e1
@ -1107,7 +1107,7 @@ class S3Backend(BaseBackend):
|
|||||||
key = key_version
|
key = key_version
|
||||||
break
|
break
|
||||||
|
|
||||||
if part_number and key.multipart:
|
if part_number and key and key.multipart:
|
||||||
key = key.multipart.parts[part_number]
|
key = key.multipart.parts[part_number]
|
||||||
|
|
||||||
if isinstance(key, FakeKey):
|
if isinstance(key, FakeKey):
|
||||||
|
@ -1534,6 +1534,18 @@ def test_boto3_get_object():
|
|||||||
e.exception.response['Error']['Code'].should.equal('NoSuchKey')
|
e.exception.response['Error']['Code'].should.equal('NoSuchKey')
|
||||||
|
|
||||||
|
|
||||||
|
@mock_s3
|
||||||
|
def test_boto3_get_missing_object_with_part_number():
|
||||||
|
s3 = boto3.resource('s3', region_name='us-east-1')
|
||||||
|
s3.create_bucket(Bucket="blah")
|
||||||
|
|
||||||
|
with assert_raises(ClientError) as e:
|
||||||
|
s3.Object('blah', 'hello.txt').meta.client.head_object(
|
||||||
|
Bucket='blah', Key='hello.txt', PartNumber=123)
|
||||||
|
|
||||||
|
e.exception.response['Error']['Code'].should.equal('404')
|
||||||
|
|
||||||
|
|
||||||
@mock_s3
|
@mock_s3
|
||||||
def test_boto3_head_object_with_versioning():
|
def test_boto3_head_object_with_versioning():
|
||||||
s3 = boto3.resource('s3', region_name='us-east-1')
|
s3 = boto3.resource('s3', region_name='us-east-1')
|
||||||
|
Loading…
Reference in New Issue
Block a user