Ignore encoding error when open spec file 19/299119/2 debian/0.9.27
authorbiao716.wang <biao716.wang@samsung.com>
Wed, 20 Sep 2023 06:38:26 +0000 (15:38 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Thu, 21 Sep 2023 08:38:03 +0000 (17:38 +0900)
for example: capi_context.spec the encoding way is "EUC-KR"
import chardet
>>> chardet.detect(open('capi-context.spec', 'rb').read())['encoding']
'EUC-KR'
but default encoding is utf-8.
Change-Id: Ib22e0b6101c6bada2945b11b6883790a975c7acb
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
gbp/rpm/__init__.py

index 54e9e6a..926f66e 100644 (file)
@@ -138,7 +138,7 @@ class SpecFile(object):
             self.specfile = os.path.basename(filename)
             self.specdir = os.path.dirname(os.path.abspath(filename))
             try:
-                with open(filename) as spec_file:
+                with open(filename, errors='ignore') as spec_file:
                     for line in spec_file.readlines():
                         self._content.append(line)
             except IOError as err:
@@ -870,7 +870,7 @@ def guess_spec_repo(repo, treeish, topdir='', recursive=True, preferred_name=Non
 def spec_from_repo(repo, treeish, spec_path):
     """Get and parse a spec file from a give Git treeish"""
     try:
-        spec = SpecFile(filedata=repo.show('%s:%s' % (treeish, spec_path)).decode())
+        spec = SpecFile(filedata=repo.show('%s:%s' % (treeish, spec_path)).decode(errors='ignore'))
         spec.specdir = os.path.dirname(spec_path)
         spec.specfile = os.path.basename(spec_path)
         return spec