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

Git-p4 UnicodeDecodeError on ascii 0x93 character

From
HLHunter Laux <hunterlaux@gmail.com>
Date
Feb 26, 2022, 05:20 UTC
Message-ID
<CAMQF8MhTmVs_LE8Te=9EL66Py8OtAMo7APf-cC=Ot6tykvaBpg@mail.gmail.com>

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
Next: Torsten B��gershausen
Message 1 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.