/* Generated by Pyrex 0.9.8.5 on Thu Nov 25 16:59:21 2010 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#include "stddef.h"
#include "stdlib.h"
#include "string.h"
#include "python-compat.h"
#include "_bencode_pyx.h"
#include "_static_tuple_c.h"


typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/

static PyObject *__pyx_m;
static PyObject *__pyx_b;
static int __pyx_lineno;
static char *__pyx_filename;
static char **__pyx_f;

static char __pyx_mdoc[] = "Pyrex implementation for bencode coder/decoder";

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size);  /*proto*/

static PyObject *__Pyx_ImportModule(char *name); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/

static void __Pyx_AddTraceback(char *funcname); /*proto*/

/* Declarations from bzrlib._static_tuple_c */

static PyTypeObject *__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple = 0;

/* Declarations from bzrlib._bencode_pyx */


/* Declarations from implementation of bzrlib._bencode_pyx */

struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder {
  PyObject_HEAD
  struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *__pyx_vtab;
  char *tail;
  int size;
  int _yield_tuples;
  PyObject *text;
};

enum  {
  __pyx_e_6bzrlib_12_bencode_pyx_INITSIZE = 1024,
  __pyx_e_6bzrlib_12_bencode_pyx_INT_BUF_SIZE = 32
};

struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder {
  PyObject_HEAD
  struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *__pyx_vtab;
  char *tail;
  int size;
  char *buffer;
  int maxsize;
};


struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder {
  PyObject *(*_decode_object)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *);
  int (*_read_digits)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *,char);
  PyObject *(*_decode_int)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *);
  PyObject *(*_decode_string)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *);
  PyObject *(*_decode_list)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *);
  PyObject *(*_decode_dict)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *);
};
static struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *__pyx_vtabptr_6bzrlib_12_bencode_pyx_Decoder;


struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder {
  int (*_ensure_buffer)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *,int);
  int (*_encode_int)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *,int);
  int (*_encode_long)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *,PyObject *);
  int (*_append_string)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *,PyObject *);
  int (*_encode_string)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *,PyObject *);
  int (*_encode_list)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *,PyObject *);
  int (*_encode_dict)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *,PyObject *);
};
static struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *__pyx_vtabptr_6bzrlib_12_bencode_pyx_Encoder;

static PyTypeObject *__pyx_ptype_6bzrlib_12_bencode_pyx_Decoder = 0;
static PyTypeObject *__pyx_ptype_6bzrlib_12_bencode_pyx_Encoder = 0;

static char __pyx_k1[] = "String required";
static char __pyx_k2[] = "junk in stream";
static char __pyx_k3[] = "stream underflow";
static char __pyx_k4[] = "_decode_object";
static char __pyx_k5[] = "too deeply nested";
static char __pyx_k6[] = "unknown object type identifier %r";
static char __pyx_k7[] = "Stop character %c not found: %c";
static char __pyx_k8[] = "string len not terminated by \":\"";
static char __pyx_k9[] = "leading zeros are not allowed";
static char __pyx_k10[] = "";
static char __pyx_k11[] = "string size below zero: %d";
static char __pyx_k12[] = "malformed list";
static char __pyx_k13[] = "key was not a simple string.";
static char __pyx_k14[] = "dict keys disordered";
static char __pyx_k15[] = "malformed dict";
static char __pyx_k16[] = "decode";
static char __pyx_k17[] = "bencoded";
static char __pyx_k18[] = "Not enough memory to allocate buffer for encoder";
static char __pyx_k19[] = "Cannot realloc buffer for encoder";
static char __pyx_k20[] = "i%de";
static char __pyx_k21[] = "int %d too big to encode";
static char __pyx_k22[] = "join";
static char __pyx_k23[] = "i";
static char __pyx_k24[] = "e";
static char __pyx_k25[] = "%d:";
static char __pyx_k26[] = "string %s too big to encode";
static char __pyx_k27[] = "process";
static char __pyx_k28[] = "keys";
static char __pyx_k29[] = "sort";
static char __pyx_k30[] = "key in dict should be string";
static char __pyx_k31[] = "encode";
static char __pyx_k32[] = "Bencached";
static char __pyx_k33[] = "unsupported type %r";
static char __pyx_k34[] = "object";
static char __pyx_k35[] = "__slots__";
static char __pyx_k36[] = "__init__";

static PyObject *__pyx_n_Bencached;
static PyObject *__pyx_n___init__;
static PyObject *__pyx_n___slots__;
static PyObject *__pyx_n_bencoded;
static PyObject *__pyx_n_decode;
static PyObject *__pyx_n_e;
static PyObject *__pyx_n_i;
static PyObject *__pyx_n_join;
static PyObject *__pyx_n_keys;
static PyObject *__pyx_n_object;
static PyObject *__pyx_n_process;
static PyObject *__pyx_n_sort;

