Re: Git-p4 UnicodeDecodeError on ascii 0x93 character
- From
Torsten B��gershausen <tboegi@web.de>
- Date
- Feb 26, 2022, 09:39 UTC
- Message-ID
- <20220226093929.uujvrauwatssl2mw@tb-raspi4>
- In-Reply-To
- <CAMQF8MhTmVs_LE8Te=9EL66Py8OtAMo7APf-cC=Ot6tykvaBpg@mail.gmail.com>
On Fri, Feb 25, 2022 at 09:20:51PM -0800, Hunter Laux wrote:
Show 48 quoted lines
> One of my p4 commits has an ???(0x93) character in the p4 description
> and I'm trying to export it to git.
> I'm using the latest git-p4.py as of c70bc33.
>
> I think python2 didn't throw an error, but python3 now treats this as an error.
> The error is.
> Traceback (most recent call last):
> File "/home/hlaux/.local/bin/git-p4", line 4292, in <module>
> main()
> File "/home/hlaux/.local/bin/git-p4", line 4286, in main
> if not cmd.run(args):
> File "/home/hlaux/.local/bin/git-p4", line 4043, in run
> if not P4Sync.run(self, depotPaths):
> File "/home/hlaux/.local/bin/git-p4", line 3910, in run
> self.importRevisions(args, branch_arg_given)
> File "/home/hlaux/.local/bin/git-p4", line 3658, in importRevisions
> changes = p4ChangesForPaths(self.depotPaths, self.changeRange,
> self.changes_block_size)
> File "/home/hlaux/.local/bin/git-p4", line 1080, in p4ChangesForPaths
> result = p4CmdList(cmd, errors_as_exceptions=True)
> File "/home/hlaux/.local/bin/git-p4", line 711, in p4CmdList
> value = value.decode()
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position
> 21: invalid start byte
>
> This patch seems to work.
>
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -707,7 +707,7 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b',
> cb=None, skip_info=False,
> for key, value in entry.items():
> key = key.decode()
> if isinstance(value, bytes) and not (key in
> ('data', 'path', 'clientFile') or key.startswith('depotFile')):
> - value = value.decode()
> + value = value.decode('latin1')
> decoded_entry[key] = value
> # Parse out data if it's an error response
> if decoded_entry.get('code') == 'error' and 'data' in
> decoded_entry:
>
>
> Does anyone have a better fix?
>
> Thanks,
>
> Hunter LauxThanks for reporting.
I think there was a patch for this problem some time ago: https://lore.kernel.org/git/20210422050504.441-1-tzadik.vanderhoof@gmail.com/