From 3ba27ffb6ae995c27608f84eef0abe636e2e63da Mon Sep 17 00:00:00 2001 From: Dylann Cordel Date: Thu, 22 Apr 2021 17:44:39 +0200 Subject: [PATCH] fix: update user's bool data and avatar If we want to update email, avatar and do not send email confirmation change (`skip_reconfirmation` = True), `MultipartEncoder` will try to encode everything except None and bytes. So it tries to encode bools. Casting bool's values to their stringified int representation fix it. --- gitlab/client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gitlab/client.py b/gitlab/client.py index 7927b3f6f..3f28eb956 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -505,6 +505,12 @@ def http_request( json = None if post_data is None: post_data = {} + else: + # booleans does not exists for data (neither for MultipartEncoder): + # cast to string int to avoid: 'bool' object has no attribute 'encode' + for k, v in post_data.items(): + if isinstance(v, bool): + post_data[k] = str(int(v)) post_data["file"] = files.get("file") post_data["avatar"] = files.get("avatar") data = MultipartEncoder(post_data)