/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/_bencode_c.pyx

  • Committer: Jelmer Vernooij
  • Date: 2009-05-27 08:25:49 UTC
  • mto: (4398.5.1 bencode_serializer)
  • mto: This revision was merged to the branch mainline in revision 4410.
  • Revision ID: jelmer@samba.org-20090527082549-yn639mlk0skeq4pz
Always checks for strings first since they're more common, make sure sizes of strings are never below zero.

Show diffs side-by-side

added added

removed removed

Lines of Context:
180
180
            raise ValueError('too long string')
181
181
        if n > self.size:
182
182
            raise ValueError('stream underflow')
 
183
        if n < 0:
 
184
            raise ValueError('string size below zero: %d' % n)
183
185
 
184
186
        result = PyString_FromStringAndSize(self.tail, n)
185
187
        self._update_tail(n)
374
376
        return 1
375
377
 
376
378
    def process(self, object x):
377
 
        if PyInt_CheckExact(x):
 
379
        if PyString_CheckExact(x):
 
380
            self._encode_string(x)
 
381
        elif PyInt_CheckExact(x):
378
382
            self._encode_int(x)
379
383
        elif PyLong_CheckExact(x):
380
384
            self._encode_long(x)
381
 
        elif PyString_CheckExact(x):
382
 
            self._encode_string(x)
383
385
        elif PyList_CheckExact(x) or PyTuple_CheckExact(x):
384
386
            self._encode_list(x)
385
387
        elif PyDict_CheckExact(x):