GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — UnicodeDecodeError when looking at the tagged_date · Issue #943 · gitpython-developers/GitPython

UnicodeDecodeError when looking at the tagged_date #943

New issue
Copy link
New issue
Copy link
Closed
Closed
UnicodeDecodeError when looking at the tagged_date#943
Copy link
Labels
acknowledged

Description

@cydan33
cydan33
opened on Oct 16, 2019
Issue body actions

I 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.

Activity

  1. Byron
    added
    acknowledged
    help wanted
    on Oct 18, 2019
  2. Byron commented on Oct 18, 2019

    @Byron
    Byron
    on Oct 18, 2019
    Member
    More actions

    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.

  3. Harmon758 commented on Feb 18, 2020

    @Harmon758
    Harmon758
    on Feb 18, 2020
    Member
    More actions

    I'm unable to reproduce this now.
    Is this still an issue? If so, can you please provide details about your environment?

  4. Harmon758
    added
    cannot reproduce
    waiting for feedback
    and removed
    help wanted
    on Feb 18, 2020
  5. 3droj7 commented on Feb 20, 2020

    @3droj7
    3droj7
    on Feb 20, 2020
    More actions

    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
    
    
  6. Harmon758
    removed
    cannot reproduce
    waiting for feedback
    on Feb 20, 2020
  7. Harmon758
    added a commit that references this issue on Feb 20, 2020

    Replace invalid bytes when decoding TagObject stream

    This issue will close once commit a244bd1 is merged into the 'master' branch.
    a244bd1
  8. Harmon758
    closed this as completedin a244bd1on Feb 20, 2020
  9. Harmon758 commented on Feb 20, 2020

    @Harmon758
    Harmon758
    on Feb 20, 2020
    Member
    More actions

    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:

    image

    Although GitPython uses the filesystem's encoding rather than looking at the encoding header, that's a separate issue.

  10. wip-sync
    added a commit that references this issue on Mar 7, 2020

    py-git: update to 3.1.0.

    cc95dab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.