iLCSoft / iLCInstall

Python scripts to install iLCSoft software and dependencies
GNU General Public License v3.0
4 stars 26 forks source link

Unicode error using ilcsofttagger #129

Closed vvolkl closed 3 years ago

vvolkl commented 3 years ago

encountered while making v00-03 of edm4hep:

INFO  - Tagger  : Committing release notes for: key4hep/edm4hep
Traceback (most recent call last):
  File "./ilcsofttagger.py", line 231, in <module>
    RUNNER.run()
  File "./ilcsofttagger.py", line 214, in run
    self._commitAndTag()
  File "./ilcsofttagger.py", line 190, in _commitAndTag
    package.commitNewReleaseNotes()
  File "/home/vavolkl/repo/iLCInstall/scripts/tagging/gitinterface.py", line 361, in commitNewReleaseNotes
    contentEncoded = contentNew.encode('base64')
  File "/usr/lib/python2.7/encodings/base64_codec.py", line 24, in base64_encode
    output = base64.encodestring(input)
  File "/usr/lib/python2.7/base64.py", line 322, in encodestring
    pieces.append(binascii.b2a_base64(chunk))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 27: ordinal not in range(128)

had to use the following patch to make it work:

diff --git a/scripts/tagging/gitinterface.py b/scripts/tagging/gitinterface.py
index a2539f4..1c8046e 100644
--- a/scripts/tagging/gitinterface.py
+++ b/scripts/tagging/gitinterface.py
@@ -358,6 +358,7 @@ class Repo(object):
       content = "\n".join(content.split("\n")[2:]) ## remove first line which is the release name
     contentNew = self.formatReleaseNotes() + "\n\n" + content

+    contentNew  = contentNew.encode("ascii", 'ignore')
     contentEncoded = contentNew.encode('base64')

     if encodedOld.replace("\n","") == contentEncoded.replace("\n",""):

I'm the culprit here actually, since I accidentally used a "Horizontal ellipsis" in https://github.com/key4hep/edm4hep/pull/97

@andresailer would be good to make this more robust - should I open a PR?

andresailer commented 3 years ago

This would just drop whatever character it doesn't know potentially silently mangling the output? I just removed the offending character from the release notes part of your PR.