summaryrefslogtreecommitdiff
path: root/gitlab/base.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2017-09-19 08:01:41 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2017-09-19 08:01:41 +0200
commite09581fccba625e4a0cf9eb67de2a9471fce3b9d (patch)
treefd5eb5960cd4900a6779747825cd491ef7c79b5a /gitlab/base.py
parent89bf53f577fa8952902179b176ae828eb5701633 (diff)
downloadgitlab-e09581fccba625e4a0cf9eb67de2a9471fce3b9d.tar.gz
Fix the labels attrs on MR and issues
Fixes #306
Diffstat (limited to 'gitlab/base.py')
-rw-r--r--gitlab/base.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/gitlab/base.py b/gitlab/base.py
index 01f6903..ccc9e4a 100644
--- a/gitlab/base.py
+++ b/gitlab/base.py
@@ -564,7 +564,24 @@ class RESTObject(object):
return self.__dict__['_updated_attrs'][name]
except KeyError:
try:
- return self.__dict__['_attrs'][name]
+ value = self.__dict__['_attrs'][name]
+
+ # If the value is a list, we copy it in the _updated_attrs dict
+ # because we are not able to detect changes made on the object
+ # (append, insert, pop, ...). Without forcing the attr
+ # creation __setattr__ is never called, the list never ends up
+ # in the _updated_attrs dict, and the update() and save()
+ # method never push the new data to the server.
+ # See https://github.com/python-gitlab/python-gitlab/issues/306
+ #
+ # note: _parent_attrs will only store simple values (int) so we
+ # don't make this check in the next except block.
+ if isinstance(value, list):
+ self.__dict__['_updated_attrs'][name] = value[:]
+ return self.__dict__['_updated_attrs'][name]
+
+ return value
+
except KeyError:
try:
return self.__dict__['_parent_attrs'][name]