GeezerVison is showing github.com — UnicodeDecodeError when looking at the tagged_date · Issue #943 · gitpython-developers/GitPython
UnicodeDecodeError when looking at the tagged_date #943DescriptionI can't get the tagged date for some repository tags.
For example -
import git
r = git.Repo.clone_from("https://github.com/nodejs/node", "/tmp/nodegit")
t = r.tags[10]
t.object.tagged_date
Error -
~/.local/lib/python3.7/site-packages/gitdb/util.py in __getattr__(self, attr)
251 to be created and set. Next time the same attribute is reqeusted, it is simply
252 returned from our dict/slots. """
--> 253 self._set_cache_(attr)
254 # will raise in case the cache was not created
255 return object.__getattribute__(self, attr)
/tmp/GitPython/git/objects/tag.py in _set_cache_(self, attr)
51 if attr in TagObject.__slots__:
52 ostream = self.repo.odb.stream(self.binsha)
---> 53 lines = ostream.read().decode(defenc).splitlines()
54
55 _obj, hexsha = lines[0].split(" ")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 392: invalid continuation byte
It happens for the following repositories -
https://github.com/nodejs/node (tag "v0.1.0")
https://github.com/OpenVPN/openvpn (tag "v2.3.1")
It reproduces in the latest version. ActivityByron commented on Oct 18, 2019 Thanks for posting. and for providing the information needed for reproduction! This helps a lot.
Unfortunately, I don't see a way to fix it as UTF-8 is assumed as default encoding. It can't be overridden unless the value of sys.getdefaultencoding() is different on python startup.
A preferable solution would be to not assume any encoding and instead work on bytes. Harmon758 commented on Feb 18, 2020 I'm unable to reproduce this now.
Is this still an issue? If so, can you please provide details about your environment? 3droj7 commented on Feb 20, 2020 Yeah it still happens, just not in the 10th tag but the 7th
import git
r = git.Repo.clone_from("https://github.com/nodejs/node", "/tmp/nodegit")
t = r.tags[7]
t.object.tagged_date
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-5-c80fb16d948c> in <module>
----> 1 t.object.tagged_date
/usr/local/lib/python3.7/dist-packages/gitdb/util.py in __getattr__(self, attr)
251 to be created and set. Next time the same attribute is reqeusted, it is simply
252 returned from our dict/slots. """
--> 253 self._set_cache_(attr)
254 # will raise in case the cache was not created
255 return object.__getattribute__(self, attr)
/usr/local/lib/python3.7/dist-packages/git/objects/tag.py in _set_cache_(self, attr)
51 if attr in TagObject.__slots__:
52 ostream = self.repo.odb.stream(self.binsha)
---> 53 lines = ostream.read().decode(defenc).splitlines()
54
55 _obj, hexsha = lines[0].split(" ")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 392: invalid continuation byte
added a commit that references this issue on Feb 20, 2020This issue will close once commit a244bd1 is merged into the 'master' branch.a244bd1 Harmon758 commented on Feb 20, 2020 I can't reproduce this with https://github.com/OpenVPN/openvpn/releases/tag/v2.3.1:
>>> import git
>>> r = git.Repo.clone_from("https://github.com/OpenVPN/openvpn", "/tmp/openvpn")
>>> r.tags[40].object.tag
'v2.3.1'
>>> r.tags[40].object.tagged_date
1364406784
However, the annotation for https://github.com/nodejs/node/releases/tag/v0.1.0 seems to be encoded in Latin-1 (ISO-8859-1), without having an encoding header for the tag specifying that.
Even git show fails to display the tag message properly, as it also assumes UTF-8:

Although GitPython uses the filesystem's encoding rather than looking at the encoding header, that's a separate issue.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|