Submitter | Matt Harbison |
---|---|
Date | Sept. 5, 2018, 2:32 a.m. |
Message ID | <5a44192e15a600f244ee.1536114744@Envy> |
Download | mbox | patch |
Permalink | /patch/34324/ |
State | Superseded |
Headers | show |
Comments
On Tue, Sep 4, 2018 at 7:33 PM Matt Harbison <mharbison72@gmail.com> wrote: > # HG changeset patch > # User Matt Harbison <matt_harbison@yahoo.com> > # Date 1536114578 14400 > # Tue Sep 04 22:29:38 2018 -0400 > # Node ID 5a44192e15a600f244ee7b77a77a2add7731b61c > # Parent 197521083166579f6c80d7532ec6e919af2fe2cf > cbor: teach the encoder to handle python `long` type for Windows > > The tests for 2**32 and -7000000000 were blowing up, complaining about not > knowing how to encode type 'long'. sys.maxint tops out at 2**31-1 on > Windows, > but I guess is 2^63-1 on Linux? I *think* we're OK on the decode side, as > there > is an assertion that the decoded value is equal to the original primitive > value. > > diff --git a/mercurial/utils/cborutil.py b/mercurial/utils/cborutil.py > --- a/mercurial/utils/cborutil.py > +++ b/mercurial/utils/cborutil.py > @@ -190,6 +190,7 @@ def streamencodenone(v): > STREAM_ENCODERS = { > bytes: streamencodebytestring, > int: streamencodeint, > + long: streamencodeint, > This is the reasonable thing to do. However, `long` is not a type on Python 3. So we need to make this conditional on the presence of the `long` type. But we don't seem to have `long` aliased in pycompat. Maybe we should? Or you could add a `try...except NameError` block below this dict and swallow the exception if `long` doesn't exist? > list: streamencodearray, > tuple: streamencodearray, > dict: streamencodemap, > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel >
Patch
diff --git a/mercurial/utils/cborutil.py b/mercurial/utils/cborutil.py --- a/mercurial/utils/cborutil.py +++ b/mercurial/utils/cborutil.py @@ -190,6 +190,7 @@ def streamencodenone(v): STREAM_ENCODERS = { bytes: streamencodebytestring, int: streamencodeint, + long: streamencodeint, list: streamencodearray, tuple: streamencodearray, dict: streamencodemap,