static PyObject *__pyx_k1p;
static PyObject *__pyx_k2p;
static PyObject *__pyx_k3p;
static PyObject *__pyx_k5p;
static PyObject *__pyx_k6p;
static PyObject *__pyx_k7p;
static PyObject *__pyx_k8p;
static PyObject *__pyx_k9p;
static PyObject *__pyx_k10p;
static PyObject *__pyx_k11p;
static PyObject *__pyx_k12p;
static PyObject *__pyx_k13p;
static PyObject *__pyx_k14p;
static PyObject *__pyx_k15p;
static PyObject *__pyx_k18p;
static PyObject *__pyx_k19p;
static PyObject *__pyx_k21p;
static PyObject *__pyx_k26p;
static PyObject *__pyx_k30p;
static PyObject *__pyx_k33p;

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_Bencached, 1, __pyx_k32, sizeof(__pyx_k32)},
  {&__pyx_n___init__, 1, __pyx_k36, sizeof(__pyx_k36)},
  {&__pyx_n___slots__, 1, __pyx_k35, sizeof(__pyx_k35)},
  {&__pyx_n_bencoded, 1, __pyx_k17, sizeof(__pyx_k17)},
  {&__pyx_n_decode, 1, __pyx_k16, sizeof(__pyx_k16)},
  {&__pyx_n_e, 1, __pyx_k24, sizeof(__pyx_k24)},
  {&__pyx_n_i, 1, __pyx_k23, sizeof(__pyx_k23)},
  {&__pyx_n_join, 1, __pyx_k22, sizeof(__pyx_k22)},
  {&__pyx_n_keys, 1, __pyx_k28, sizeof(__pyx_k28)},
  {&__pyx_n_object, 1, __pyx_k34, sizeof(__pyx_k34)},
  {&__pyx_n_process, 1, __pyx_k27, sizeof(__pyx_k27)},
  {&__pyx_n_sort, 1, __pyx_k29, sizeof(__pyx_k29)},
  {&__pyx_k1p, 0, __pyx_k1, sizeof(__pyx_k1)},
  {&__pyx_k2p, 0, __pyx_k2, sizeof(__pyx_k2)},
  {&__pyx_k3p, 0, __pyx_k3, sizeof(__pyx_k3)},
  {&__pyx_k5p, 0, __pyx_k5, sizeof(__pyx_k5)},
  {&__pyx_k6p, 0, __pyx_k6, sizeof(__pyx_k6)},
  {&__pyx_k7p, 0, __pyx_k7, sizeof(__pyx_k7)},
  {&__pyx_k8p, 0, __pyx_k8, sizeof(__pyx_k8)},
  {&__pyx_k9p, 0, __pyx_k9, sizeof(__pyx_k9)},
  {&__pyx_k10p, 0, __pyx_k10, sizeof(__pyx_k10)},
  {&__pyx_k11p, 0, __pyx_k11, sizeof(__pyx_k11)},
  {&__pyx_k12p, 0, __pyx_k12, sizeof(__pyx_k12)},
  {&__pyx_k13p, 0, __pyx_k13, sizeof(__pyx_k13)},
  {&__pyx_k14p, 0, __pyx_k14, sizeof(__pyx_k14)},
  {&__pyx_k15p, 0, __pyx_k15, sizeof(__pyx_k15)},
  {&__pyx_k18p, 0, __pyx_k18, sizeof(__pyx_k18)},
  {&__pyx_k19p, 0, __pyx_k19, sizeof(__pyx_k19)},
  {&__pyx_k21p, 0, __pyx_k21, sizeof(__pyx_k21)},
  {&__pyx_k26p, 0, __pyx_k26, sizeof(__pyx_k26)},
  {&__pyx_k30p, 0, __pyx_k30, sizeof(__pyx_k30)},
  {&__pyx_k33p, 0, __pyx_k33, sizeof(__pyx_k33)},
  {0, 0, 0, 0}
};

static PyObject *__pyx_d1;
static int __pyx_d2;


/* Implementation of bzrlib._bencode_pyx */

