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
payloads).
Ran a handful of tests locally, including
rbt diff
andrbt post
commands, testing againt Perforce change numbers and with change
descriptions utilizing various Unicode characters (including Emoji).While these failed before (with
rbt post
claiming the path was
invalid andrbt diff
just raising aKeyError
), both now work
as expected.
Description | From | Last Updated |
---|---|---|
typo: Perfore -> Perforce. This sentence also reads a little clunky. |
david |
- Change Summary:
-
- 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
run_p4()
. - Fixed some exception messages un
run_p4()
to not include newlines.
- Commit:
-
2dc54c131348574756795dd69f447ebb82ad9f4df50f73c503730d6d2486e30798c5b040f688c98d
- Diff:
-
Revision 2 (+49 -7)