git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Git-p4 UnicodeDecodeError on ascii 0x93 character
@ 2022-02-26  5:20 Hunter Laux
  2022-02-26  9:39 ` Torsten =?unknown-8bit?Q?B=C3=B6gershausen?=
  0 siblings, 1 reply; 2+ messages in thread
From: Hunter Laux @ 2022-02-26  5:20 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-26  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-26  5:20 Git-p4 UnicodeDecodeError on ascii 0x93 character Hunter Laux
2022-02-26  9:39 ` Torsten =?unknown-8bit?Q?B=C3=B6gershausen?=

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).