Description
In my packed-refs file, following contents:
# pack-refs with: peeled fully-peeled sorted
a5052c65b74b79851e9b91589a83906deb434b8a refs/heads/master
a9a4140068e7108a57cf038c2864def8e27f06d9 refs/heads/test
a5052c65b74b79851e9b91589a83906deb434b8a refs/remotes/origin/commit_test
a5052c65b74b79851e9b91589a83906deb434b8a refs/remotes/origin/master
a9a4140068e7108a57cf038c2864def8e27f06d9 refs/remotes/origin/test
baf762435d9145df5d498962d9c6a4ca9825c66e refs/remotes/origin/ttt
df5227b1e584215e9f69a577b7b284230b5a5e1d refs/tags/테스트
^a9a4140068e7108a57cf038c2864def8e27f06d9
problem encounter from df5227b1e584215e9f69a577b7b284230b5a5e1d refs/tags/테스트
,
and error message here:
File "C:\Users\admin\AppData\Local\Programs\Python\Python36\lib\site-packages\git\repo\base.py", line 269, in heads
return Head.list_items(self)
File "C:\Users\admin\AppData\Local\Programs\Python\Python36\lib\site-packages\git\util.py", line 934, in list_items
out_list.extend(cls.iter_items(repo, *args, **kwargs))
File "C:\Users\admin\AppData\Local\Programs\Python\Python36\lib\site-packages\git\refs\symbolic.py", line 617, in _iter_items
for sha, rela_path in cls._iter_packed_refs(repo): # @UnusedVariable
File "C:\Users\admin\AppData\Local\Programs\Python\Python36\lib\site-packages\git\refs\symbolic.py", line 94, in _iter_packed_refs
for line in fp:
UnicodeDecodeError: 'cp949' codec can't decode byte 0xed in position 485: illegal multibyte sequence
(This is not common case of naming for branch or tags name as non-english. but, I need handing for this problem.)
problem point is line no.94 at _iter_packed_refs
in symbolic.py
.
line 93:with open(osp.join(repodir, ref_path), 'rt') as fp:
line 94: value = fp.read().rstrip()
when open as fp
, properties has
fp: <_io.TextIOWrapper name='some\\path\\.git\\packed-refs' mode='rt' encoding='cp949'>
and next line value = fp.read().rstrip()
, this builtin lib can not read non-unicode string
I think, this expected encoding is 'utf-8'
or 'unicode'
, but is setting for default system language encoder.
So, I modified this line(no.93 and 148 at symbolic.py) for that
#with open(cls._get_packed_refs_path(repo), 'rt') as fp:
#modify: encoding option setting for multilanguage
with open(cls._get_packed_refs_path(repo), 'rt', encoding='utf-8') as fp:
after this modify, it has no problem! but, I worried about some side-effect.
few source code used yet open()
function, I can not certain for every coverage from os, encoding system and etc.
please check this problem.