~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_bencode_pyx.pyx

  • Committer: John Arbash Meinel
  • Date: 2009-06-04 16:03:13 UTC
  • mto: This revision was merged to the branch mainline in revision 4410.
  • Revision ID: john@arbash-meinel.com-20090604160313-mo66r0hhgkg6vzil
Turn Decoder.decode_object into _decode_object.

def foo() functions have to be accessed via getattr() because they
can be overridden by python code. While
cdef _foo() functions can be accessed directly via the struct member.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
        self._yield_tuples = int(yield_tuples)
81
81
 
82
82
    def decode(self):
83
 
        result = self.decode_object()
 
83
        result = self._decode_object()
84
84
        if self.size != 0:
85
85
            raise ValueError('junk in stream')
86
86
        return result
87
87
 
88
88
    def decode_object(self):
 
89
        return self._decode_object()
 
90
 
 
91
    cdef object _decode_object(self):
89
92
        cdef char ch
90
93
 
91
94
        if 0 == self.size:
92
95
            raise ValueError('stream underflow')
93
96
 
94
 
        if Py_EnterRecursiveCall("decode_object"):
 
97
        if Py_EnterRecursiveCall("_decode_object"):
95
98
            raise RuntimeError("too deeply nested")
96
99
        try:
97
100
            ch = self.tail[0]
172
175
                else:
173
176
                    return result
174
177
            else:
175
 
                result.append(self.decode_object())
 
178
                result.append(self._decode_object())
176
179
 
177
180
        raise ValueError('malformed list')
178
181
 
194
197
                    raise ValueError('dict keys disordered')
195
198
                else:
196
199
                    lastkey = key
197
 
                value = self.decode_object()
 
200
                value = self._decode_object()
198
201
                result[key] = value
199
202
 
200
203
        raise ValueError('malformed dict')