git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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 Laux
Thanks 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/

Previous: Hunter Laux
Message 2 of 2 in “Git-p4 UnicodeDecodeError on ascii 0x93 character”
  1. Hunter LauxFeb 26, 2022
  2. Torsten B��gershausenFeb 26, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.