static int __pyx_f_6bzrlib_12_bencode_pyx_7Decoder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_6bzrlib_12_bencode_pyx_7Decoder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_v_yield_tuples = 0;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  char *__pyx_4;
  Py_ssize_t __pyx_5;
  static char *__pyx_argnames[] = {"s","yield_tuples",0};
  __pyx_v_yield_tuples = __pyx_d1;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_s, &__pyx_v_yield_tuples)) return -1;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_s);
  Py_INCREF(__pyx_v_yield_tuples);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":81 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_s));
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;}
    Py_INCREF(__pyx_k1p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k1p);
    __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":84 */
  Py_INCREF(__pyx_v_s);
  Py_DECREF(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->text);
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->text = __pyx_v_s;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":85 */
  __pyx_4 = PyString_AS_STRING(__pyx_v_s); if (__pyx_4 == NULL) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;}
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->tail = __pyx_4;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":86 */
  __pyx_5 = PyString_GET_SIZE(__pyx_v_s); if (__pyx_5 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; goto __pyx_L1;}
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->size = __pyx_5;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":87 */
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;}
  Py_INCREF(__pyx_v_yield_tuples);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_yield_tuples);
  __pyx_3 = PyObject_CallObject(((PyObject *)(&PyInt_Type)), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->_yield_tuples = __pyx_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_s);
  Py_DECREF(__pyx_v_yield_tuples);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Decoder_decode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Decoder_decode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":90 */
  __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->__pyx_vtab)->_decode_object(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_1;
  __pyx_1 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":91 */
  __pyx_2 = (((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->size != 0);
  if (__pyx_2) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;}
    Py_INCREF(__pyx_k2p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k2p);
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":93 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder.decode");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Decoder_decode_object(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Decoder_decode_object(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->__pyx_vtab)->_decode_object(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder.decode_object");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_object(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *__pyx_v_self) {
  char __pyx_v_ch;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":101 */
  __pyx_1 = (0 == __pyx_v_self->size);
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;}
    Py_INCREF(__pyx_k3p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k3p);
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":104 */
  __pyx_1 = Py_EnterRecursiveCall(__pyx_k4);
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;}
    Py_INCREF(__pyx_k5p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k5p);
    __pyx_3 = PyObject_CallObject(PyExc_RuntimeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":106 */
  /*try:*/ {

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":107 */
    __pyx_v_ch = (__pyx_v_self->tail[0]);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":108 */
    __pyx_1 = '0' <= __pyx_v_ch;
    if (__pyx_1) {
      __pyx_1 = __pyx_v_ch <= '9';
    }
    if (__pyx_1) {
      __pyx_2 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_string(__pyx_v_self); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; goto __pyx_L5;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L4;
      goto __pyx_L7;
    }
    __pyx_1 = (__pyx_v_ch == 'l');
    if (__pyx_1) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":111 */
      D_UPDATE_TAIL(__pyx_v_self,1);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":112 */
      __pyx_3 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_list(__pyx_v_self); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L5;}
      __pyx_r = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L4;
      goto __pyx_L7;
    }
    __pyx_1 = (__pyx_v_ch == 'i');
    if (__pyx_1) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":114 */
      D_UPDATE_TAIL(__pyx_v_self,1);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":115 */
      __pyx_2 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_int(__pyx_v_self); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L5;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L4;
      goto __pyx_L7;
    }
    __pyx_1 = (__pyx_v_ch == 'd');
    if (__pyx_1) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":117 */
      D_UPDATE_TAIL(__pyx_v_self,1);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":118 */
      __pyx_3 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_dict(__pyx_v_self); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L5;}
      __pyx_r = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L4;
      goto __pyx_L7;
    }
    /*else*/ {
      __pyx_2 = PyInt_FromLong(__pyx_v_ch); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L5;}
      __pyx_3 = PyNumber_Remainder(__pyx_k6p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L5;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L5;}
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
      __pyx_3 = 0;
      __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L5;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __Pyx_Raise(__pyx_3, 0, 0);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L5;}
    }
    __pyx_L7:;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_why = 0; goto __pyx_L6;
    __pyx_L4: __pyx_why = 3; goto __pyx_L6;
    __pyx_L5: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L6;
    }
    __pyx_L6:;
    Py_LeaveRecursiveCall();
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1;
      }
    }
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._decode_object");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_12_bencode_pyx_7Decoder__read_digits(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *__pyx_v_self,char __pyx_v_stop_char) {
  int __pyx_v_i;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":126 */
  __pyx_v_i = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":127 */
  while (1) {
    __pyx_1 = ((__pyx_v_self->tail[__pyx_v_i]) >= '0');
    if (__pyx_1) {
      __pyx_1 = ((__pyx_v_self->tail[__pyx_v_i]) <= '9');
    }
    if (!__pyx_1) {
      __pyx_1 = ((__pyx_v_self->tail[__pyx_v_i]) == '-');
    }
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_i < __pyx_v_self->size);
    }
    if (!__pyx_1) break;
    __pyx_v_i = (__pyx_v_i + 1);
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":131 */
  __pyx_1 = ((__pyx_v_self->tail[__pyx_v_i]) != __pyx_v_stop_char);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(__pyx_v_stop_char); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong((__pyx_v_self->tail[__pyx_v_i])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
    __pyx_2 = 0;
    __pyx_3 = 0;
    __pyx_2 = PyNumber_Remainder(__pyx_k7p, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":134 */
  __pyx_1 = ((__pyx_v_self->tail[0]) == '0');
  if (!__pyx_1) {
    __pyx_1 = ((__pyx_v_self->tail[0]) == '-');
    if (__pyx_1) {
      __pyx_1 = ((__pyx_v_self->tail[1]) == '0');
    }
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_i == 1);
    if (__pyx_1) {
      __pyx_r = __pyx_v_i;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    /*else*/ {
      __Pyx_Raise(PyExc_ValueError, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;}
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":140 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._read_digits");
  __pyx_r = (-1);
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_int(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *__pyx_v_self) {
  int __pyx_v_i;
  PyObject *__pyx_v_ret;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_ret = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":144 */
  __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_read_digits(__pyx_v_self,'e'); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
  __pyx_v_i = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":145 */
  (__pyx_v_self->tail[__pyx_v_i]) = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":146 */
  /*try:*/ {
    __pyx_2 = PyInt_FromString(__pyx_v_self->tail,NULL,10); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L3;}
    Py_DECREF(__pyx_v_ret);
    __pyx_v_ret = __pyx_2;
    __pyx_2 = 0;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_why = 0; goto __pyx_L4;
    __pyx_L3: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L4;
    }
    __pyx_L4:;
    (__pyx_v_self->tail[__pyx_v_i]) = 'e';
    switch (__pyx_why) {
      case 4: {
        PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1;
      }
    }
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":150 */
  D_UPDATE_TAIL(__pyx_v_self,(__pyx_v_i + 1));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":151 */
  Py_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._decode_int");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ret);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_string(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *__pyx_v_self) {
  int __pyx_v_n;
  char *__pyx_v_next_tail;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":160 */
  __pyx_v_n = strtol(__pyx_v_self->tail,(&__pyx_v_next_tail),10);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":161 */
  __pyx_1 = (__pyx_v_next_tail == NULL);
  if (!__pyx_1) {
    __pyx_1 = ((__pyx_v_next_tail[0]) != ':');
  }
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
    Py_INCREF(__pyx_k8p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k8p);
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":164 */
  __pyx_1 = ((__pyx_v_self->tail[0]) == '0');
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_n != 0);
    if (!__pyx_1) {
      __pyx_1 = ((__pyx_v_next_tail - __pyx_v_self->tail) != 1);
    }
  }
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L1;}
    Py_INCREF(__pyx_k9p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k9p);
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":167 */
  D_UPDATE_TAIL(__pyx_v_self,((__pyx_v_next_tail - __pyx_v_self->tail) + 1));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":168 */
  __pyx_1 = (__pyx_v_n == 0);
  if (__pyx_1) {
    Py_INCREF(__pyx_k10p);
    __pyx_r = __pyx_k10p;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":170 */
  __pyx_1 = (__pyx_v_n > __pyx_v_self->size);
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
    Py_INCREF(__pyx_k3p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k3p);
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":172 */
  __pyx_1 = (__pyx_v_n < 0);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(__pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k11p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":175 */
  __pyx_2 = PyString_FromStringAndSize(__pyx_v_self->tail,__pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":176 */
  D_UPDATE_TAIL(__pyx_v_self,__pyx_v_n);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":177 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._decode_string");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_list(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *__pyx_v_self) {
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":180 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_1;
  __pyx_1 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":182 */
  while (1) {
    __pyx_2 = (__pyx_v_self->size > 0);
    if (!__pyx_2) break;
    __pyx_2 = ((__pyx_v_self->tail[0]) == 'e');
    if (__pyx_2) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":184 */
      D_UPDATE_TAIL(__pyx_v_self,1);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":185 */
      __pyx_2 = __pyx_v_self->_yield_tuples;
      if (__pyx_2) {
        __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;}
        Py_INCREF(__pyx_v_result);
        PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_result);
        __pyx_3 = PyObject_CallObject(((PyObject *)(&PyTuple_Type)), __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        __pyx_r = __pyx_3;
        __pyx_3 = 0;
        goto __pyx_L0;
        goto __pyx_L5;
      }
      /*else*/ {
        Py_INCREF(__pyx_v_result);
        __pyx_r = __pyx_v_result;
        goto __pyx_L0;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    /*else*/ {
      __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_object(__pyx_v_self); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}
      __pyx_2 = PyList_Append(__pyx_v_result,__pyx_1); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
    }
    __pyx_L4:;
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":195 */
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;}
  Py_INCREF(__pyx_k12p);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k12p);
  __pyx_1 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __Pyx_Raise(__pyx_1, 0, 0);
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._decode_list");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_dict(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *__pyx_v_self) {
  char __pyx_v_ch;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_lastkey;
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);
  __pyx_v_lastkey = Py_None; Py_INCREF(Py_None);
  __pyx_v_key = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":200 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; goto __pyx_L1;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_1;
  __pyx_1 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":201 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_lastkey);
  __pyx_v_lastkey = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":203 */
  while (1) {
    __pyx_2 = (__pyx_v_self->size > 0);
    if (!__pyx_2) break;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":204 */
    __pyx_v_ch = (__pyx_v_self->tail[0]);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":205 */
    __pyx_2 = (__pyx_v_ch == 'e');
    if (__pyx_2) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":206 */
      D_UPDATE_TAIL(__pyx_v_self,1);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":207 */
      Py_INCREF(__pyx_v_result);
      __pyx_r = __pyx_v_result;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":210 */
      __pyx_2 = ((__pyx_v_self->tail[0]) < '0');
      if (!__pyx_2) {
        __pyx_2 = ((__pyx_v_self->tail[0]) > '9');
      }
      if (__pyx_2) {
        __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
        Py_INCREF(__pyx_k13p);
        PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k13p);
        __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        __Pyx_Raise(__pyx_3, 0, 0);
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":212 */
      __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_string(__pyx_v_self); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;}
      Py_DECREF(__pyx_v_key);
      __pyx_v_key = __pyx_1;
      __pyx_1 = 0;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":213 */
      if (PyObject_Cmp(__pyx_v_lastkey, __pyx_v_key, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}
      __pyx_2 = __pyx_2 >= 0;
      if (__pyx_2) {
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}
        Py_INCREF(__pyx_k14p);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k14p);
        __pyx_1 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __Pyx_Raise(__pyx_1, 0, 0);
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}
        goto __pyx_L6;
      }
      /*else*/ {
        Py_INCREF(__pyx_v_key);
        Py_DECREF(__pyx_v_lastkey);
        __pyx_v_lastkey = __pyx_v_key;
      }
      __pyx_L6:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":217 */
      __pyx_3 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_object(__pyx_v_self); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_3;
      __pyx_3 = 0;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":218 */
      if (PyObject_SetItem(__pyx_v_result, __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;}
    }
    __pyx_L4:;
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":220 */
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;}
  Py_INCREF(__pyx_k15p);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k15p);
  __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __Pyx_Raise(__pyx_3, 0, 0);
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._decode_dict");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_lastkey);
  Py_DECREF(__pyx_v_key);
  Py_DECREF(__pyx_v_value);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_bdecode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_12_bencode_pyx_bdecode[] = "Decode string x to Python object";
