Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/cborutil.py @ 49033:bce8f66d3045
cborutil: remove Python 2 definition of _elementtointeger()
Differential Revision: https://phab.mercurial-scm.org/D12348
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 01 Mar 2022 20:53:52 -0800 |
parents | 176f1a0d15dc |
children | 642e31cb55f0 |
comparison
equal
deleted
inserted
replaced
49032:fd5b8e696b75 | 49033:bce8f66d3045 |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 | 8 |
9 import struct | 9 import struct |
10 import sys | |
11 | 10 |
12 | 11 |
13 # Very short very of RFC 7049... | 12 # Very short very of RFC 7049... |
14 # | 13 # |
15 # Each item begins with a byte. The 3 high bits of that byte denote the | 14 # Each item begins with a byte. The 3 high bits of that byte denote the |
244 | 243 |
245 class CBORDecodeError(Exception): | 244 class CBORDecodeError(Exception): |
246 """Represents an error decoding CBOR.""" | 245 """Represents an error decoding CBOR.""" |
247 | 246 |
248 | 247 |
249 if sys.version_info.major >= 3: | 248 def _elementtointeger(b, i): |
250 | 249 return b[i] |
251 def _elementtointeger(b, i): | |
252 return b[i] | |
253 | |
254 | |
255 else: | |
256 | |
257 def _elementtointeger(b, i): | |
258 return ord(b[i]) | |
259 | 250 |
260 | 251 |
261 STRUCT_BIG_UBYTE = struct.Struct('>B') | 252 STRUCT_BIG_UBYTE = struct.Struct('>B') |
262 STRUCT_BIG_USHORT = struct.Struct(b'>H') | 253 STRUCT_BIG_USHORT = struct.Struct(b'>H') |
263 STRUCT_BIG_ULONG = struct.Struct(b'>L') | 254 STRUCT_BIG_ULONG = struct.Struct(b'>L') |