diff options
author | biao716.wang <biao716.wang@samsung.com> | 2023-09-20 15:38:26 +0900 |
---|---|---|
committer | biao716.wang <biao716.wang@samsung.com> | 2023-09-21 17:38:03 +0900 |
commit | d878acae51c987f5713b4e068d150fda223e2f2c (patch) | |
tree | 19c777cb4868ab0fe5013d1fb629a4f69de9decc | |
parent | 691c27ee4a50f70634a0b194796724d141b96842 (diff) | |
download | git-buildpackage-d878acae51c987f5713b4e068d150fda223e2f2c.tar.gz git-buildpackage-d878acae51c987f5713b4e068d150fda223e2f2c.tar.bz2 git-buildpackage-d878acae51c987f5713b4e068d150fda223e2f2c.zip |
Ignore encoding error when open spec filedebian/0.9.27
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>
-rw-r--r-- | gbp/rpm/__init__.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py index 54e9e6a9..926f66e4 100644 --- a/gbp/rpm/__init__.py +++ b/gbp/rpm/__init__.py @@ -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 |