static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_bdecode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"s",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_s)) return 0;
  Py_INCREF(__pyx_v_s);
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;}
  Py_INCREF(__pyx_v_s);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_s);
  __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_6bzrlib_12_bencode_pyx_Decoder), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_decode); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.bdecode");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_s);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_bdecode_as_tuple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_12_bencode_pyx_bdecode_as_tuple[] = "Decode string x to Python object, using tuples rather than lists.";
static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_bdecode_as_tuple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"s",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_s)) return 0;
  Py_INCREF(__pyx_v_s);
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;}
  Py_INCREF(__pyx_v_s);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_s);
  Py_INCREF(Py_True);
  PyTuple_SET_ITEM(__pyx_1, 1, Py_True);
  __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_6bzrlib_12_bencode_pyx_Decoder), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_decode); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.bdecode_as_tuple");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_s);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_9Bencached___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6bzrlib_12_bencode_pyx_9Bencached___init__ = {"__init__", (PyCFunction)__pyx_f_6bzrlib_12_bencode_pyx_9Bencached___init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_9Bencached___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"self","s",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_self, &__pyx_v_s)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_s);
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_bencoded, __pyx_v_s) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; goto __pyx_L1;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Bencached.__init__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_s);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_12_bencode_pyx_7Encoder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_6bzrlib_12_bencode_pyx_7Encoder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_maxsize;
  char *__pyx_v_p;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"maxsize",0};
  __pyx_v_maxsize = __pyx_d2;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|i", __pyx_argnames, &__pyx_v_maxsize)) return -1;
  Py_INCREF(__pyx_v_self);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":259 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->maxsize = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":260 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->size = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":261 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->tail = NULL;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":263 */
  __pyx_v_p = ((char *)malloc(__pyx_v_maxsize));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":264 */
  __pyx_1 = (__pyx_v_p == NULL);
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;}
    Py_INCREF(__pyx_k18p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k18p);
    __pyx_3 = PyObject_CallObject(PyExc_MemoryError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":267 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->buffer = __pyx_v_p;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":268 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->maxsize = __pyx_v_maxsize;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":269 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->tail = __pyx_v_p;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_6bzrlib_12_bencode_pyx_7Encoder___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_6bzrlib_12_bencode_pyx_7Encoder___dealloc__(PyObject *__pyx_v_self) {
  Py_INCREF(__pyx_v_self);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":272 */
  free(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->buffer);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":273 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->buffer = NULL;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":274 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->maxsize = 0;

  Py_DECREF(__pyx_v_self);
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Encoder___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Encoder___str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_1 = (((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->buffer != NULL);
  if (__pyx_1) {
    __pyx_1 = (((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->size != 0);
  }
  if (__pyx_1) {
    __pyx_2 = PyString_FromStringAndSize(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->buffer,((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {
    Py_INCREF(__pyx_k10p);
    __pyx_r = __pyx_k10p;
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.__str__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_12_bencode_pyx_7Encoder__ensure_buffer(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *__pyx_v_self,int __pyx_v_required) {
  char *__pyx_v_new_buffer;
  int __pyx_v_new_size;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":290 */
  __pyx_1 = ((__pyx_v_self->size + __pyx_v_required) < __pyx_v_self->maxsize);
  if (__pyx_1) {
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":293 */
  __pyx_v_new_size = __pyx_v_self->maxsize;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":294 */
  while (1) {
    __pyx_1 = (__pyx_v_new_size < (__pyx_v_self->size + __pyx_v_required));
    if (!__pyx_1) break;
    __pyx_v_new_size = (__pyx_v_new_size * 2);
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":296 */
  __pyx_v_new_buffer = ((char *)realloc(__pyx_v_self->buffer,__pyx_v_new_size));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":297 */
  __pyx_1 = (__pyx_v_new_buffer == NULL);
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; goto __pyx_L1;}
    Py_INCREF(__pyx_k19p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k19p);
    __pyx_3 = PyObject_CallObject(PyExc_MemoryError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":300 */
  __pyx_v_self->buffer = __pyx_v_new_buffer;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":301 */
  __pyx_v_self->maxsize = __pyx_v_new_size;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":302 */
  __pyx_v_self->tail = (&(__pyx_v_new_buffer[__pyx_v_self->size]));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":303 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._ensure_buffer");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_int(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *__pyx_v_self,int __pyx_v_x) {
  int __pyx_v_n;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":310 */
  __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self,__pyx_e_6bzrlib_12_bencode_pyx_INT_BUF_SIZE); if (__pyx_1 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":311 */
  __pyx_v_n = snprintf(__pyx_v_self->tail,__pyx_e_6bzrlib_12_bencode_pyx_INT_BUF_SIZE,__pyx_k20,__pyx_v_x);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":312 */
  __pyx_1 = (__pyx_v_n < 0);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(__pyx_v_x); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k21p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(PyExc_MemoryError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":314 */
  E_UPDATE_TAIL(__pyx_v_self,__pyx_v_n);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":315 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._encode_int");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_long(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *__pyx_v_self,PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_x);
  __pyx_1 = PyObject_GetAttr(__pyx_k10p, __pyx_n_join); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
  Py_INCREF(__pyx_v_x);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);
  __pyx_3 = PyObject_CallObject(((PyObject *)(&PyString_Type)), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
  Py_INCREF(__pyx_n_i);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_i);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
  Py_INCREF(__pyx_n_e);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_n_e);
  __pyx_3 = 0;
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_4 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_append_string(__pyx_v_self,__pyx_2); if (__pyx_4 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_4;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._encode_long");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_12_bencode_pyx_7Encoder__append_string(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *__pyx_v_self,PyObject *__pyx_v_s) {
  Py_ssize_t __pyx_v_n;
  int __pyx_r;
  Py_ssize_t __pyx_1;
  int __pyx_2;
  char *__pyx_3;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_s);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":322 */
  __pyx_1 = PyString_GET_SIZE(__pyx_v_s); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}
  __pyx_v_n = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":323 */
  __pyx_2 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self,__pyx_v_n); if (__pyx_2 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":324 */
  __pyx_3 = PyString_AS_STRING(__pyx_v_s); if (__pyx_3 == NULL) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
  memcpy(__pyx_v_self->tail,__pyx_3,__pyx_v_n);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":325 */
  E_UPDATE_TAIL(__pyx_v_self,__pyx_v_n);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":326 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._append_string");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_s);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_string(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *__pyx_v_self,PyObject *__pyx_v_x) {
  int __pyx_v_n;
  Py_ssize_t __pyx_v_x_len;
  int __pyx_r;
  Py_ssize_t __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  char *__pyx_5;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":331 */
  __pyx_1 = PyString_GET_SIZE(__pyx_v_x); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; goto __pyx_L1;}
  __pyx_v_x_len = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":332 */
  __pyx_2 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self,(__pyx_v_x_len + __pyx_e_6bzrlib_12_bencode_pyx_INT_BUF_SIZE)); if (__pyx_2 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":333 */
  __pyx_v_n = snprintf(__pyx_v_self->tail,__pyx_e_6bzrlib_12_bencode_pyx_INT_BUF_SIZE,__pyx_k25,__pyx_v_x_len);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":334 */
  __pyx_2 = (__pyx_v_n < 0);
  if (__pyx_2) {
    __pyx_3 = PyNumber_Remainder(__pyx_k26p, __pyx_v_x); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(PyExc_MemoryError, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":336 */
  __pyx_5 = PyString_AS_STRING(__pyx_v_x); if (__pyx_5 == NULL) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}
  memcpy((__pyx_v_self->tail + __pyx_v_n),__pyx_5,__pyx_v_x_len);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":337 */
  E_UPDATE_TAIL(__pyx_v_self,(__pyx_v_n + __pyx_v_x_len));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":338 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._encode_string");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_list(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *__pyx_v_self,PyObject *__pyx_v_x) {
  PyObject *__pyx_v_i;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_x);
  __pyx_v_i = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":341 */
  __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self,1); if (__pyx_1 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":342 */
  (__pyx_v_self->tail[0]) = 'l';

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":343 */
  E_UPDATE_TAIL(__pyx_v_self,1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":345 */
  __pyx_2 = PyObject_GetIter(__pyx_v_x); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}
  for (;;) {
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_process); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
    Py_INCREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_i);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":348 */
  __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self,1); if (__pyx_1 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":349 */
  (__pyx_v_self->tail[0]) = 'e';

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":350 */
  E_UPDATE_TAIL(__pyx_v_self,1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":351 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._encode_list");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_i);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static int __pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_dict(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *__pyx_v_self,PyObject *__pyx_v_x) {
  PyObject *__pyx_v_keys;
  PyObject *__pyx_v_k;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_x);
  __pyx_v_keys = Py_None; Py_INCREF(Py_None);
  __pyx_v_k = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":354 */
  __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self,1); if (__pyx_1 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":355 */
  (__pyx_v_self->tail[0]) = 'd';

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":356 */
  E_UPDATE_TAIL(__pyx_v_self,1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":358 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_x, __pyx_n_keys); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_keys);
  __pyx_v_keys = __pyx_3;
  __pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":359 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_keys, __pyx_n_sort); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":360 */
  __pyx_2 = PyObject_GetIter(__pyx_v_keys); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;}
  for (;;) {
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_k);
    __pyx_v_k = __pyx_3;
    __pyx_3 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":361 */
    __pyx_1 = (!PyString_CheckExact(__pyx_v_k));
    if (__pyx_1) {
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; goto __pyx_L1;}
      Py_INCREF(__pyx_k30p);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k30p);
      __pyx_4 = PyObject_CallObject(PyExc_TypeError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; goto __pyx_L1;}
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":363 */
    __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_encode_string(__pyx_v_self,__pyx_v_k); if (__pyx_1 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":364 */
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_process); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_x, __pyx_v_k); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":366 */
  __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self,1); if (__pyx_1 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":367 */
  (__pyx_v_self->tail[0]) = 'e';

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":368 */
  E_UPDATE_TAIL(__pyx_v_self,1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":369 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._encode_dict");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_keys);
  Py_DECREF(__pyx_v_k);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Encoder_process(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_7Encoder_process(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"x",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_x)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":372 */
  __pyx_1 = Py_EnterRecursiveCall(__pyx_k31);
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;}
    Py_INCREF(__pyx_k5p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k5p);
    __pyx_3 = PyObject_CallObject(PyExc_RuntimeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":374 */
  /*try:*/ {
    __pyx_1 = PyString_CheckExact(__pyx_v_x);
    if (__pyx_1) {
      __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->__pyx_vtab)->_encode_string(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self),__pyx_v_x); if (__pyx_1 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L4;}
      goto __pyx_L6;
    }
    __pyx_1 = PyInt_CheckExact(__pyx_v_x);
    if (__pyx_1) {
      __pyx_1 = PyInt_AsLong(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L4;}
      __pyx_4 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->__pyx_vtab)->_encode_int(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self),__pyx_1); if (__pyx_4 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L4;}
      goto __pyx_L6;
    }
    __pyx_1 = PyLong_CheckExact(__pyx_v_x);
    if (__pyx_1) {
      __pyx_4 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->__pyx_vtab)->_encode_long(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self),__pyx_v_x); if (__pyx_4 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; goto __pyx_L4;}
      goto __pyx_L6;
    }
    __pyx_1 = PyList_CheckExact(__pyx_v_x);
    if (!__pyx_1) {
      __pyx_1 = PyTuple_CheckExact(__pyx_v_x);
      if (!__pyx_1) {
        __pyx_1 = StaticTuple_CheckExact(__pyx_v_x);
      }
    }
    if (__pyx_1) {
      __pyx_4 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->__pyx_vtab)->_encode_list(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self),__pyx_v_x); if (__pyx_4 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L4;}
      goto __pyx_L6;
    }
    __pyx_1 = PyDict_CheckExact(__pyx_v_x);
    if (__pyx_1) {
      __pyx_4 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->__pyx_vtab)->_encode_dict(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self),__pyx_v_x); if (__pyx_4 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L4;}
      goto __pyx_L6;
    }
    __pyx_1 = PyBool_Check(__pyx_v_x);
    if (__pyx_1) {
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L4;}
      Py_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);
      __pyx_3 = PyObject_CallObject(((PyObject *)(&PyInt_Type)), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L4;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L4;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->__pyx_vtab)->_encode_int(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self),__pyx_4); if (__pyx_1 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L4;}
      goto __pyx_L6;
    }
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Bencached); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L4;}
    __pyx_4 = PyObject_IsInstance(__pyx_v_x,__pyx_2); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L4;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_4) {
      __pyx_3 = PyObject_GetAttr(__pyx_v_x, __pyx_n_bencoded); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L4;}
      __pyx_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->__pyx_vtab)->_append_string(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self),__pyx_3); if (__pyx_1 == 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L4;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L6;
    }
    /*else*/ {
      __pyx_2 = PyNumber_Remainder(__pyx_k33p, __pyx_v_x); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L4;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L4;}
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
      __pyx_2 = 0;
      __pyx_2 = PyObject_CallObject(PyExc_TypeError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L4;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_2, 0, 0);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L4;}
    }
    __pyx_L6:;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;
    Py_LeaveRecursiveCall();
    switch (__pyx_why) {
      case 4: {
        PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1;
      }
    }
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.process");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_bencode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_12_bencode_pyx_bencode[] = "Encode Python object x to string";
static PyObject *__pyx_f_6bzrlib_12_bencode_pyx_bencode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_v_encoder;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"x",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_x)) return 0;
  Py_INCREF(__pyx_v_x);
  __pyx_v_encoder = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":398 */
  __pyx_1 = PyObject_CallObject(((PyObject *)__pyx_ptype_6bzrlib_12_bencode_pyx_Encoder), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
  Py_DECREF(__pyx_v_encoder);
  __pyx_v_encoder = __pyx_1;
  __pyx_1 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":399 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_encoder, __pyx_n_process); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
  Py_INCREF(__pyx_v_x);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":400 */
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;}
  Py_INCREF(__pyx_v_encoder);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_encoder);
  __pyx_2 = PyObject_CallObject(((PyObject *)(&PyString_Type)), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.bencode");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_encoder);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}
static struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder __pyx_vtable_6bzrlib_12_bencode_pyx_Decoder;

static PyObject *__pyx_tp_new_6bzrlib_12_bencode_pyx_Decoder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)o);
  *(struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder **)&p->__pyx_vtab = __pyx_vtabptr_6bzrlib_12_bencode_pyx_Decoder;
  p->text = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6bzrlib_12_bencode_pyx_Decoder(PyObject *o) {
  struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *p = (struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)o;
  Py_XDECREF(p->text);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_6bzrlib_12_bencode_pyx_Decoder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *p = (struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)o;
  if (p->text) {
    e = (*v)(p->text, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6bzrlib_12_bencode_pyx_Decoder(PyObject *o) {
  struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *p = (struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)o;
  PyObject *t;
  t = p->text; 
  p->text = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(t);
  return 0;
}

static struct PyMethodDef __pyx_methods_6bzrlib_12_bencode_pyx_Decoder[] = {
  {"decode", (PyCFunction)__pyx_f_6bzrlib_12_bencode_pyx_7Decoder_decode, METH_VARARGS|METH_KEYWORDS, 0},
  {"decode_object", (PyCFunction)__pyx_f_6bzrlib_12_bencode_pyx_7Decoder_decode_object, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_6bzrlib_12_bencode_pyx_Decoder[] = {
  {"tail", T_STRING, offsetof(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder, tail), READONLY, 0},
  {"size", T_INT, offsetof(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder, size), READONLY, 0},
  {"_yield_tuples", T_INT, offsetof(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder, _yield_tuples), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Decoder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Decoder = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Decoder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Decoder = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_6bzrlib_12_bencode_pyx_Decoder = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "bzrlib._bencode_pyx.Decoder", /*tp_name*/
  sizeof(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6bzrlib_12_bencode_pyx_Decoder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Decoder, /*tp_as_number*/
  &__pyx_tp_as_sequence_Decoder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Decoder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Decoder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Bencode decoder", /*tp_doc*/
  __pyx_tp_traverse_6bzrlib_12_bencode_pyx_Decoder, /*tp_traverse*/
  __pyx_tp_clear_6bzrlib_12_bencode_pyx_Decoder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6bzrlib_12_bencode_pyx_Decoder, /*tp_methods*/
  __pyx_members_6bzrlib_12_bencode_pyx_Decoder, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_6bzrlib_12_bencode_pyx_7Decoder___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6bzrlib_12_bencode_pyx_Decoder, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder __pyx_vtable_6bzrlib_12_bencode_pyx_Encoder;

static PyObject *__pyx_tp_new_6bzrlib_12_bencode_pyx_Encoder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)o);
  *(struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder **)&p->__pyx_vtab = __pyx_vtabptr_6bzrlib_12_bencode_pyx_Encoder;
  return o;
}

static void __pyx_tp_dealloc_6bzrlib_12_bencode_pyx_Encoder(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_6bzrlib_12_bencode_pyx_7Encoder___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  (*o->ob_type->tp_free)(o);
}

static struct PyMethodDef __pyx_methods_6bzrlib_12_bencode_pyx_Encoder[] = {
  {"process", (PyCFunction)__pyx_f_6bzrlib_12_bencode_pyx_7Encoder_process, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_6bzrlib_12_bencode_pyx_Encoder[] = {
  {"tail", T_STRING, offsetof(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder, tail), READONLY, 0},
  {"size", T_INT, offsetof(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder, size), READONLY, 0},
  {"buffer", T_STRING, offsetof(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder, buffer), READONLY, 0},
  {"maxsize", T_INT, offsetof(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder, maxsize), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Encoder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Encoder = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Encoder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Encoder = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_6bzrlib_12_bencode_pyx_Encoder = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "bzrlib._bencode_pyx.Encoder", /*tp_name*/
  sizeof(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6bzrlib_12_bencode_pyx_Encoder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Encoder, /*tp_as_number*/
  &__pyx_tp_as_sequence_Encoder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Encoder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_f_6bzrlib_12_bencode_pyx_7Encoder___str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Encoder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "Bencode encoder", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6bzrlib_12_bencode_pyx_Encoder, /*tp_methods*/
  __pyx_members_6bzrlib_12_bencode_pyx_Encoder, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_6bzrlib_12_bencode_pyx_7Encoder___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6bzrlib_12_bencode_pyx_Encoder, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static struct PyMethodDef __pyx_methods[] = {
  {"bdecode", (PyCFunction)__pyx_f_6bzrlib_12_bencode_pyx_bdecode, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6bzrlib_12_bencode_pyx_bdecode},
  {"bdecode_as_tuple", (PyCFunction)__pyx_f_6bzrlib_12_bencode_pyx_bdecode_as_tuple, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6bzrlib_12_bencode_pyx_bdecode_as_tuple},
  {"bencode", (PyCFunction)__pyx_f_6bzrlib_12_bencode_pyx_bencode, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6bzrlib_12_bencode_pyx_bencode},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC init_bencode_pyx(void); /*proto*/
PyMODINIT_FUNC init_bencode_pyx(void) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_bencode_pyx", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  __pyx_vtabptr_6bzrlib_12_bencode_pyx_Decoder = &__pyx_vtable_6bzrlib_12_bencode_pyx_Decoder;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._decode_object = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_object;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._read_digits = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__read_digits;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._decode_int = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_int;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._decode_string = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_string;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._decode_list = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_list;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._decode_dict = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_dict;
  __pyx_type_6bzrlib_12_bencode_pyx_Decoder.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_6bzrlib_12_bencode_pyx_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_6bzrlib_12_bencode_pyx_Decoder.tp_dict, __pyx_vtabptr_6bzrlib_12_bencode_pyx_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Decoder", (PyObject *)&__pyx_type_6bzrlib_12_bencode_pyx_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;}
  __pyx_ptype_6bzrlib_12_bencode_pyx_Decoder = &__pyx_type_6bzrlib_12_bencode_pyx_Decoder;
  __pyx_vtabptr_6bzrlib_12_bencode_pyx_Encoder = &__pyx_vtable_6bzrlib_12_bencode_pyx_Encoder;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._ensure_buffer = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__ensure_buffer;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._encode_int = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_int;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._encode_long = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_long;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._append_string = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__append_string;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._encode_string = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_string;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._encode_list = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_list;
  *(void(**)(void))&__pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._encode_dict = (void(*)(void))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_dict;
  if (PyType_Ready(&__pyx_type_6bzrlib_12_bencode_pyx_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_6bzrlib_12_bencode_pyx_Encoder.tp_dict, __pyx_vtabptr_6bzrlib_12_bencode_pyx_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Encoder", (PyObject *)&__pyx_type_6bzrlib_12_bencode_pyx_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;}
  __pyx_ptype_6bzrlib_12_bencode_pyx_Encoder = &__pyx_type_6bzrlib_12_bencode_pyx_Encoder;
  __pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple = __Pyx_ImportType("bzrlib._static_tuple_c", "StaticTuple", sizeof(StaticTuple)); if (!__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":66 */
  __pyx_1 = import_static_tuple_c(); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":77 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; goto __pyx_L1;}
  __pyx_d1 = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":233 */
  __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
  __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_object); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
  __pyx_4 = 0;
  __pyx_4 = __Pyx_CreateClass(__pyx_5, __pyx_3, __pyx_n_Bencached, "bzrlib._bencode_pyx"); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":234 */
  __pyx_5 = PyList_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; goto __pyx_L1;}
  Py_INCREF(__pyx_n_bencoded);
  PyList_SET_ITEM(__pyx_5, 0, __pyx_n_bencoded);
  if (PyObject_SetAttr(__pyx_4, __pyx_n___slots__, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":236 */
  __pyx_5 = PyCFunction_New(&__pyx_mdef_6bzrlib_12_bencode_pyx_9Bencached___init__, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;}
  __pyx_6 = PyMethod_New(__pyx_5, 0, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (PyObject_SetAttr(__pyx_4, __pyx_n___init__, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Bencached, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":253 */
  __pyx_d2 = __pyx_e_6bzrlib_12_bencode_pyx_INITSIZE;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_bencode_pyx.pyx":396 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("bzrlib._bencode_pyx");
}

static char *__pyx_filenames[] = {
  "_bencode_pyx.pyx",
  "_static_tuple_c.pxd",
};

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) type->ob_type;
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }
    PyErr_Restore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        if (!*t->p)
            return -1;
        if (t->i)
            PyString_InternInPlace(t->p);
        ++t;
    }
    return 0;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
    PyObject *pycobj = 0;
    int result;
    
    pycobj = PyCObject_FromVoidPtr(vtable, 0);
    if (!pycobj)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0)
        goto bad;
    result = 0;
    goto done;

bad:
    result = -1;
done:
    Py_XDECREF(pycobj);
    return result;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, 
    long size) 
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    result = PyObject_GetAttrString(py_module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError, 
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError, 
            "%s.%s does not appear to be the correct type object",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(char *name) {
    PyObject *py_name = 0;
    
    py_name = PyString_FromString(name);
    if (!py_name)
        goto bad;
    return PyImport_Import(py_name);
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

static PyObject *__Pyx_CreateClass(
    PyObject *bases, PyObject *dict, PyObject *name, char *modname)
{
    PyObject *py_modname;
    PyObject *result = 0;
    
    py_modname = PyString_FromString(modname);
    if (!py_modname)
        goto bad;
    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
        goto bad;
    result = PyClass_New(bases, dict, name);
bad:
    Py_XDECREF(py_modname);
    return result;
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyObject *empty_tuple = 0;
    PyObject *empty_string = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    
    py_srcfile = PyString_FromString(__pyx_filename);
    if (!py_srcfile) goto bad;
    py_funcname = PyString_FromString(funcname);
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    empty_tuple = PyTuple_New(0);
    if (!empty_tuple) goto bad;
    empty_string = PyString_FromString("");
    if (!empty_string) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        empty_string, /*PyObject *code,*/
        empty_tuple,  /*PyObject *consts,*/
        empty_tuple,  /*PyObject *names,*/
        empty_tuple,  /*PyObject *varnames,*/
        empty_tuple,  /*PyObject *freevars,*/
        empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        empty_string  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_Get(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(empty_tuple);
    Py_XDECREF(empty_string);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}
