Mercurial > public > mercurial-scm > hg
comparison mercurial/utils/cborutil.py @ 39456:8d858fbf2759
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.
I opted for the pycompat alias instead of swallowing the NameError because the
vendored cbor package uses an alias, and I see at least pywatchman and
templatefilters open codes their own aliases.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 04 Sep 2018 22:29:38 -0400 |
parents | babad5ebaf0a |
children | 62160d3077cd |
comparison
equal
deleted
inserted
replaced
39453:ab452995eaff | 39456:8d858fbf2759 |
---|---|
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import struct | 10 import struct |
11 import sys | 11 import sys |
12 | |
13 from .. import pycompat | |
12 | 14 |
13 # Very short very of RFC 7049... | 15 # Very short very of RFC 7049... |
14 # | 16 # |
15 # Each item begins with a byte. The 3 high bits of that byte denote the | 17 # Each item begins with a byte. The 3 high bits of that byte denote the |
16 # "major type." The lower 5 bits denote the "subtype." Each major type | 18 # "major type." The lower 5 bits denote the "subtype." Each major type |
188 yield b'\xf6' | 190 yield b'\xf6' |
189 | 191 |
190 STREAM_ENCODERS = { | 192 STREAM_ENCODERS = { |
191 bytes: streamencodebytestring, | 193 bytes: streamencodebytestring, |
192 int: streamencodeint, | 194 int: streamencodeint, |
195 pycompat.long: streamencodeint, | |
193 list: streamencodearray, | 196 list: streamencodearray, |
194 tuple: streamencodearray, | 197 tuple: streamencodearray, |
195 dict: streamencodemap, | 198 dict: streamencodemap, |
196 set: streamencodeset, | 199 set: streamencodeset, |
197 bool: streamencodebool, | 200 bool: streamencodebool, |