~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/util/_bencode_py.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-09 15:30:59 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090909153059-sb038agvd38ci2q8
more link fixes in the User Guide

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
 
 
20
18
class BDecoder(object):
21
19
 
22
20
    def __init__(self, yield_tuples=False):
92
90
            raise TypeError
93
91
        try:
94
92
            r, l = self.decode_func[x[0]](x, 0)
95
 
        except (IndexError, KeyError, OverflowError), e:
96
 
            import sys
97
 
            raise ValueError, ValueError(str(e)), sys.exc_info()[2]
 
93
        except (IndexError, KeyError):
 
94
            raise ValueError
98
95
        if l != len(x):
99
96
            raise ValueError
100
97
        return r
157
154
        encode_int(int(x), r)
158
155
    encode_func[BooleanType] = encode_bool
159
156
 
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
 
 
169
157
 
170
158
def bencode(x):
171
159
    r = []