~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/util/_bencode_py.py

  • Committer: Vincent Ladeuil
  • Date: 2017-01-30 14:30:10 UTC
  • mfrom: (6615.3.7 merges)
  • mto: This revision was merged to the branch mainline in revision 6621.
  • Revision ID: v.ladeuil+lp@free.fr-20170130143010-p31t1ranfeqbaeki
Merge  2.7 into trunk including fix for bug #1657238

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#
16
16
# Modifications copyright (C) 2008 Canonical Ltd
17
17
 
 
18
from __future__ import absolute_import
 
19
 
18
20
class BDecoder(object):
19
21
 
20
22
    def __init__(self, yield_tuples=False):
90
92
            raise TypeError
91
93
        try:
92
94
            r, l = self.decode_func[x[0]](x, 0)
93
 
        except (IndexError, KeyError):
94
 
            raise ValueError
 
95
        except (IndexError, KeyError, OverflowError), e:
 
96
            import sys
 
97
            raise ValueError, ValueError(str(e)), sys.exc_info()[2]
95
98
        if l != len(x):
96
99
            raise ValueError
97
100
        return r
154
157
        encode_int(int(x), r)
155
158
    encode_func[BooleanType] = encode_bool
156
159
 
 
160
from bzrlib._static_tuple_py import StaticTuple
 
161
encode_func[StaticTuple] = encode_list
 
162
try:
 
163
    from bzrlib._static_tuple_c import StaticTuple
 
164
except ImportError:
 
165
    pass
 
166
else:
 
167
    encode_func[StaticTuple] = encode_list
 
168
 
157
169
 
158
170
def bencode(x):
159
171
    r = []