Fix Python 3.x compatibility issues with demarshalling Perforce data.
Review Request #10666 — Created Aug. 21, 2019 and submitted
When we call out to
p4, we often request data in a marshalled form.
These come back as byte strings, and on Python 3.x, this prevents us
from properly looking up all sorts of data from them (error results,
change status, etc.). We had a single place that attempted to handle
this, which was the fetching of a change description, but nowhere else.
We now normalize the string types before we hand it back to the caller,
ensuring that all keys and string values are Unicode. This is based in
part on Perforce's own documentation on demarshalling on Python 3.x
(though fixes an issue they have involving int values, found in error
Ran a handful of tests locally, including
commands, testing againt Perforce change numbers and with change
descriptions utilizing various Unicode characters (including Emoji).
While these failed before (with
rbt postclaiming the path was
rbt diffjust raising a
KeyError), both now work
- Redid a comment, fixing a typo and making it a lot easier to understand.
- Added logging and a proper exception if we ever get decoded data back from Perforce that's in a format we don't expect.
- Improved the docstring for
- Fixed some exception messages un
run_p4()to not include newlines.
Revision 2 (+49 -7)
Checks run (2 succeeded)