#969602 lptools: UnicodeDecodeError in lp-project-upload

Package:
lptools
Source:
lptools
Submitter:
Francois Marier
Date:
2020-12-07 19:51:06 UTC
Severity:
normal
Tags:
#969602#5
Date:
2020-09-05 20:52:53 UTC
From:
To:
I was unable to use lp-project-upload to upload a new release of safe-rm to
Launchpad:

  $ gpg --armor --sign --detach-sig safe-rm-0.13.tar.gz
  gpg: using "8C470B2A0B31568E110D432516281F2E007C98D1" as default secret key for signing
  $ lp-project-upload safe-rm 0.13 safe-rm-0.13.tar.gz
  Traceback (most recent call last):
    File "/usr/bin/lp-project-upload", line 175, in <module>
      main()
    File "/usr/bin/lp-project-upload", line 126, in main
      file_content = open(tarball, 'r').read()
    File "/usr/lib/python3.8/codecs.py", line 322, in decode
      (result, consumed) = self._buffer_decode(data, self.errors, final)
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

Looks like it might be a bug introduced from the Python 2 conversion of the
code.

Francois

#969602#10
Date:
2020-12-07 19:46:54 UTC
From:
To:
tags 969602 + patch
thanks

I just bumped into this. The solution is to open the release tarball and
its signature as binary, as follows. This should probably just be
squashed into debian/patches/02_python3:
--- a/bin/lp-project-upload 2020-12-07 19:40:42.000000000 +0000 +++ b/bin/lp-project-upload 2020-12-07 19:43:40.056335442 +0000 @@ -123,7 +123,7 @@ release = create_release(proj, version) # Get the file contents. - file_content = open(tarball, 'r').read() + file_content = open(tarball, 'rb').read() # Get the signature, if available. signature = tarball + '.asc' if not os.path.exists(signature): @@ -133,7 +133,7 @@ print('gpg failed, aborting', file=sys.stderr) if os.path.exists(signature): - signature_content = open(signature, 'r').read() + signature_content = open(signature, 'rb').read() else: signature_content = None