- Notifications
You must be signed in to change notification settings - Fork673
Closed
Description
Hi there,
Using Python 3.5 and python-gitlab 0.16, i can't save some file content to Gitlab.
More specifically, running this code
from pathlib import Pathpath = Path('..')/'test.txt' # Text file with contents "Goodbye, world"project_id = 'secret_ID'file_path = 'data/' + path.namef = gl.project_files.get(file_path=file_path, ref='master', project_id=project_id) f.content = base64.b64encode(path.open('rb').read())f.save(branch_name='master', commit_message='Updated ' + file_path , encoding='base64')
i get this error
TypeError Traceback (most recent call last)<ipython-input-17-7015cf3aaaad> in <module>() 12 13 f.content = base64.b64encode(path.open('rb').read())---> 14 f.save(branch_name='master', commit_message='Updated ' + file_path , encoding='base64')/home/hidden_user/.virtualenvs/hidden_dir/lib/python3.5/site-packages/gitlab/objects.py in save(self, **kwargs) 318 def save(self, **kwargs): 319 if self._from_api:--> 320 self._update(**kwargs) 321 else: 322 self._create(**kwargs)/home/hidden_user/.virtualenvs/hidden_dir/lib/python3.5/site-packages/gitlab/objects.py in _update(self, **kwargs) 313 raise NotImplementedError 314 --> 315 json = self.gitlab.update(self, **kwargs) 316 self._set_from_dict(json) 317 /home/hidden_user/.virtualenvs/hidden_dir/lib/python3.5/site-packages/gitlab/__init__.py in update(self, obj, **kwargs) 621 622 # build data that can really be sent to server--> 623 data = obj._data_for_gitlab(extra_parameters=kwargs, update=True) 624 625 r = self._raw_put(url, data=data, content_type='application/json')/home/hidden_user/.virtualenvs/hidden_dir/lib/python3.5/site-packages/gitlab/objects.py in _data_for_gitlab(self, extra_parameters, update, as_json) 227 data.update(extra_parameters) 228 --> 229 return json.dumps(data) if as_json else data 230 231 @classmethod/usr/lib/python3.5/json/__init__.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw) 228 cls is None and indent is None and separators is None and 229 default is None and not sort_keys and not kw):--> 230 return _default_encoder.encode(obj) 231 if cls is None: 232 cls = JSONEncoder/usr/lib/python3.5/json/encoder.py in encode(self, o) 196 # exceptions aren't as detailed. The list call should be roughly 197 # equivalent to the PySequence_Fast that ''.join() would do.--> 198 chunks = self.iterencode(o, _one_shot=True) 199 if not isinstance(chunks, (list, tuple)): 200 chunks = list(chunks)/usr/lib/python3.5/json/encoder.py in iterencode(self, o, _one_shot) 254 self.key_separator, self.item_separator, self.sort_keys, 255 self.skipkeys, _one_shot)--> 256 return _iterencode(o, 0) 257 258 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,/usr/lib/python3.5/json/encoder.py in default(self, o) 177 178 """--> 179 raise TypeError(repr(o) + " is not JSON serializable") 180 181 def encode(self, o):TypeError: b'R29vZGJ5ZSwgd29ybGQK' is not JSON serializable
Metadata
Metadata
Assignees
Labels
No labels