Skip to content

ImageXService的get_upload_auth方法参数默认值错误 #61

Description

@mrgaolei
    def get_upload_auth(self, service_ids, expire=60 * 60, key_ptn='', tag=dict):
        apply_res = []
        commit_res = []
        if len(service_ids) == 0:
            apply_res.append(ResourceServiceIdTRN % '*')
            commit_res.append(ResourceServiceIdTRN % '*')
        else:
            for sid in service_ids:
                apply_res.append(ResourceServiceIdTRN % sid)
                commit_res.append(ResourceServiceIdTRN % sid)
        apply_res.append(ResourceStoreKeyTRN % key_ptn)

        inline_policy = Policy([
            Statement.new_allow_statement(
                ['ImageX:ApplyImageUpload'], apply_res),
            Statement.new_allow_statement(
                ['ImageX:CommitImageUpload'], commit_res)
        ])
        for k, v in tag.items():
            inline_policy.statements.append(Statement.new_allow_statement([k], [str(v)]))
        return self.sign_sts2(inline_policy, expire)

参数tag默认值dict没有实例化,导致如果不传参数,下面循环时会抛出异常:
for k, v in tag.items():
^^^^^^^^^^^
TypeError: unbound method dict.items() needs an argument

这里应该是tag=dict()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions