/* Generated by Cython 0.13 on Mon Sep 19 20:18:38 2011 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#else

#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif

#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#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 PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif

#ifndef PySet_CheckExact
#  define PySet_CheckExact(obj)          (Py_TYPE(obj) == &PySet_Type)
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject PyLongObject
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif

#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE_API__bzrlib___bencode_pyx
#include "stddef.h"
#include "stdlib.h"
#include "string.h"
#include "python-compat.h"
#include "_bencode_pyx.h"
#include "_static_tuple_c.h"

/* inline attribute */
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE 
  #endif
#endif

/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__)) 
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || defined(__INTEL_COMPILER)
#   define CYTHON_UNUSED __attribute__ ((__unused__)) 
# else
#   define CYTHON_UNUSED 
# endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))


#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


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

/* Type declarations */

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":240
 * 
 * 
 * cdef enum:             # <<<<<<<<<<<<<<
 *     INITSIZE = 1024     # initial size for encoder buffer
 *     INT_BUF_SIZE = 32
 */

enum  {
  __pyx_e_6bzrlib_12_bencode_pyx_INITSIZE = 1024,
  __pyx_e_6bzrlib_12_bencode_pyx_INT_BUF_SIZE = 32
};

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":54
 *     int snprintf(char* buffer, size_t nsize, char* fmt, ...)
 * 
 * cdef class Decoder             # <<<<<<<<<<<<<<
 * cdef class Encoder
 * 
 */

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;
};

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":55
 * 
 * cdef class Decoder
 * cdef class Encoder             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "_bencode_pyx.h":
 */

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;
};


/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":245
 * 
 * 
 * cdef class Encoder:             # <<<<<<<<<<<<<<
 *     """Bencode encoder"""
 * 
 */

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;


/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":69
 * 
 * 
 * cdef class Decoder:             # <<<<<<<<<<<<<<
 *     """Bencode decoder"""
 * 
 */

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;

#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif

#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
  end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
  }
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
#else
  #define __Pyx_RefNannySetupContext(name)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)

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

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

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

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

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

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

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

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

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

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from bzrlib._static_tuple_c */

/* Module declarations from bzrlib._static_tuple_c */

static PyTypeObject *__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple = 0;
/* Module declarations from bzrlib._bencode_pyx */

static PyTypeObject *__pyx_ptype_6bzrlib_12_bencode_pyx_Decoder = 0;
static PyTypeObject *__pyx_ptype_6bzrlib_12_bencode_pyx_Encoder = 0;
#define __Pyx_MODULE_NAME "bzrlib._bencode_pyx"
int __pyx_module_is_main_bzrlib___bencode_pyx = 0;

/* Implementation of bzrlib._bencode_pyx */
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_MemoryError;
static char __pyx_k_1[] = "String required";
static char __pyx_k_2[] = "junk in stream";
static char __pyx_k_3[] = "stream underflow";
static char __pyx_k_4[] = "too deeply nested";
static char __pyx_k_5[] = "unknown object type identifier %r";
static char __pyx_k_6[] = "Stop character %c not found: %c";
static char __pyx_k_7[] = "string len not terminated by \":\"";
static char __pyx_k_8[] = "leading zeros are not allowed";
static char __pyx_k_9[] = "";
static char __pyx_k_10[] = "string size below zero: %d";
static char __pyx_k_11[] = "malformed list";
static char __pyx_k_12[] = "key was not a simple string.";
static char __pyx_k_13[] = "dict keys disordered";
static char __pyx_k_14[] = "malformed dict";
static char __pyx_k_16[] = "Not enough memory to allocate buffer for encoder";
static char __pyx_k_17[] = "Cannot realloc buffer for encoder";
static char __pyx_k_18[] = "i%de";
static char __pyx_k_19[] = "int %d too big to encode";
static char __pyx_k_20[] = "%d:";
static char __pyx_k_21[] = "string %s too big to encode";
static char __pyx_k_22[] = "key in dict should be string";
static char __pyx_k_23[] = "unsupported type %r";
static char __pyx_k_24[] = "Pyrex implementation for bencode coder/decoder";
static char __pyx_k_25[] = "Decoder.__init__ (line 77)";
static char __pyx_k_26[] = "bdecode (line 223)";
static char __pyx_k_27[] = "bdecode_as_tuple (line 228)";
static char __pyx_k_28[] = "Encoder.__init__ (line 253)";
static char __pyx_k_29[] = "bencode (line 396)";
static char __pyx_k__e[] = "e";
static char __pyx_k__i[] = "i";
static char __pyx_k__s[] = "s";
static char __pyx_k__join[] = "join";
static char __pyx_k__keys[] = "keys";
static char __pyx_k__self[] = "self";
static char __pyx_k__size[] = "size";
static char __pyx_k__sort[] = "sort";
static char __pyx_k__tail[] = "tail";
static char __pyx_k__text[] = "text";
static char __pyx_k__buffer[] = "buffer";
static char __pyx_k__decode[] = "decode";
static char __pyx_k__encode[] = "encode";
static char __pyx_k__object[] = "object";
static char __pyx_k__Decoder[] = "Decoder";
static char __pyx_k__Encoder[] = "Encoder";
static char __pyx_k__bdecode[] = "bdecode";
static char __pyx_k__bencode[] = "bencode";
static char __pyx_k__maxsize[] = "maxsize";
static char __pyx_k__process[] = "process";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__bencoded[] = "bencoded";
static char __pyx_k__Bencached[] = "Bencached";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k____slots__[] = "__slots__";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__MemoryError[] = "MemoryError";
static char __pyx_k___decode_int[] = "_decode_int";
static char __pyx_k___encode_int[] = "_encode_int";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static char __pyx_k___decode_dict[] = "_decode_dict";
static char __pyx_k___decode_list[] = "_decode_list";
static char __pyx_k___encode_dict[] = "_encode_dict";
static char __pyx_k___encode_list[] = "_encode_list";
static char __pyx_k___encode_long[] = "_encode_long";
static char __pyx_k___read_digits[] = "_read_digits";
static char __pyx_k__yield_tuples[] = "yield_tuples";
static char __pyx_k___yield_tuples[] = "_yield_tuples";
static char __pyx_k___append_string[] = "_append_string";
static char __pyx_k___decode_object[] = "_decode_object";
static char __pyx_k___decode_string[] = "_decode_string";
static char __pyx_k___encode_string[] = "_encode_string";
static char __pyx_k___ensure_buffer[] = "_ensure_buffer";
static char __pyx_k__bdecode_as_tuple[] = "bdecode_as_tuple";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_10;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_s_13;
static PyObject *__pyx_kp_s_14;
static PyObject *__pyx_kp_s_16;
static PyObject *__pyx_kp_s_17;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_kp_s_22;
static PyObject *__pyx_kp_s_23;
static PyObject *__pyx_kp_u_25;
static PyObject *__pyx_kp_u_26;
static PyObject *__pyx_kp_u_27;
static PyObject *__pyx_kp_u_28;
static PyObject *__pyx_kp_u_29;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__Bencached;
static PyObject *__pyx_n_s__Decoder;
static PyObject *__pyx_n_s__Encoder;
static PyObject *__pyx_n_s__MemoryError;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____slots__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___append_string;
static PyObject *__pyx_n_s___decode_dict;
static PyObject *__pyx_n_s___decode_int;
static PyObject *__pyx_n_s___decode_list;
static PyObject *__pyx_n_s___decode_object;
static PyObject *__pyx_n_s___decode_string;
static PyObject *__pyx_n_s___encode_dict;
static PyObject *__pyx_n_s___encode_int;
static PyObject *__pyx_n_s___encode_list;
static PyObject *__pyx_n_s___encode_long;
static PyObject *__pyx_n_s___encode_string;
static PyObject *__pyx_n_s___ensure_buffer;
static PyObject *__pyx_n_s___read_digits;
static PyObject *__pyx_n_s___yield_tuples;
static PyObject *__pyx_n_s__bdecode;
static PyObject *__pyx_n_s__bdecode_as_tuple;
static PyObject *__pyx_n_s__bencode;
static PyObject *__pyx_n_s__bencoded;
static PyObject *__pyx_n_s__buffer;
static PyObject *__pyx_n_s__decode;
static PyObject *__pyx_n_s__e;
static PyObject *__pyx_n_s__i;
static PyObject *__pyx_n_s__join;
static PyObject *__pyx_n_s__keys;
static PyObject *__pyx_n_s__maxsize;
static PyObject *__pyx_n_s__object;
static PyObject *__pyx_n_s__process;
static PyObject *__pyx_n_s__s;
static PyObject *__pyx_n_s__self;
static PyObject *__pyx_n_s__size;
static PyObject *__pyx_n_s__sort;
static PyObject *__pyx_n_s__tail;
static PyObject *__pyx_n_s__text;
static PyObject *__pyx_n_s__yield_tuples;
static PyObject *__pyx_int_0;
static int __pyx_k_15;

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":72
 *     """Bencode decoder"""
 * 
 *     cdef readonly char *tail             # <<<<<<<<<<<<<<
 *     cdef readonly int size
 *     cdef readonly int _yield_tuples
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_4tail___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_4tail___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->tail); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder.tail.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":73
 * 
 *     cdef readonly char *tail
 *     cdef readonly int size             # <<<<<<<<<<<<<<
 *     cdef readonly int _yield_tuples
 *     cdef object text
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_4size___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_4size___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder.size.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":74
 *     cdef readonly char *tail
 *     cdef readonly int size
 *     cdef readonly int _yield_tuples             # <<<<<<<<<<<<<<
 *     cdef object text
 * 
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_13_yield_tuples___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_13_yield_tuples___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->_yield_tuples); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._yield_tuples.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":77
 *     cdef object text
 * 
 *     def __init__(self, s, yield_tuples=0):             # <<<<<<<<<<<<<<
 *         """Initialize decoder engine.
 *         @param  s:  Python string.
 */

static int __pyx_pf_6bzrlib_12_bencode_pyx_7Decoder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_12_bencode_pyx_7Decoder___init__[] = "Initialize decoder engine.\n        @param  s:  Python string.\n        ";
struct wrapperbase __pyx_wrapperbase_6bzrlib_12_bencode_pyx_7Decoder___init__;
static int __pyx_pf_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_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__s,&__pyx_n_s__yield_tuples,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_0);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__s);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__yield_tuples);
        if (value) { values[1] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_s = values[0];
    __pyx_v_yield_tuples = values[1];
  } else {
    __pyx_v_yield_tuples = ((PyObject *)__pyx_int_0);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_yield_tuples = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_s = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":81
 *         @param  s:  Python string.
 *         """
 *         if not PyString_CheckExact(s):             # <<<<<<<<<<<<<<
 *             raise TypeError("String required")
 * 
 */
  __pyx_t_1 = (!PyString_CheckExact(__pyx_v_s));
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":82
 *         """
 *         if not PyString_CheckExact(s):
 *             raise TypeError("String required")             # <<<<<<<<<<<<<<
 * 
 *         self.text = s
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":84
 *             raise TypeError("String required")
 * 
 *         self.text = s             # <<<<<<<<<<<<<<
 *         self.tail = PyString_AS_STRING(s)
 *         self.size = PyString_GET_SIZE(s)
 */
  __Pyx_INCREF(__pyx_v_s);
  __Pyx_GIVEREF(__pyx_v_s);
  __Pyx_GOTREF(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->text);
  __Pyx_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/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":85
 * 
 *         self.text = s
 *         self.tail = PyString_AS_STRING(s)             # <<<<<<<<<<<<<<
 *         self.size = PyString_GET_SIZE(s)
 *         self._yield_tuples = int(yield_tuples)
 */
  __pyx_t_4 = PyString_AS_STRING(__pyx_v_s); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->tail = __pyx_t_4;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":86
 *         self.text = s
 *         self.tail = PyString_AS_STRING(s)
 *         self.size = PyString_GET_SIZE(s)             # <<<<<<<<<<<<<<
 *         self._yield_tuples = int(yield_tuples)
 * 
 */
  __pyx_t_5 = PyString_GET_SIZE(__pyx_v_s); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->size = __pyx_t_5;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":87
 *         self.tail = PyString_AS_STRING(s)
 *         self.size = PyString_GET_SIZE(s)
 *         self._yield_tuples = int(yield_tuples)             # <<<<<<<<<<<<<<
 * 
 *     def decode(self):
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_yield_tuples);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_yield_tuples);
  __Pyx_GIVEREF(__pyx_v_yield_tuples);
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->_yield_tuples = __pyx_t_6;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":89
 *         self._yield_tuples = int(yield_tuples)
 * 
 *     def decode(self):             # <<<<<<<<<<<<<<
 *         result = self._decode_object()
 *         if self.size != 0:
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_decode(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_decode(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_v_result;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("decode");
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":90
 * 
 *     def decode(self):
 *         result = self._decode_object()             # <<<<<<<<<<<<<<
 *         if self.size != 0:
 *             raise ValueError('junk in stream')
 */
  __pyx_t_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 (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":91
 *     def decode(self):
 *         result = self._decode_object()
 *         if self.size != 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('junk in stream')
 *         return result
 */
  __pyx_t_2 = (((struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self)->size != 0);
  if (__pyx_t_2) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":92
 *         result = self._decode_object()
 *         if self.size != 0:
 *             raise ValueError('junk in stream')             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":93
 *         if self.size != 0:
 *             raise ValueError('junk in stream')
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def decode_object(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder.decode");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":95
 *         return result
 * 
 *     def decode_object(self):             # <<<<<<<<<<<<<<
 *         return self._decode_object()
 * 
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_decode_object(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_decode_object(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("decode_object");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":96
 * 
 *     def decode_object(self):
 *         return self._decode_object()             # <<<<<<<<<<<<<<
 * 
 *     cdef object _decode_object(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_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 (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder.decode_object");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":98
 *         return self._decode_object()
 * 
 *     cdef object _decode_object(self):             # <<<<<<<<<<<<<<
 *         cdef char ch
 * 
 */

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 = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("_decode_object");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":101
 *         cdef char ch
 * 
 *         if 0 == self.size:             # <<<<<<<<<<<<<<
 *             raise ValueError('stream underflow')
 * 
 */
  __pyx_t_1 = (0 == __pyx_v_self->size);
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":102
 * 
 *         if 0 == self.size:
 *             raise ValueError('stream underflow')             # <<<<<<<<<<<<<<
 * 
 *         if Py_EnterRecursiveCall("_decode_object"):
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":104
 *             raise ValueError('stream underflow')
 * 
 *         if Py_EnterRecursiveCall("_decode_object"):             # <<<<<<<<<<<<<<
 *             raise RuntimeError("too deeply nested")
 *         try:
 */
  __pyx_t_4 = Py_EnterRecursiveCall(__pyx_k___decode_object);
  if (__pyx_t_4) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":105
 * 
 *         if Py_EnterRecursiveCall("_decode_object"):
 *             raise RuntimeError("too deeply nested")             # <<<<<<<<<<<<<<
 *         try:
 *             ch = self.tail[0]
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":106
 *         if Py_EnterRecursiveCall("_decode_object"):
 *             raise RuntimeError("too deeply nested")
 *         try:             # <<<<<<<<<<<<<<
 *             ch = self.tail[0]
 *             if c'0' <= ch <= c'9':
 */
  /*try:*/ {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":107
 *             raise RuntimeError("too deeply nested")
 *         try:
 *             ch = self.tail[0]             # <<<<<<<<<<<<<<
 *             if c'0' <= ch <= c'9':
 *                 return self._decode_string()
 */
    __pyx_v_ch = (__pyx_v_self->tail[0]);

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":108
 *         try:
 *             ch = self.tail[0]
 *             if c'0' <= ch <= c'9':             # <<<<<<<<<<<<<<
 *                 return self._decode_string()
 *             elif ch == c'l':
 */
    __pyx_t_1 = ('0' <= __pyx_v_ch);
    if (__pyx_t_1) {
      __pyx_t_1 = (__pyx_v_ch <= '9');
    }
    if (__pyx_t_1) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":109
 *             ch = self.tail[0]
 *             if c'0' <= ch <= c'9':
 *                 return self._decode_string()             # <<<<<<<<<<<<<<
 *             elif ch == c'l':
 *                 D_UPDATE_TAIL(self, 1)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_string(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L5;
      goto __pyx_L8;
    }

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":110
 *             if c'0' <= ch <= c'9':
 *                 return self._decode_string()
 *             elif ch == c'l':             # <<<<<<<<<<<<<<
 *                 D_UPDATE_TAIL(self, 1)
 *                 return self._decode_list()
 */
    __pyx_t_1 = (__pyx_v_ch == 'l');
    if (__pyx_t_1) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":111
 *                 return self._decode_string()
 *             elif ch == c'l':
 *                 D_UPDATE_TAIL(self, 1)             # <<<<<<<<<<<<<<
 *                 return self._decode_list()
 *             elif ch == c'i':
 */
      D_UPDATE_TAIL(__pyx_v_self, 1);

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":112
 *             elif ch == c'l':
 *                 D_UPDATE_TAIL(self, 1)
 *                 return self._decode_list()             # <<<<<<<<<<<<<<
 *             elif ch == c'i':
 *                 D_UPDATE_TAIL(self, 1)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_list(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L5;
      goto __pyx_L8;
    }

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":113
 *                 D_UPDATE_TAIL(self, 1)
 *                 return self._decode_list()
 *             elif ch == c'i':             # <<<<<<<<<<<<<<
 *                 D_UPDATE_TAIL(self, 1)
 *                 return self._decode_int()
 */
    __pyx_t_1 = (__pyx_v_ch == 'i');
    if (__pyx_t_1) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":114
 *                 return self._decode_list()
 *             elif ch == c'i':
 *                 D_UPDATE_TAIL(self, 1)             # <<<<<<<<<<<<<<
 *                 return self._decode_int()
 *             elif ch == c'd':
 */
      D_UPDATE_TAIL(__pyx_v_self, 1);

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":115
 *             elif ch == c'i':
 *                 D_UPDATE_TAIL(self, 1)
 *                 return self._decode_int()             # <<<<<<<<<<<<<<
 *             elif ch == c'd':
 *                 D_UPDATE_TAIL(self, 1)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_int(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L5;
      goto __pyx_L8;
    }

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":116
 *                 D_UPDATE_TAIL(self, 1)
 *                 return self._decode_int()
 *             elif ch == c'd':             # <<<<<<<<<<<<<<
 *                 D_UPDATE_TAIL(self, 1)
 *                 return self._decode_dict()
 */
    __pyx_t_1 = (__pyx_v_ch == 'd');
    if (__pyx_t_1) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":117
 *                 return self._decode_int()
 *             elif ch == c'd':
 *                 D_UPDATE_TAIL(self, 1)             # <<<<<<<<<<<<<<
 *                 return self._decode_dict()
 *             else:
 */
      D_UPDATE_TAIL(__pyx_v_self, 1);

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":118
 *             elif ch == c'd':
 *                 D_UPDATE_TAIL(self, 1)
 *                 return self._decode_dict()             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError('unknown object type identifier %r' % ch)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_dict(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L5;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":120
 *                 return self._decode_dict()
 *             else:
 *                 raise ValueError('unknown object type identifier %r' % ch)             # <<<<<<<<<<<<<<
 *         finally:
 *             Py_LeaveRecursiveCall()
 */
      __pyx_t_2 = PyInt_FromLong(__pyx_v_ch); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L6;}
    }
    __pyx_L8:;
  }

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":122
 *                 raise ValueError('unknown object type identifier %r' % ch)
 *         finally:
 *             Py_LeaveRecursiveCall()             # <<<<<<<<<<<<<<
 * 
 *     cdef int _read_digits(self, char stop_char) except -1:
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L7;
    __pyx_L5: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L7;
    __pyx_L6: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L7;
    }
    __pyx_L7:;
    Py_LeaveRecursiveCall();
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__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_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._decode_object");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":124
 *             Py_LeaveRecursiveCall()
 * 
 *     cdef int _read_digits(self, char stop_char) except -1:             # <<<<<<<<<<<<<<
 *         cdef int i
 *         i = 0
 */

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_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("_read_digits");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":126
 *     cdef int _read_digits(self, char stop_char) except -1:
 *         cdef int i
 *         i = 0             # <<<<<<<<<<<<<<
 *         while ((self.tail[i] >= c'0' and self.tail[i] <= c'9') or
 *                self.tail[i] == c'-') and i < self.size:
 */
  __pyx_v_i = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":127
 *         cdef int i
 *         i = 0
 *         while ((self.tail[i] >= c'0' and self.tail[i] <= c'9') or             # <<<<<<<<<<<<<<
 *                self.tail[i] == c'-') and i < self.size:
 *             i = i + 1
 */
  while (1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":128
 *         i = 0
 *         while ((self.tail[i] >= c'0' and self.tail[i] <= c'9') or
 *                self.tail[i] == c'-') and i < self.size:             # <<<<<<<<<<<<<<
 *             i = i + 1
 * 
 */
    __pyx_t_1 = ((__pyx_v_self->tail[__pyx_v_i]) >= '0');
    if (__pyx_t_1) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":127
 *         cdef int i
 *         i = 0
 *         while ((self.tail[i] >= c'0' and self.tail[i] <= c'9') or             # <<<<<<<<<<<<<<
 *                self.tail[i] == c'-') and i < self.size:
 *             i = i + 1
 */
      __pyx_t_2 = ((__pyx_v_self->tail[__pyx_v_i]) <= '9');
      __pyx_t_3 = __pyx_t_2;
    } else {
      __pyx_t_3 = __pyx_t_1;
    }
    if (!__pyx_t_3) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":128
 *         i = 0
 *         while ((self.tail[i] >= c'0' and self.tail[i] <= c'9') or
 *                self.tail[i] == c'-') and i < self.size:             # <<<<<<<<<<<<<<
 *             i = i + 1
 * 
 */
      __pyx_t_1 = ((__pyx_v_self->tail[__pyx_v_i]) == '-');
      __pyx_t_2 = __pyx_t_1;
    } else {
      __pyx_t_2 = __pyx_t_3;
    }
    if (__pyx_t_2) {
      __pyx_t_3 = (__pyx_v_i < __pyx_v_self->size);
      __pyx_t_1 = __pyx_t_3;
    } else {
      __pyx_t_1 = __pyx_t_2;
    }
    if (!__pyx_t_1) break;

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":129
 *         while ((self.tail[i] >= c'0' and self.tail[i] <= c'9') or
 *                self.tail[i] == c'-') and i < self.size:
 *             i = i + 1             # <<<<<<<<<<<<<<
 * 
 *         if self.tail[i] != stop_char:
 */
    __pyx_v_i = (__pyx_v_i + 1);
  }

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":131
 *             i = i + 1
 * 
 *         if self.tail[i] != stop_char:             # <<<<<<<<<<<<<<
 *             raise ValueError("Stop character %c not found: %c" %
 *                 (stop_char, self.tail[i]))
 */
  __pyx_t_1 = ((__pyx_v_self->tail[__pyx_v_i]) != __pyx_v_stop_char);
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":133
 *         if self.tail[i] != stop_char:
 *             raise ValueError("Stop character %c not found: %c" %
 *                 (stop_char, self.tail[i]))             # <<<<<<<<<<<<<<
 *         if (self.tail[0] == c'0' or
 *                 (self.tail[0] == c'-' and self.tail[1] == c'0')):
 */
    __pyx_t_4 = PyInt_FromLong(__pyx_v_stop_char); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyInt_FromLong((__pyx_v_self->tail[__pyx_v_i])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":134
 *             raise ValueError("Stop character %c not found: %c" %
 *                 (stop_char, self.tail[i]))
 *         if (self.tail[0] == c'0' or             # <<<<<<<<<<<<<<
 *                 (self.tail[0] == c'-' and self.tail[1] == c'0')):
 *             if i == 1:
 */
  __pyx_t_1 = ((__pyx_v_self->tail[0]) == '0');
  if (!__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":135
 *                 (stop_char, self.tail[i]))
 *         if (self.tail[0] == c'0' or
 *                 (self.tail[0] == c'-' and self.tail[1] == c'0')):             # <<<<<<<<<<<<<<
 *             if i == 1:
 *                 return i
 */
    __pyx_t_2 = ((__pyx_v_self->tail[0]) == '-');
    if (__pyx_t_2) {
      __pyx_t_3 = ((__pyx_v_self->tail[1]) == '0');
      __pyx_t_7 = __pyx_t_3;
    } else {
      __pyx_t_7 = __pyx_t_2;
    }
    __pyx_t_2 = __pyx_t_7;
  } else {
    __pyx_t_2 = __pyx_t_1;
  }
  if (__pyx_t_2) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":136
 *         if (self.tail[0] == c'0' or
 *                 (self.tail[0] == c'-' and self.tail[1] == c'0')):
 *             if i == 1:             # <<<<<<<<<<<<<<
 *                 return i
 *             else:
 */
    __pyx_t_2 = (__pyx_v_i == 1);
    if (__pyx_t_2) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":137
 *                 (self.tail[0] == c'-' and self.tail[1] == c'0')):
 *             if i == 1:
 *                 return i             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError # leading zeroes are not allowed
 */
      __pyx_r = __pyx_v_i;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":139
 *                 return i
 *             else:
 *                 raise ValueError # leading zeroes are not allowed             # <<<<<<<<<<<<<<
 *         return i
 * 
 */
      __Pyx_Raise(__pyx_builtin_ValueError, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":140
 *             else:
 *                 raise ValueError # leading zeroes are not allowed
 *         return i             # <<<<<<<<<<<<<<
 * 
 *     cdef object _decode_int(self):
 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._read_digits");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":142
 *         return i
 * 
 *     cdef object _decode_int(self):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         i = self._read_digits(c'e')
 */

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 = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_decode_int");
  __pyx_v_ret = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":144
 *     cdef object _decode_int(self):
 *         cdef int i
 *         i = self._read_digits(c'e')             # <<<<<<<<<<<<<<
 *         self.tail[i] = 0
 *         try:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_read_digits(__pyx_v_self, 'e'); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_i = __pyx_t_1;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":145
 *         cdef int i
 *         i = self._read_digits(c'e')
 *         self.tail[i] = 0             # <<<<<<<<<<<<<<
 *         try:
 *             ret = PyInt_FromString(self.tail, NULL, 10)
 */
  (__pyx_v_self->tail[__pyx_v_i]) = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":146
 *         i = self._read_digits(c'e')
 *         self.tail[i] = 0
 *         try:             # <<<<<<<<<<<<<<
 *             ret = PyInt_FromString(self.tail, NULL, 10)
 *         finally:
 */
  /*try:*/ {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":147
 *         self.tail[i] = 0
 *         try:
 *             ret = PyInt_FromString(self.tail, NULL, 10)             # <<<<<<<<<<<<<<
 *         finally:
 *             self.tail[i] = c'e'
 */
    __pyx_t_2 = PyInt_FromString(__pyx_v_self->tail, NULL, 10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L4;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_ret);
    __pyx_v_ret = __pyx_t_2;
    __pyx_t_2 = 0;
  }

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":149
 *             ret = PyInt_FromString(self.tail, NULL, 10)
 *         finally:
 *             self.tail[i] = c'e'             # <<<<<<<<<<<<<<
 *         D_UPDATE_TAIL(self, i+1)
 *         return ret
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;
    (__pyx_v_self->tail[__pyx_v_i]) = 'e';
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__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_error;
      }
    }
  }

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":150
 *         finally:
 *             self.tail[i] = c'e'
 *         D_UPDATE_TAIL(self, i+1)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
  D_UPDATE_TAIL(__pyx_v_self, (__pyx_v_i + 1));

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":151
 *             self.tail[i] = c'e'
 *         D_UPDATE_TAIL(self, i+1)
 *         return ret             # <<<<<<<<<<<<<<
 * 
 *     cdef object _decode_string(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ret);
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._decode_int");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":153
 *         return ret
 * 
 *     cdef object _decode_string(self):             # <<<<<<<<<<<<<<
 *         cdef int n
 *         cdef char *next_tail
 */

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 = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_decode_string");
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":160
 *         # or they wouldn't have called _decode_string
 *         # strtol will stop at trailing whitespace, etc
 *         n = strtol(self.tail, &next_tail, 10)             # <<<<<<<<<<<<<<
 *         if next_tail == NULL or next_tail[0] != c':':
 *             raise ValueError('string len not terminated by ":"')
 */
  __pyx_v_n = strtol(__pyx_v_self->tail, (&__pyx_v_next_tail), 10);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":161
 *         # strtol will stop at trailing whitespace, etc
 *         n = strtol(self.tail, &next_tail, 10)
 *         if next_tail == NULL or next_tail[0] != c':':             # <<<<<<<<<<<<<<
 *             raise ValueError('string len not terminated by ":"')
 *         # strtol allows leading zeros, so validate that we don't have that
 */
  __pyx_t_1 = (__pyx_v_next_tail == NULL);
  if (!__pyx_t_1) {
    __pyx_t_2 = ((__pyx_v_next_tail[0]) != ':');
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":162
 *         n = strtol(self.tail, &next_tail, 10)
 *         if next_tail == NULL or next_tail[0] != c':':
 *             raise ValueError('string len not terminated by ":"')             # <<<<<<<<<<<<<<
 *         # strtol allows leading zeros, so validate that we don't have that
 *         if (self.tail[0] == c'0'
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_7));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":164
 *             raise ValueError('string len not terminated by ":"')
 *         # strtol allows leading zeros, so validate that we don't have that
 *         if (self.tail[0] == c'0'             # <<<<<<<<<<<<<<
 *             and (n != 0 or (next_tail - self.tail != 1))):
 *             raise ValueError('leading zeros are not allowed')
 */
  __pyx_t_3 = ((__pyx_v_self->tail[0]) == '0');
  if (__pyx_t_3) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":165
 *         # strtol allows leading zeros, so validate that we don't have that
 *         if (self.tail[0] == c'0'
 *             and (n != 0 or (next_tail - self.tail != 1))):             # <<<<<<<<<<<<<<
 *             raise ValueError('leading zeros are not allowed')
 *         D_UPDATE_TAIL(self, next_tail - self.tail + 1)
 */
    __pyx_t_1 = (__pyx_v_n != 0);
    if (!__pyx_t_1) {
      __pyx_t_2 = ((__pyx_v_next_tail - __pyx_v_self->tail) != 1);
      __pyx_t_6 = __pyx_t_2;
    } else {
      __pyx_t_6 = __pyx_t_1;
    }
    __pyx_t_1 = __pyx_t_6;
  } else {
    __pyx_t_1 = __pyx_t_3;
  }
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":166
 *         if (self.tail[0] == c'0'
 *             and (n != 0 or (next_tail - self.tail != 1))):
 *             raise ValueError('leading zeros are not allowed')             # <<<<<<<<<<<<<<
 *         D_UPDATE_TAIL(self, next_tail - self.tail + 1)
 *         if n == 0:
 */
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_8));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":167
 *             and (n != 0 or (next_tail - self.tail != 1))):
 *             raise ValueError('leading zeros are not allowed')
 *         D_UPDATE_TAIL(self, next_tail - self.tail + 1)             # <<<<<<<<<<<<<<
 *         if n == 0:
 *             return ''
 */
  D_UPDATE_TAIL(__pyx_v_self, ((__pyx_v_next_tail - __pyx_v_self->tail) + 1));

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":168
 *             raise ValueError('leading zeros are not allowed')
 *         D_UPDATE_TAIL(self, next_tail - self.tail + 1)
 *         if n == 0:             # <<<<<<<<<<<<<<
 *             return ''
 *         if n > self.size:
 */
  __pyx_t_1 = (__pyx_v_n == 0);
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":169
 *         D_UPDATE_TAIL(self, next_tail - self.tail + 1)
 *         if n == 0:
 *             return ''             # <<<<<<<<<<<<<<
 *         if n > self.size:
 *             raise ValueError('stream underflow')
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_9));
    __pyx_r = ((PyObject *)__pyx_kp_s_9);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":170
 *         if n == 0:
 *             return ''
 *         if n > self.size:             # <<<<<<<<<<<<<<
 *             raise ValueError('stream underflow')
 *         if n < 0:
 */
  __pyx_t_1 = (__pyx_v_n > __pyx_v_self->size);
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":171
 *             return ''
 *         if n > self.size:
 *             raise ValueError('stream underflow')             # <<<<<<<<<<<<<<
 *         if n < 0:
 *             raise ValueError('string size below zero: %d' % n)
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":172
 *         if n > self.size:
 *             raise ValueError('stream underflow')
 *         if n < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('string size below zero: %d' % n)
 * 
 */
  __pyx_t_1 = (__pyx_v_n < 0);
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":173
 *             raise ValueError('stream underflow')
 *         if n < 0:
 *             raise ValueError('string size below zero: %d' % n)             # <<<<<<<<<<<<<<
 * 
 *         result = PyString_FromStringAndSize(self.tail, n)
 */
    __pyx_t_5 = PyInt_FromLong(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":175
 *             raise ValueError('string size below zero: %d' % n)
 * 
 *         result = PyString_FromStringAndSize(self.tail, n)             # <<<<<<<<<<<<<<
 *         D_UPDATE_TAIL(self, n)
 *         return result
 */
  __pyx_t_4 = PyString_FromStringAndSize(__pyx_v_self->tail, __pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":176
 * 
 *         result = PyString_FromStringAndSize(self.tail, n)
 *         D_UPDATE_TAIL(self, n)             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  D_UPDATE_TAIL(__pyx_v_self, __pyx_v_n);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":177
 *         result = PyString_FromStringAndSize(self.tail, n)
 *         D_UPDATE_TAIL(self, n)
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cdef object _decode_list(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._decode_string");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":179
 *         return result
 * 
 *     cdef object _decode_list(self):             # <<<<<<<<<<<<<<
 *         result = []
 * 
 */

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 = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_decode_list");
  __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":180
 * 
 *     cdef object _decode_list(self):
 *         result = []             # <<<<<<<<<<<<<<
 * 
 *         while self.size > 0:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(((PyObject *)__pyx_v_result));
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":182
 *         result = []
 * 
 *         while self.size > 0:             # <<<<<<<<<<<<<<
 *             if self.tail[0] == c'e':
 *                 D_UPDATE_TAIL(self, 1)
 */
  while (1) {
    __pyx_t_2 = (__pyx_v_self->size > 0);
    if (!__pyx_t_2) break;

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":183
 * 
 *         while self.size > 0:
 *             if self.tail[0] == c'e':             # <<<<<<<<<<<<<<
 *                 D_UPDATE_TAIL(self, 1)
 *                 if self._yield_tuples:
 */
    __pyx_t_2 = ((__pyx_v_self->tail[0]) == 'e');
    if (__pyx_t_2) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":184
 *         while self.size > 0:
 *             if self.tail[0] == c'e':
 *                 D_UPDATE_TAIL(self, 1)             # <<<<<<<<<<<<<<
 *                 if self._yield_tuples:
 *                     return tuple(result)
 */
      D_UPDATE_TAIL(__pyx_v_self, 1);

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":185
 *             if self.tail[0] == c'e':
 *                 D_UPDATE_TAIL(self, 1)
 *                 if self._yield_tuples:             # <<<<<<<<<<<<<<
 *                     return tuple(result)
 *                 else:
 */
      if (__pyx_v_self->_yield_tuples) {

        /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":186
 *                 D_UPDATE_TAIL(self, 1)
 *                 if self._yield_tuples:
 *                     return tuple(result)             # <<<<<<<<<<<<<<
 *                 else:
 *                     return result
 */
        __Pyx_XDECREF(__pyx_r);
        if (unlikely(__pyx_v_result == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
        }
        __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_v_result)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
        __pyx_r = ((PyObject *)__pyx_t_1);
        __pyx_t_1 = 0;
        goto __pyx_L0;
        goto __pyx_L6;
      }
      /*else*/ {

        /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":188
 *                     return tuple(result)
 *                 else:
 *                     return result             # <<<<<<<<<<<<<<
 *             else:
 *                 # As a quick shortcut, check to see if the next object is a
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(((PyObject *)__pyx_v_result));
        __pyx_r = ((PyObject *)__pyx_v_result);
        goto __pyx_L0;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":193
 *                 # string, since we know that won't be creating recursion
 *                 # if self.tail[0] >= c'0' and self.tail[0] <= c'9':
 *                 PyList_Append(result, self._decode_object())             # <<<<<<<<<<<<<<
 * 
 *         raise ValueError('malformed list')
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyList_Append(((PyObject *)__pyx_v_result), __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L5:;
  }

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":195
 *                 PyList_Append(result, self._decode_object())
 * 
 *         raise ValueError('malformed list')             # <<<<<<<<<<<<<<
 * 
 *     cdef object _decode_dict(self):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_11));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
  __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_Raise(__pyx_t_4, 0, 0);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._decode_list");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":197
 *         raise ValueError('malformed list')
 * 
 *     cdef object _decode_dict(self):             # <<<<<<<<<<<<<<
 *         cdef char ch
 * 
 */

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 = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_decode_dict");
  __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_lastkey = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":200
 *         cdef char ch
 * 
 *         result = {}             # <<<<<<<<<<<<<<
 *         lastkey = None
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(((PyObject *)__pyx_v_result));
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":201
 * 
 *         result = {}
 *         lastkey = None             # <<<<<<<<<<<<<<
 * 
 *         while self.size > 0:
 */
  __Pyx_INCREF(Py_None);
  __Pyx_DECREF(__pyx_v_lastkey);
  __pyx_v_lastkey = Py_None;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":203
 *         lastkey = None
 * 
 *         while self.size > 0:             # <<<<<<<<<<<<<<
 *             ch = self.tail[0]
 *             if ch == c'e':
 */
  while (1) {
    __pyx_t_2 = (__pyx_v_self->size > 0);
    if (!__pyx_t_2) break;

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":204
 * 
 *         while self.size > 0:
 *             ch = self.tail[0]             # <<<<<<<<<<<<<<
 *             if ch == c'e':
 *                 D_UPDATE_TAIL(self, 1)
 */
    __pyx_v_ch = (__pyx_v_self->tail[0]);

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":205
 *         while self.size > 0:
 *             ch = self.tail[0]
 *             if ch == c'e':             # <<<<<<<<<<<<<<
 *                 D_UPDATE_TAIL(self, 1)
 *                 return result
 */
    __pyx_t_2 = (__pyx_v_ch == 'e');
    if (__pyx_t_2) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":206
 *             ch = self.tail[0]
 *             if ch == c'e':
 *                 D_UPDATE_TAIL(self, 1)             # <<<<<<<<<<<<<<
 *                 return result
 *             else:
 */
      D_UPDATE_TAIL(__pyx_v_self, 1);

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":207
 *             if ch == c'e':
 *                 D_UPDATE_TAIL(self, 1)
 *                 return result             # <<<<<<<<<<<<<<
 *             else:
 *                 # keys should be strings only
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_result));
      __pyx_r = ((PyObject *)__pyx_v_result);
      goto __pyx_L0;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":210
 *             else:
 *                 # keys should be strings only
 *                 if self.tail[0] < c'0' or self.tail[0] > c'9':             # <<<<<<<<<<<<<<
 *                     raise ValueError('key was not a simple string.')
 *                 key = self._decode_string()
 */
      __pyx_t_2 = ((__pyx_v_self->tail[0]) < '0');
      if (!__pyx_t_2) {
        __pyx_t_3 = ((__pyx_v_self->tail[0]) > '9');
        __pyx_t_4 = __pyx_t_3;
      } else {
        __pyx_t_4 = __pyx_t_2;
      }
      if (__pyx_t_4) {

        /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":211
 *                 # keys should be strings only
 *                 if self.tail[0] < c'0' or self.tail[0] > c'9':
 *                     raise ValueError('key was not a simple string.')             # <<<<<<<<<<<<<<
 *                 key = self._decode_string()
 *                 if lastkey >= key:
 */
        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_12));
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":212
 *                 if self.tail[0] < c'0' or self.tail[0] > c'9':
 *                     raise ValueError('key was not a simple string.')
 *                 key = self._decode_string()             # <<<<<<<<<<<<<<
 *                 if lastkey >= key:
 *                     raise ValueError('dict keys disordered')
 */
      __pyx_t_5 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_string(__pyx_v_self); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_v_key);
      __pyx_v_key = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":213
 *                     raise ValueError('key was not a simple string.')
 *                 key = self._decode_string()
 *                 if lastkey >= key:             # <<<<<<<<<<<<<<
 *                     raise ValueError('dict keys disordered')
 *                 else:
 */
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_lastkey, __pyx_v_key, Py_GE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_4) {

        /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":214
 *                 key = self._decode_string()
 *                 if lastkey >= key:
 *                     raise ValueError('dict keys disordered')             # <<<<<<<<<<<<<<
 *                 else:
 *                     lastkey = key
 */
        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_13));
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13));
        __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      /*else*/ {

        /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":216
 *                     raise ValueError('dict keys disordered')
 *                 else:
 *                     lastkey = key             # <<<<<<<<<<<<<<
 *                 value = self._decode_object()
 *                 result[key] = value
 */
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_DECREF(__pyx_v_lastkey);
        __pyx_v_lastkey = __pyx_v_key;
      }
      __pyx_L7:;

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":217
 *                 else:
 *                     lastkey = key
 *                 value = self._decode_object()             # <<<<<<<<<<<<<<
 *                 result[key] = value
 * 
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Decoder *)__pyx_v_self->__pyx_vtab)->_decode_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":218
 *                     lastkey = key
 *                 value = self._decode_object()
 *                 result[key] = value             # <<<<<<<<<<<<<<
 * 
 *         raise ValueError('malformed dict')
 */
      if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L5:;
  }

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":220
 *                 result[key] = value
 * 
 *         raise ValueError('malformed dict')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_14));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_14));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_14));
  __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_Raise(__pyx_t_5, 0, 0);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Decoder._decode_dict");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_DECREF(__pyx_v_lastkey);
  __Pyx_DECREF(__pyx_v_key);
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":223
 * 
 * 
 * def bdecode(object s):             # <<<<<<<<<<<<<<
 *     """Decode string x to Python object"""
 *     return Decoder(s).decode()
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_bdecode(PyObject *__pyx_self, PyObject *__pyx_v_s); /*proto*/
static char __pyx_doc_6bzrlib_12_bencode_pyx_bdecode[] = "Decode string x to Python object";
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_bdecode(PyObject *__pyx_self, PyObject *__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("bdecode");
  __pyx_self = __pyx_self;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":225
 * def bdecode(object s):
 *     """Decode string x to Python object"""
 *     return Decoder(s).decode()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_s);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s);
  __Pyx_GIVEREF(__pyx_v_s);
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_12_bencode_pyx_Decoder)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__decode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.bdecode");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":228
 * 
 * 
 * def bdecode_as_tuple(object s):             # <<<<<<<<<<<<<<
 *     """Decode string x to Python object, using tuples rather than lists."""
 *     return Decoder(s, True).decode()
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_bdecode_as_tuple(PyObject *__pyx_self, PyObject *__pyx_v_s); /*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_pf_6bzrlib_12_bencode_pyx_bdecode_as_tuple(PyObject *__pyx_self, PyObject *__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("bdecode_as_tuple");
  __pyx_self = __pyx_self;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":230
 * def bdecode_as_tuple(object s):
 *     """Decode string x to Python object, using tuples rather than lists."""
 *     return Decoder(s, True).decode()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_s);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_s);
  __Pyx_GIVEREF(__pyx_v_s);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_12_bencode_pyx_Decoder)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__decode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.bdecode_as_tuple");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":236
 *     __slots__ = ['bencoded']
 * 
 *     def __init__(self, s):             # <<<<<<<<<<<<<<
 *         self.bencoded = s
 * 
 */

static PyObject *__pyx_pf_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__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_6bzrlib_12_bencode_pyx_9Bencached___init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_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 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__s,0};
  __Pyx_RefNannySetupContext("__init__");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__s);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_s = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_s = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Bencached.__init__");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":237
 * 
 *     def __init__(self, s):
 *         self.bencoded = s             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__bencoded, __pyx_v_s) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Bencached.__init__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":248
 *     """Bencode encoder"""
 * 
 *     cdef readonly char *tail             # <<<<<<<<<<<<<<
 *     cdef readonly int size
 *     cdef readonly char *buffer
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_4tail___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_4tail___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->tail); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.tail.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":249
 * 
 *     cdef readonly char *tail
 *     cdef readonly int size             # <<<<<<<<<<<<<<
 *     cdef readonly char *buffer
 *     cdef readonly int maxsize
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_4size___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_4size___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.size.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":250
 *     cdef readonly char *tail
 *     cdef readonly int size
 *     cdef readonly char *buffer             # <<<<<<<<<<<<<<
 *     cdef readonly int maxsize
 * 
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_6buffer___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_6buffer___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->buffer); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.buffer.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":251
 *     cdef readonly int size
 *     cdef readonly char *buffer
 *     cdef readonly int maxsize             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, int maxsize=INITSIZE):
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_7maxsize___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_7maxsize___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->maxsize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.maxsize.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":253
 *     cdef readonly int maxsize
 * 
 *     def __init__(self, int maxsize=INITSIZE):             # <<<<<<<<<<<<<<
 *         """Initialize encoder engine
 *         @param  maxsize:    initial size of internal char buffer
 */

static int __pyx_pf_6bzrlib_12_bencode_pyx_7Encoder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_12_bencode_pyx_7Encoder___init__[] = "Initialize encoder engine\n        @param  maxsize:    initial size of internal char buffer\n        ";
struct wrapperbase __pyx_wrapperbase_6bzrlib_12_bencode_pyx_7Encoder___init__;
static int __pyx_pf_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_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__maxsize,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__maxsize);
        if (value) { values[0] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_maxsize = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_maxsize == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_maxsize = __pyx_k_15;
    }
  } else {
    __pyx_v_maxsize = __pyx_k_15;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_maxsize = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_maxsize == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":259
 *         cdef char *p
 * 
 *         self.maxsize = 0             # <<<<<<<<<<<<<<
 *         self.size = 0
 *         self.tail = NULL
 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->maxsize = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":260
 * 
 *         self.maxsize = 0
 *         self.size = 0             # <<<<<<<<<<<<<<
 *         self.tail = NULL
 * 
 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->size = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":261
 *         self.maxsize = 0
 *         self.size = 0
 *         self.tail = NULL             # <<<<<<<<<<<<<<
 * 
 *         p = <char*>malloc(maxsize)
 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->tail = NULL;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":263
 *         self.tail = NULL
 * 
 *         p = <char*>malloc(maxsize)             # <<<<<<<<<<<<<<
 *         if p == NULL:
 *             raise MemoryError('Not enough memory to allocate buffer '
 */
  __pyx_v_p = ((char *)malloc(__pyx_v_maxsize));

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":264
 * 
 *         p = <char*>malloc(maxsize)
 *         if p == NULL:             # <<<<<<<<<<<<<<
 *             raise MemoryError('Not enough memory to allocate buffer '
 *                               'for encoder')
 */
  __pyx_t_1 = (__pyx_v_p == NULL);
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":265
 *         p = <char*>malloc(maxsize)
 *         if p == NULL:
 *             raise MemoryError('Not enough memory to allocate buffer '             # <<<<<<<<<<<<<<
 *                               'for encoder')
 *         self.buffer = p
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_16));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_16));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":267
 *             raise MemoryError('Not enough memory to allocate buffer '
 *                               'for encoder')
 *         self.buffer = p             # <<<<<<<<<<<<<<
 *         self.maxsize = maxsize
 *         self.tail = p
 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->buffer = __pyx_v_p;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":268
 *                               'for encoder')
 *         self.buffer = p
 *         self.maxsize = maxsize             # <<<<<<<<<<<<<<
 *         self.tail = p
 * 
 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->maxsize = __pyx_v_maxsize;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":269
 *         self.buffer = p
 *         self.maxsize = maxsize
 *         self.tail = p             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->tail = __pyx_v_p;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":271
 *         self.tail = p
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         free(self.buffer)
 *         self.buffer = NULL
 */

static void __pyx_pf_6bzrlib_12_bencode_pyx_7Encoder___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_6bzrlib_12_bencode_pyx_7Encoder___dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":272
 * 
 *     def __dealloc__(self):
 *         free(self.buffer)             # <<<<<<<<<<<<<<
 *         self.buffer = NULL
 *         self.maxsize = 0
 */
  free(((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->buffer);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":273
 *     def __dealloc__(self):
 *         free(self.buffer)
 *         self.buffer = NULL             # <<<<<<<<<<<<<<
 *         self.maxsize = 0
 * 
 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->buffer = NULL;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":274
 *         free(self.buffer)
 *         self.buffer = NULL
 *         self.maxsize = 0             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->maxsize = 0;

  __Pyx_RefNannyFinishContext();
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":276
 *         self.maxsize = 0
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         if self.buffer != NULL and self.size != 0:
 *             return PyString_FromStringAndSize(self.buffer, self.size)
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder___str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__str__");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":277
 * 
 *     def __str__(self):
 *         if self.buffer != NULL and self.size != 0:             # <<<<<<<<<<<<<<
 *             return PyString_FromStringAndSize(self.buffer, self.size)
 *         else:
 */
  __pyx_t_1 = (((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->buffer != NULL);
  if (__pyx_t_1) {
    __pyx_t_2 = (((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self)->size != 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":278
 *     def __str__(self):
 *         if self.buffer != NULL and self.size != 0:
 *             return PyString_FromStringAndSize(self.buffer, self.size)             # <<<<<<<<<<<<<<
 *         else:
 *             return ''
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = 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 (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":280
 *             return PyString_FromStringAndSize(self.buffer, self.size)
 *         else:
 *             return ''             # <<<<<<<<<<<<<<
 * 
 *     cdef int _ensure_buffer(self, int required) except 0:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_9));
    __pyx_r = ((PyObject *)__pyx_kp_s_9);
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":282
 *             return ''
 * 
 *     cdef int _ensure_buffer(self, int required) except 0:             # <<<<<<<<<<<<<<
 *         """Ensure that tail of CharTail buffer has enough size.
 *         If buffer is not big enough then function try to
 */

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_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_ensure_buffer");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":290
 *         cdef int   new_size
 * 
 *         if self.size + required < self.maxsize:             # <<<<<<<<<<<<<<
 *             return 1
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->size + __pyx_v_required) < __pyx_v_self->maxsize);
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":291
 * 
 *         if self.size + required < self.maxsize:
 *             return 1             # <<<<<<<<<<<<<<
 * 
 *         new_size = self.maxsize
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":293
 *             return 1
 * 
 *         new_size = self.maxsize             # <<<<<<<<<<<<<<
 *         while new_size < self.size + required:
 *             new_size = new_size * 2
 */
  __pyx_v_new_size = __pyx_v_self->maxsize;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":294
 * 
 *         new_size = self.maxsize
 *         while new_size < self.size + required:             # <<<<<<<<<<<<<<
 *             new_size = new_size * 2
 *         new_buffer = <char*>realloc(self.buffer, <size_t>new_size)
 */
  while (1) {
    __pyx_t_1 = (__pyx_v_new_size < (__pyx_v_self->size + __pyx_v_required));
    if (!__pyx_t_1) break;

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":295
 *         new_size = self.maxsize
 *         while new_size < self.size + required:
 *             new_size = new_size * 2             # <<<<<<<<<<<<<<
 *         new_buffer = <char*>realloc(self.buffer, <size_t>new_size)
 *         if new_buffer == NULL:
 */
    __pyx_v_new_size = (__pyx_v_new_size * 2);
  }

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":296
 *         while new_size < self.size + required:
 *             new_size = new_size * 2
 *         new_buffer = <char*>realloc(self.buffer, <size_t>new_size)             # <<<<<<<<<<<<<<
 *         if new_buffer == NULL:
 *             raise MemoryError('Cannot realloc buffer for encoder')
 */
  __pyx_v_new_buffer = ((char *)realloc(__pyx_v_self->buffer, ((size_t)__pyx_v_new_size)));

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":297
 *             new_size = new_size * 2
 *         new_buffer = <char*>realloc(self.buffer, <size_t>new_size)
 *         if new_buffer == NULL:             # <<<<<<<<<<<<<<
 *             raise MemoryError('Cannot realloc buffer for encoder')
 * 
 */
  __pyx_t_1 = (__pyx_v_new_buffer == NULL);
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":298
 *         new_buffer = <char*>realloc(self.buffer, <size_t>new_size)
 *         if new_buffer == NULL:
 *             raise MemoryError('Cannot realloc buffer for encoder')             # <<<<<<<<<<<<<<
 * 
 *         self.buffer = new_buffer
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_17));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":300
 *             raise MemoryError('Cannot realloc buffer for encoder')
 * 
 *         self.buffer = new_buffer             # <<<<<<<<<<<<<<
 *         self.maxsize = new_size
 *         self.tail = &new_buffer[self.size]
 */
  __pyx_v_self->buffer = __pyx_v_new_buffer;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":301
 * 
 *         self.buffer = new_buffer
 *         self.maxsize = new_size             # <<<<<<<<<<<<<<
 *         self.tail = &new_buffer[self.size]
 *         return 1
 */
  __pyx_v_self->maxsize = __pyx_v_new_size;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":302
 *         self.buffer = new_buffer
 *         self.maxsize = new_size
 *         self.tail = &new_buffer[self.size]             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  __pyx_v_self->tail = (&(__pyx_v_new_buffer[__pyx_v_self->size]));

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":303
 *         self.maxsize = new_size
 *         self.tail = &new_buffer[self.size]
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     cdef int _encode_int(self, int x) except 0:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._ensure_buffer");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":305
 *         return 1
 * 
 *     cdef int _encode_int(self, int x) except 0:             # <<<<<<<<<<<<<<
 *         """Encode int to bencode string iNNNe
 *         @param  x:  value to encode
 */

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_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_encode_int");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":310
 *         """
 *         cdef int n
 *         self._ensure_buffer(INT_BUF_SIZE)             # <<<<<<<<<<<<<<
 *         n = snprintf(self.tail, INT_BUF_SIZE, "i%de", x)
 *         if n < 0:
 */
  __pyx_t_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 (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":311
 *         cdef int n
 *         self._ensure_buffer(INT_BUF_SIZE)
 *         n = snprintf(self.tail, INT_BUF_SIZE, "i%de", x)             # <<<<<<<<<<<<<<
 *         if n < 0:
 *             raise MemoryError('int %d too big to encode' % x)
 */
  __pyx_v_n = snprintf(__pyx_v_self->tail, __pyx_e_6bzrlib_12_bencode_pyx_INT_BUF_SIZE, __pyx_k_18, __pyx_v_x);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":312
 *         self._ensure_buffer(INT_BUF_SIZE)
 *         n = snprintf(self.tail, INT_BUF_SIZE, "i%de", x)
 *         if n < 0:             # <<<<<<<<<<<<<<
 *             raise MemoryError('int %d too big to encode' % x)
 *         E_UPDATE_TAIL(self, n)
 */
  __pyx_t_2 = (__pyx_v_n < 0);
  if (__pyx_t_2) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":313
 *         n = snprintf(self.tail, INT_BUF_SIZE, "i%de", x)
 *         if n < 0:
 *             raise MemoryError('int %d too big to encode' % x)             # <<<<<<<<<<<<<<
 *         E_UPDATE_TAIL(self, n)
 *         return 1
 */
    __pyx_t_3 = PyInt_FromLong(__pyx_v_x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":314
 *         if n < 0:
 *             raise MemoryError('int %d too big to encode' % x)
 *         E_UPDATE_TAIL(self, n)             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  E_UPDATE_TAIL(__pyx_v_self, __pyx_v_n);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":315
 *             raise MemoryError('int %d too big to encode' % x)
 *         E_UPDATE_TAIL(self, n)
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     cdef int _encode_long(self, x) except 0:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._encode_int");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":317
 *         return 1
 * 
 *     cdef int _encode_long(self, x) except 0:             # <<<<<<<<<<<<<<
 *         return self._append_string(''.join(('i', str(x), 'e')))
 * 
 */

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_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("_encode_long");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":318
 * 
 *     cdef int _encode_long(self, x) except 0:
 *         return self._append_string(''.join(('i', str(x), 'e')))             # <<<<<<<<<<<<<<
 * 
 *     cdef int _append_string(self, s) except 0:
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_9), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_x);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_x);
  __Pyx_GIVEREF(__pyx_v_x);
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__e));
  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_n_s__e));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__e));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_append_string(__pyx_v_self, __pyx_t_2); if (unlikely(__pyx_t_4 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._encode_long");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":320
 *         return self._append_string(''.join(('i', str(x), 'e')))
 * 
 *     cdef int _append_string(self, s) except 0:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t n
 *         n = PyString_GET_SIZE(s)
 */

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_t_1;
  int __pyx_t_2;
  char *__pyx_t_3;
  __Pyx_RefNannySetupContext("_append_string");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":322
 *     cdef int _append_string(self, s) except 0:
 *         cdef Py_ssize_t n
 *         n = PyString_GET_SIZE(s)             # <<<<<<<<<<<<<<
 *         self._ensure_buffer(n)
 *         memcpy(self.tail, PyString_AS_STRING(s), n)
 */
  __pyx_t_1 = PyString_GET_SIZE(__pyx_v_s); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_n = __pyx_t_1;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":323
 *         cdef Py_ssize_t n
 *         n = PyString_GET_SIZE(s)
 *         self._ensure_buffer(n)             # <<<<<<<<<<<<<<
 *         memcpy(self.tail, PyString_AS_STRING(s), n)
 *         E_UPDATE_TAIL(self, n)
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self, __pyx_v_n); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":324
 *         n = PyString_GET_SIZE(s)
 *         self._ensure_buffer(n)
 *         memcpy(self.tail, PyString_AS_STRING(s), n)             # <<<<<<<<<<<<<<
 *         E_UPDATE_TAIL(self, n)
 *         return 1
 */
  __pyx_t_3 = PyString_AS_STRING(__pyx_v_s); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  memcpy(__pyx_v_self->tail, __pyx_t_3, __pyx_v_n);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":325
 *         self._ensure_buffer(n)
 *         memcpy(self.tail, PyString_AS_STRING(s), n)
 *         E_UPDATE_TAIL(self, n)             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  E_UPDATE_TAIL(__pyx_v_self, __pyx_v_n);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":326
 *         memcpy(self.tail, PyString_AS_STRING(s), n)
 *         E_UPDATE_TAIL(self, n)
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     cdef int _encode_string(self, x) except 0:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._append_string");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":328
 *         return 1
 * 
 *     cdef int _encode_string(self, x) except 0:             # <<<<<<<<<<<<<<
 *         cdef int n
 *         cdef Py_ssize_t x_len
 */

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_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  char *__pyx_t_6;
  __Pyx_RefNannySetupContext("_encode_string");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":331
 *         cdef int n
 *         cdef Py_ssize_t x_len
 *         x_len = PyString_GET_SIZE(x)             # <<<<<<<<<<<<<<
 *         self._ensure_buffer(x_len + INT_BUF_SIZE)
 *         n = snprintf(self.tail, INT_BUF_SIZE, '%d:', x_len)
 */
  __pyx_t_1 = PyString_GET_SIZE(__pyx_v_x); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_x_len = __pyx_t_1;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":332
 *         cdef Py_ssize_t x_len
 *         x_len = PyString_GET_SIZE(x)
 *         self._ensure_buffer(x_len + INT_BUF_SIZE)             # <<<<<<<<<<<<<<
 *         n = snprintf(self.tail, INT_BUF_SIZE, '%d:', x_len)
 *         if n < 0:
 */
  __pyx_t_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 (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":333
 *         x_len = PyString_GET_SIZE(x)
 *         self._ensure_buffer(x_len + INT_BUF_SIZE)
 *         n = snprintf(self.tail, INT_BUF_SIZE, '%d:', x_len)             # <<<<<<<<<<<<<<
 *         if n < 0:
 *             raise MemoryError('string %s too big to encode' % x)
 */
  __pyx_v_n = snprintf(__pyx_v_self->tail, __pyx_e_6bzrlib_12_bencode_pyx_INT_BUF_SIZE, __pyx_k_20, __pyx_v_x_len);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":334
 *         self._ensure_buffer(x_len + INT_BUF_SIZE)
 *         n = snprintf(self.tail, INT_BUF_SIZE, '%d:', x_len)
 *         if n < 0:             # <<<<<<<<<<<<<<
 *             raise MemoryError('string %s too big to encode' % x)
 *         memcpy(<void *>(self.tail+n), PyString_AS_STRING(x), x_len)
 */
  __pyx_t_3 = (__pyx_v_n < 0);
  if (__pyx_t_3) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":335
 *         n = snprintf(self.tail, INT_BUF_SIZE, '%d:', x_len)
 *         if n < 0:
 *             raise MemoryError('string %s too big to encode' % x)             # <<<<<<<<<<<<<<
 *         memcpy(<void *>(self.tail+n), PyString_AS_STRING(x), x_len)
 *         E_UPDATE_TAIL(self, n + x_len)
 */
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_v_x); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":336
 *         if n < 0:
 *             raise MemoryError('string %s too big to encode' % x)
 *         memcpy(<void *>(self.tail+n), PyString_AS_STRING(x), x_len)             # <<<<<<<<<<<<<<
 *         E_UPDATE_TAIL(self, n + x_len)
 *         return 1
 */
  __pyx_t_6 = PyString_AS_STRING(__pyx_v_x); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  memcpy(((void *)(__pyx_v_self->tail + __pyx_v_n)), __pyx_t_6, __pyx_v_x_len);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":337
 *             raise MemoryError('string %s too big to encode' % x)
 *         memcpy(<void *>(self.tail+n), PyString_AS_STRING(x), x_len)
 *         E_UPDATE_TAIL(self, n + x_len)             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  E_UPDATE_TAIL(__pyx_v_self, (__pyx_v_n + __pyx_v_x_len));

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":338
 *         memcpy(<void *>(self.tail+n), PyString_AS_STRING(x), x_len)
 *         E_UPDATE_TAIL(self, n + x_len)
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     cdef int _encode_list(self, x) except 0:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._encode_string");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":340
 *         return 1
 * 
 *     cdef int _encode_list(self, x) except 0:             # <<<<<<<<<<<<<<
 *         self._ensure_buffer(1)
 *         self.tail[0] = c'l'
 */

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_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_encode_list");
  __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":341
 * 
 *     cdef int _encode_list(self, x) except 0:
 *         self._ensure_buffer(1)             # <<<<<<<<<<<<<<
 *         self.tail[0] = c'l'
 *         E_UPDATE_TAIL(self, 1)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":342
 *     cdef int _encode_list(self, x) except 0:
 *         self._ensure_buffer(1)
 *         self.tail[0] = c'l'             # <<<<<<<<<<<<<<
 *         E_UPDATE_TAIL(self, 1)
 * 
 */
  (__pyx_v_self->tail[0]) = 'l';

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":343
 *         self._ensure_buffer(1)
 *         self.tail[0] = c'l'
 *         E_UPDATE_TAIL(self, 1)             # <<<<<<<<<<<<<<
 * 
 *         for i in x:
 */
  E_UPDATE_TAIL(__pyx_v_self, 1);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":345
 *         E_UPDATE_TAIL(self, 1)
 * 
 *         for i in x:             # <<<<<<<<<<<<<<
 *             self.process(i)
 * 
 */
  if (PyList_CheckExact(__pyx_v_x) || PyTuple_CheckExact(__pyx_v_x)) {
    __pyx_t_2 = 0; __pyx_t_3 = __pyx_v_x; __Pyx_INCREF(__pyx_t_3);
  } else {
    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_t_3))) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else {
      __pyx_t_4 = PyIter_Next(__pyx_t_3);
      if (!__pyx_t_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":346
 * 
 *         for i in x:
 *             self.process(i)             # <<<<<<<<<<<<<<
 * 
 *         self._ensure_buffer(1)
 */
    __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__process); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    __pyx_t_6 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":348
 *             self.process(i)
 * 
 *         self._ensure_buffer(1)             # <<<<<<<<<<<<<<
 *         self.tail[0] = c'e'
 *         E_UPDATE_TAIL(self, 1)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":349
 * 
 *         self._ensure_buffer(1)
 *         self.tail[0] = c'e'             # <<<<<<<<<<<<<<
 *         E_UPDATE_TAIL(self, 1)
 *         return 1
 */
  (__pyx_v_self->tail[0]) = 'e';

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":350
 *         self._ensure_buffer(1)
 *         self.tail[0] = c'e'
 *         E_UPDATE_TAIL(self, 1)             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  E_UPDATE_TAIL(__pyx_v_self, 1);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":351
 *         self.tail[0] = c'e'
 *         E_UPDATE_TAIL(self, 1)
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     cdef int _encode_dict(self, x) except 0:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._encode_list");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_i);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":353
 *         return 1
 * 
 *     cdef int _encode_dict(self, x) except 0:             # <<<<<<<<<<<<<<
 *         self._ensure_buffer(1)
 *         self.tail[0] = c'd'
 */

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_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_encode_dict");
  __pyx_v_keys = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_k = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":354
 * 
 *     cdef int _encode_dict(self, x) except 0:
 *         self._ensure_buffer(1)             # <<<<<<<<<<<<<<
 *         self.tail[0] = c'd'
 *         E_UPDATE_TAIL(self, 1)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":355
 *     cdef int _encode_dict(self, x) except 0:
 *         self._ensure_buffer(1)
 *         self.tail[0] = c'd'             # <<<<<<<<<<<<<<
 *         E_UPDATE_TAIL(self, 1)
 * 
 */
  (__pyx_v_self->tail[0]) = 'd';

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":356
 *         self._ensure_buffer(1)
 *         self.tail[0] = c'd'
 *         E_UPDATE_TAIL(self, 1)             # <<<<<<<<<<<<<<
 * 
 *         keys = x.keys()
 */
  E_UPDATE_TAIL(__pyx_v_self, 1);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":358
 *         E_UPDATE_TAIL(self, 1)
 * 
 *         keys = x.keys()             # <<<<<<<<<<<<<<
 *         keys.sort()
 *         for k in keys:
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_keys);
  __pyx_v_keys = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":359
 * 
 *         keys = x.keys()
 *         keys.sort()             # <<<<<<<<<<<<<<
 *         for k in keys:
 *             if not PyString_CheckExact(k):
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_keys, __pyx_n_s__sort); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":360
 *         keys = x.keys()
 *         keys.sort()
 *         for k in keys:             # <<<<<<<<<<<<<<
 *             if not PyString_CheckExact(k):
 *                 raise TypeError('key in dict should be string')
 */
  if (PyList_CheckExact(__pyx_v_keys) || PyTuple_CheckExact(__pyx_v_keys)) {
    __pyx_t_4 = 0; __pyx_t_2 = __pyx_v_keys; __Pyx_INCREF(__pyx_t_2);
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_t_2))) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
    } else {
      __pyx_t_3 = PyIter_Next(__pyx_t_2);
      if (!__pyx_t_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_v_k);
    __pyx_v_k = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":361
 *         keys.sort()
 *         for k in keys:
 *             if not PyString_CheckExact(k):             # <<<<<<<<<<<<<<
 *                 raise TypeError('key in dict should be string')
 *             self._encode_string(k)
 */
    __pyx_t_5 = (!PyString_CheckExact(__pyx_v_k));
    if (__pyx_t_5) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":362
 *         for k in keys:
 *             if not PyString_CheckExact(k):
 *                 raise TypeError('key in dict should be string')             # <<<<<<<<<<<<<<
 *             self._encode_string(k)
 *             self.process(x[k])
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_22));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_22));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_22));
      __pyx_t_6 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":363
 *             if not PyString_CheckExact(k):
 *                 raise TypeError('key in dict should be string')
 *             self._encode_string(k)             # <<<<<<<<<<<<<<
 *             self.process(x[k])
 * 
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_encode_string(__pyx_v_self, __pyx_v_k); if (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":364
 *                 raise TypeError('key in dict should be string')
 *             self._encode_string(k)
 *             self.process(x[k])             # <<<<<<<<<<<<<<
 * 
 *         self._ensure_buffer(1)
 */
    __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__process); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyObject_GetItem(__pyx_v_x, __pyx_v_k); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":366
 *             self.process(x[k])
 * 
 *         self._ensure_buffer(1)             # <<<<<<<<<<<<<<
 *         self.tail[0] = c'e'
 *         E_UPDATE_TAIL(self, 1)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_12_bencode_pyx_Encoder *)__pyx_v_self->__pyx_vtab)->_ensure_buffer(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":367
 * 
 *         self._ensure_buffer(1)
 *         self.tail[0] = c'e'             # <<<<<<<<<<<<<<
 *         E_UPDATE_TAIL(self, 1)
 *         return 1
 */
  (__pyx_v_self->tail[0]) = 'e';

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":368
 *         self._ensure_buffer(1)
 *         self.tail[0] = c'e'
 *         E_UPDATE_TAIL(self, 1)             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  E_UPDATE_TAIL(__pyx_v_self, 1);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":369
 *         self.tail[0] = c'e'
 *         E_UPDATE_TAIL(self, 1)
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     def process(self, object x):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder._encode_dict");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_keys);
  __Pyx_DECREF(__pyx_v_k);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":371
 *         return 1
 * 
 *     def process(self, object x):             # <<<<<<<<<<<<<<
 *         if Py_EnterRecursiveCall("encode"):
 *             raise RuntimeError("too deeply nested")
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_process(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_process(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("process");

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":372
 * 
 *     def process(self, object x):
 *         if Py_EnterRecursiveCall("encode"):             # <<<<<<<<<<<<<<
 *             raise RuntimeError("too deeply nested")
 *         try:
 */
  __pyx_t_1 = Py_EnterRecursiveCall(__pyx_k__encode);
  if (__pyx_t_1) {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":373
 *     def process(self, object x):
 *         if Py_EnterRecursiveCall("encode"):
 *             raise RuntimeError("too deeply nested")             # <<<<<<<<<<<<<<
 *         try:
 *             if PyString_CheckExact(x):
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":374
 *         if Py_EnterRecursiveCall("encode"):
 *             raise RuntimeError("too deeply nested")
 *         try:             # <<<<<<<<<<<<<<
 *             if PyString_CheckExact(x):
 *                 self._encode_string(x)
 */
  /*try:*/ {

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":375
 *             raise RuntimeError("too deeply nested")
 *         try:
 *             if PyString_CheckExact(x):             # <<<<<<<<<<<<<<
 *                 self._encode_string(x)
 *             elif PyInt_CheckExact(x):
 */
    __pyx_t_1 = PyString_CheckExact(__pyx_v_x);
    if (__pyx_t_1) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":376
 *         try:
 *             if PyString_CheckExact(x):
 *                 self._encode_string(x)             # <<<<<<<<<<<<<<
 *             elif PyInt_CheckExact(x):
 *                 self._encode_int(x)
 */
      __pyx_t_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 (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L7;}
      goto __pyx_L9;
    }

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":377
 *             if PyString_CheckExact(x):
 *                 self._encode_string(x)
 *             elif PyInt_CheckExact(x):             # <<<<<<<<<<<<<<
 *                 self._encode_int(x)
 *             elif PyLong_CheckExact(x):
 */
    __pyx_t_1 = PyInt_CheckExact(__pyx_v_x);
    if (__pyx_t_1) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":378
 *                 self._encode_string(x)
 *             elif PyInt_CheckExact(x):
 *                 self._encode_int(x)             # <<<<<<<<<<<<<<
 *             elif PyLong_CheckExact(x):
 *                 self._encode_long(x)
 */
      __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_x); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __pyx_t_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_t_1); if (unlikely(__pyx_t_4 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L7;}
      goto __pyx_L9;
    }

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":379
 *             elif PyInt_CheckExact(x):
 *                 self._encode_int(x)
 *             elif PyLong_CheckExact(x):             # <<<<<<<<<<<<<<
 *                 self._encode_long(x)
 *             elif (PyList_CheckExact(x) or PyTuple_CheckExact(x)
 */
    __pyx_t_4 = PyLong_CheckExact(__pyx_v_x);
    if (__pyx_t_4) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":380
 *                 self._encode_int(x)
 *             elif PyLong_CheckExact(x):
 *                 self._encode_long(x)             # <<<<<<<<<<<<<<
 *             elif (PyList_CheckExact(x) or PyTuple_CheckExact(x)
 *                   or StaticTuple_CheckExact(x)):
 */
      __pyx_t_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 (unlikely(__pyx_t_4 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L7;}
      goto __pyx_L9;
    }

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":381
 *             elif PyLong_CheckExact(x):
 *                 self._encode_long(x)
 *             elif (PyList_CheckExact(x) or PyTuple_CheckExact(x)             # <<<<<<<<<<<<<<
 *                   or StaticTuple_CheckExact(x)):
 *                 self._encode_list(x)
 */
    __pyx_t_4 = PyList_CheckExact(__pyx_v_x);
    if (!__pyx_t_4) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":382
 *                 self._encode_long(x)
 *             elif (PyList_CheckExact(x) or PyTuple_CheckExact(x)
 *                   or StaticTuple_CheckExact(x)):             # <<<<<<<<<<<<<<
 *                 self._encode_list(x)
 *             elif PyDict_CheckExact(x):
 */
      __pyx_t_1 = PyTuple_CheckExact(__pyx_v_x);
      if (!__pyx_t_1) {
        __pyx_t_5 = StaticTuple_CheckExact(__pyx_v_x);
        __pyx_t_6 = __pyx_t_5;
      } else {
        __pyx_t_6 = __pyx_t_1;
      }
      __pyx_t_7 = __pyx_t_6;
    } else {
      __pyx_t_7 = __pyx_t_4;
    }
    if (__pyx_t_7) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":383
 *             elif (PyList_CheckExact(x) or PyTuple_CheckExact(x)
 *                   or StaticTuple_CheckExact(x)):
 *                 self._encode_list(x)             # <<<<<<<<<<<<<<
 *             elif PyDict_CheckExact(x):
 *                 self._encode_dict(x)
 */
      __pyx_t_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 (unlikely(__pyx_t_4 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L7;}
      goto __pyx_L9;
    }

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":384
 *                   or StaticTuple_CheckExact(x)):
 *                 self._encode_list(x)
 *             elif PyDict_CheckExact(x):             # <<<<<<<<<<<<<<
 *                 self._encode_dict(x)
 *             elif PyBool_Check(x):
 */
    __pyx_t_4 = PyDict_CheckExact(__pyx_v_x);
    if (__pyx_t_4) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":385
 *                 self._encode_list(x)
 *             elif PyDict_CheckExact(x):
 *                 self._encode_dict(x)             # <<<<<<<<<<<<<<
 *             elif PyBool_Check(x):
 *                 self._encode_int(int(x))
 */
      __pyx_t_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 (unlikely(__pyx_t_4 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L7;}
      goto __pyx_L9;
    }

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":386
 *             elif PyDict_CheckExact(x):
 *                 self._encode_dict(x)
 *             elif PyBool_Check(x):             # <<<<<<<<<<<<<<
 *                 self._encode_int(int(x))
 *             elif isinstance(x, Bencached):
 */
    __pyx_t_4 = PyBool_Check(__pyx_v_x);
    if (__pyx_t_4) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":387
 *                 self._encode_dict(x)
 *             elif PyBool_Check(x):
 *                 self._encode_int(int(x))             # <<<<<<<<<<<<<<
 *             elif isinstance(x, Bencached):
 *                 self._append_string(x.bencoded)
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_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_t_4); if (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L7;}
      goto __pyx_L9;
    }

    /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":388
 *             elif PyBool_Check(x):
 *                 self._encode_int(int(x))
 *             elif isinstance(x, Bencached):             # <<<<<<<<<<<<<<
 *                 self._append_string(x.bencoded)
 *             else:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__Bencached); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L7;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyObject_IsInstance(__pyx_v_x, __pyx_t_2); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L7;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_7) {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":389
 *                 self._encode_int(int(x))
 *             elif isinstance(x, Bencached):
 *                 self._append_string(x.bencoded)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise TypeError('unsupported type %r' % x)
 */
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__bencoded); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_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_t_2); if (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L9;
    }
    /*else*/ {

      /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":391
 *                 self._append_string(x.bencoded)
 *             else:
 *                 raise TypeError('unsupported type %r' % x)             # <<<<<<<<<<<<<<
 *         finally:
 *             Py_LeaveRecursiveCall()
 */
      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), __pyx_v_x); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L7;}
    }
    __pyx_L9:;
  }

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":393
 *                 raise TypeError('unsupported type %r' % x)
 *         finally:
 *             Py_LeaveRecursiveCall()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L8;
    __pyx_L7: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L8;
    }
    __pyx_L8:;
    Py_LeaveRecursiveCall();
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__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_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.Encoder.process");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":396
 * 
 * 
 * def bencode(x):             # <<<<<<<<<<<<<<
 *     """Encode Python object x to string"""
 *     encoder = Encoder()
 */

static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_bencode(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
static char __pyx_doc_6bzrlib_12_bencode_pyx_bencode[] = "Encode Python object x to string";
static PyObject *__pyx_pf_6bzrlib_12_bencode_pyx_bencode(PyObject *__pyx_self, PyObject *__pyx_v_x) {
  struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *__pyx_v_encoder;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("bencode");
  __pyx_self = __pyx_self;
  __pyx_v_encoder = ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)Py_None); __Pyx_INCREF(Py_None);

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":398
 * def bencode(x):
 *     """Encode Python object x to string"""
 *     encoder = Encoder()             # <<<<<<<<<<<<<<
 *     encoder.process(x)
 *     return str(encoder)
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_12_bencode_pyx_Encoder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_v_encoder));
  __pyx_v_encoder = ((struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":399
 *     """Encode Python object x to string"""
 *     encoder = Encoder()
 *     encoder.process(x)             # <<<<<<<<<<<<<<
 *     return str(encoder)
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_encoder), __pyx_n_s__process); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_x);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_x);
  __Pyx_GIVEREF(__pyx_v_x);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":400
 *     encoder = Encoder()
 *     encoder.process(x)
 *     return str(encoder)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_encoder));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_encoder));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_encoder));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._bencode_pyx.bencode");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_encoder);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  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);
  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);
  (*Py_TYPE(o)->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* tmp;
  tmp = ((PyObject*)p->text);
  p->text = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6bzrlib_12_bencode_pyx_7Decoder_tail(PyObject *o, void *x) {
  return __pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_4tail___get__(o);
}

static PyObject *__pyx_getprop_6bzrlib_12_bencode_pyx_7Decoder_size(PyObject *o, void *x) {
  return __pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_4size___get__(o);
}

static PyObject *__pyx_getprop_6bzrlib_12_bencode_pyx_7Decoder__yield_tuples(PyObject *o, void *x) {
  return __pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_13_yield_tuples___get__(o);
}

static PyMethodDef __pyx_methods_6bzrlib_12_bencode_pyx_Decoder[] = {
  {__Pyx_NAMESTR("decode"), (PyCFunction)__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_decode, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("decode_object"), (PyCFunction)__pyx_pf_6bzrlib_12_bencode_pyx_7Decoder_decode_object, METH_NOARGS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6bzrlib_12_bencode_pyx_Decoder[] = {
  {(char *)"tail", __pyx_getprop_6bzrlib_12_bencode_pyx_7Decoder_tail, 0, 0, 0},
  {(char *)"size", __pyx_getprop_6bzrlib_12_bencode_pyx_7Decoder_size, 0, 0, 0},
  {(char *)"_yield_tuples", __pyx_getprop_6bzrlib_12_bencode_pyx_7Decoder__yield_tuples, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Decoder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  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*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  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_VERSION_HEX >= 0x02050000
  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 = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6bzrlib_12_bencode_pyx_Decoder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("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*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  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_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("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*/
  0, /*tp_members*/
  __pyx_getsets_6bzrlib_12_bencode_pyx_Decoder, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_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*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
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);
  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);
    ++Py_REFCNT(o);
    __pyx_pf_6bzrlib_12_bencode_pyx_7Encoder___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyObject *__pyx_getprop_6bzrlib_12_bencode_pyx_7Encoder_tail(PyObject *o, void *x) {
  return __pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_4tail___get__(o);
}

static PyObject *__pyx_getprop_6bzrlib_12_bencode_pyx_7Encoder_size(PyObject *o, void *x) {
  return __pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_4size___get__(o);
}

static PyObject *__pyx_getprop_6bzrlib_12_bencode_pyx_7Encoder_buffer(PyObject *o, void *x) {
  return __pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_6buffer___get__(o);
}

static PyObject *__pyx_getprop_6bzrlib_12_bencode_pyx_7Encoder_maxsize(PyObject *o, void *x) {
  return __pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_7maxsize___get__(o);
}

static PyMethodDef __pyx_methods_6bzrlib_12_bencode_pyx_Encoder[] = {
  {__Pyx_NAMESTR("process"), (PyCFunction)__pyx_pf_6bzrlib_12_bencode_pyx_7Encoder_process, METH_O, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6bzrlib_12_bencode_pyx_Encoder[] = {
  {(char *)"tail", __pyx_getprop_6bzrlib_12_bencode_pyx_7Encoder_tail, 0, 0, 0},
  {(char *)"size", __pyx_getprop_6bzrlib_12_bencode_pyx_7Encoder_size, 0, 0, 0},
  {(char *)"buffer", __pyx_getprop_6bzrlib_12_bencode_pyx_7Encoder_buffer, 0, 0, 0},
  {(char *)"maxsize", __pyx_getprop_6bzrlib_12_bencode_pyx_7Encoder_maxsize, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Encoder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  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*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  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_VERSION_HEX >= 0x02050000
  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 = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6bzrlib_12_bencode_pyx_Encoder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("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*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  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_pf_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|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  __Pyx_DOCSTR("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*/
  0, /*tp_members*/
  __pyx_getsets_6bzrlib_12_bencode_pyx_Encoder, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_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*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {__Pyx_NAMESTR("bdecode"), (PyCFunction)__pyx_pf_6bzrlib_12_bencode_pyx_bdecode, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_12_bencode_pyx_bdecode)},
  {__Pyx_NAMESTR("bdecode_as_tuple"), (PyCFunction)__pyx_pf_6bzrlib_12_bencode_pyx_bdecode_as_tuple, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_12_bencode_pyx_bdecode_as_tuple)},
  {__Pyx_NAMESTR("bencode"), (PyCFunction)__pyx_pf_6bzrlib_12_bencode_pyx_bencode, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_12_bencode_pyx_bencode)},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("_bencode_pyx"),
    __Pyx_DOCSTR(__pyx_k_24), /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
  {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
  {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
  {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
  {&__pyx_kp_u_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 1, 0, 0},
  {&__pyx_kp_u_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 1, 0, 0},
  {&__pyx_kp_u_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 1, 0, 0},
  {&__pyx_kp_u_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 1, 0, 0},
  {&__pyx_kp_u_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 1, 0, 0},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  {&__pyx_n_s__Bencached, __pyx_k__Bencached, sizeof(__pyx_k__Bencached), 0, 0, 1, 1},
  {&__pyx_n_s__Decoder, __pyx_k__Decoder, sizeof(__pyx_k__Decoder), 0, 0, 1, 1},
  {&__pyx_n_s__Encoder, __pyx_k__Encoder, sizeof(__pyx_k__Encoder), 0, 0, 1, 1},
  {&__pyx_n_s__MemoryError, __pyx_k__MemoryError, sizeof(__pyx_k__MemoryError), 0, 0, 1, 1},
  {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____slots__, __pyx_k____slots__, sizeof(__pyx_k____slots__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___append_string, __pyx_k___append_string, sizeof(__pyx_k___append_string), 0, 0, 1, 1},
  {&__pyx_n_s___decode_dict, __pyx_k___decode_dict, sizeof(__pyx_k___decode_dict), 0, 0, 1, 1},
  {&__pyx_n_s___decode_int, __pyx_k___decode_int, sizeof(__pyx_k___decode_int), 0, 0, 1, 1},
  {&__pyx_n_s___decode_list, __pyx_k___decode_list, sizeof(__pyx_k___decode_list), 0, 0, 1, 1},
  {&__pyx_n_s___decode_object, __pyx_k___decode_object, sizeof(__pyx_k___decode_object), 0, 0, 1, 1},
  {&__pyx_n_s___decode_string, __pyx_k___decode_string, sizeof(__pyx_k___decode_string), 0, 0, 1, 1},
  {&__pyx_n_s___encode_dict, __pyx_k___encode_dict, sizeof(__pyx_k___encode_dict), 0, 0, 1, 1},
  {&__pyx_n_s___encode_int, __pyx_k___encode_int, sizeof(__pyx_k___encode_int), 0, 0, 1, 1},
  {&__pyx_n_s___encode_list, __pyx_k___encode_list, sizeof(__pyx_k___encode_list), 0, 0, 1, 1},
  {&__pyx_n_s___encode_long, __pyx_k___encode_long, sizeof(__pyx_k___encode_long), 0, 0, 1, 1},
  {&__pyx_n_s___encode_string, __pyx_k___encode_string, sizeof(__pyx_k___encode_string), 0, 0, 1, 1},
  {&__pyx_n_s___ensure_buffer, __pyx_k___ensure_buffer, sizeof(__pyx_k___ensure_buffer), 0, 0, 1, 1},
  {&__pyx_n_s___read_digits, __pyx_k___read_digits, sizeof(__pyx_k___read_digits), 0, 0, 1, 1},
  {&__pyx_n_s___yield_tuples, __pyx_k___yield_tuples, sizeof(__pyx_k___yield_tuples), 0, 0, 1, 1},
  {&__pyx_n_s__bdecode, __pyx_k__bdecode, sizeof(__pyx_k__bdecode), 0, 0, 1, 1},
  {&__pyx_n_s__bdecode_as_tuple, __pyx_k__bdecode_as_tuple, sizeof(__pyx_k__bdecode_as_tuple), 0, 0, 1, 1},
  {&__pyx_n_s__bencode, __pyx_k__bencode, sizeof(__pyx_k__bencode), 0, 0, 1, 1},
  {&__pyx_n_s__bencoded, __pyx_k__bencoded, sizeof(__pyx_k__bencoded), 0, 0, 1, 1},
  {&__pyx_n_s__buffer, __pyx_k__buffer, sizeof(__pyx_k__buffer), 0, 0, 1, 1},
  {&__pyx_n_s__decode, __pyx_k__decode, sizeof(__pyx_k__decode), 0, 0, 1, 1},
  {&__pyx_n_s__e, __pyx_k__e, sizeof(__pyx_k__e), 0, 0, 1, 1},
  {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1},
  {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
  {&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1},
  {&__pyx_n_s__maxsize, __pyx_k__maxsize, sizeof(__pyx_k__maxsize), 0, 0, 1, 1},
  {&__pyx_n_s__object, __pyx_k__object, sizeof(__pyx_k__object), 0, 0, 1, 1},
  {&__pyx_n_s__process, __pyx_k__process, sizeof(__pyx_k__process), 0, 0, 1, 1},
  {&__pyx_n_s__s, __pyx_k__s, sizeof(__pyx_k__s), 0, 0, 1, 1},
  {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
  {&__pyx_n_s__size, __pyx_k__size, sizeof(__pyx_k__size), 0, 0, 1, 1},
  {&__pyx_n_s__sort, __pyx_k__sort, sizeof(__pyx_k__sort), 0, 0, 1, 1},
  {&__pyx_n_s__tail, __pyx_k__tail, sizeof(__pyx_k__tail), 0, 0, 1, 1},
  {&__pyx_n_s__text, __pyx_k__text, sizeof(__pyx_k__text), 0, 0, 1, 1},
  {&__pyx_n_s__yield_tuples, __pyx_k__yield_tuples, sizeof(__pyx_k__yield_tuples), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_object = __Pyx_GetName(__pyx_b, __pyx_n_s__object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_MemoryError = __Pyx_GetName(__pyx_b, __pyx_n_s__MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_bencode_pyx(void); /*proto*/
PyMODINIT_FUNC init_bencode_pyx(void)
#else
PyMODINIT_FUNC PyInit__bencode_pyx(void); /*proto*/
PyMODINIT_FUNC PyInit__bencode_pyx(void)
#endif
{
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  #if CYTHON_REFNANNY
  void* __pyx_refnanny = NULL;
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit__bencode_pyx(void)", __LINE__, __FILE__);
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __pyx_binding_PyCFunctionType_USED
  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_bencode_pyx"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_24), 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_bzrlib___bencode_pyx) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_6bzrlib_12_bencode_pyx_Decoder = &__pyx_vtable_6bzrlib_12_bencode_pyx_Decoder;
  #if PY_MAJOR_VERSION >= 3
  __pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._decode_object = (PyObject *(*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_object;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._read_digits = (int (*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *, char))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__read_digits;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._decode_int = (PyObject *(*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_int;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._decode_string = (PyObject *(*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_string;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._decode_list = (PyObject *(*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_list;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Decoder._decode_dict = (PyObject *(*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Decoder *))__pyx_f_6bzrlib_12_bencode_pyx_7Decoder__decode_dict;
  #else
  *(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;
  #endif
  if (PyType_Ready(&__pyx_type_6bzrlib_12_bencode_pyx_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6bzrlib_12_bencode_pyx_Decoder, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_6bzrlib_12_bencode_pyx_7Decoder___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_6bzrlib_12_bencode_pyx_7Decoder___init__.doc = __pyx_doc_6bzrlib_12_bencode_pyx_7Decoder___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6bzrlib_12_bencode_pyx_7Decoder___init__;
    }
  }
  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; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Decoder", (PyObject *)&__pyx_type_6bzrlib_12_bencode_pyx_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __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;
  #if PY_MAJOR_VERSION >= 3
  __pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._ensure_buffer = (int (*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *, int))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__ensure_buffer;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._encode_int = (int (*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *, int))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_int;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._encode_long = (int (*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *, PyObject *))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_long;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._append_string = (int (*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *, PyObject *))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__append_string;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._encode_string = (int (*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *, PyObject *))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_string;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._encode_list = (int (*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *, PyObject *))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_list;
  __pyx_vtable_6bzrlib_12_bencode_pyx_Encoder._encode_dict = (int (*)(struct __pyx_obj_6bzrlib_12_bencode_pyx_Encoder *, PyObject *))__pyx_f_6bzrlib_12_bencode_pyx_7Encoder__encode_dict;
  #else
  *(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;
  #endif
  if (PyType_Ready(&__pyx_type_6bzrlib_12_bencode_pyx_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6bzrlib_12_bencode_pyx_Encoder, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_6bzrlib_12_bencode_pyx_7Encoder___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_6bzrlib_12_bencode_pyx_7Encoder___init__.doc = __pyx_doc_6bzrlib_12_bencode_pyx_7Encoder___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6bzrlib_12_bencode_pyx_7Encoder___init__;
    }
  }
  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; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Encoder", (PyObject *)&__pyx_type_6bzrlib_12_bencode_pyx_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6bzrlib_12_bencode_pyx_Encoder = &__pyx_type_6bzrlib_12_bencode_pyx_Encoder;
  /*--- Type import code ---*/
  __pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple = __Pyx_ImportType("bzrlib._static_tuple_c", "StaticTuple", sizeof(StaticTuple), 0); if (unlikely(!__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":66
 *     import_static_tuple_c
 * 
 * import_static_tuple_c()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = import_static_tuple_c(); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":233
 * 
 * 
 * class Bencached(object):             # <<<<<<<<<<<<<<
 *     __slots__ = ['bencoded']
 * 
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  __pyx_t_4 = __Pyx_CreateClass(__pyx_t_3, ((PyObject *)__pyx_t_2), __pyx_n_s__Bencached, "bzrlib._bencode_pyx"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":234
 * 
 * class Bencached(object):
 *     __slots__ = ['bencoded']             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, s):
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__bencoded));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__bencoded));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bencoded));
  if (PyObject_SetAttr(__pyx_t_4, __pyx_n_s____slots__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":236
 *     __slots__ = ['bencoded']
 * 
 *     def __init__(self, s):             # <<<<<<<<<<<<<<
 *         self.bencoded = s
 * 
 */
  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_6bzrlib_12_bencode_pyx_9Bencached___init__, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyMethod_New(__pyx_t_3, 0, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_t_4, __pyx_n_s____init__, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Bencached, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":253
 *     cdef readonly int maxsize
 * 
 *     def __init__(self, int maxsize=INITSIZE):             # <<<<<<<<<<<<<<
 *         """Initialize encoder engine
 *         @param  maxsize:    initial size of internal char buffer
 */
  __pyx_k_15 = __pyx_e_6bzrlib_12_bencode_pyx_INITSIZE;

  /* "/home/vila/src/bzr/integration/2.4.2-dev/bzrlib/_bencode_pyx.pyx":1
 * # Copyright (C) 2007, 2009, 2010 Canonical Ltd             # <<<<<<<<<<<<<<
 * #
 * # This program is free software; you can redistribute it and/or modify
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Decoder); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____init__); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_5, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_25), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__bdecode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_26), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_GetAttr(__pyx_m, __pyx_n_s__bdecode_as_tuple); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_5, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_27), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Encoder); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____init__); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_5, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_28), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__bencode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_29), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  if (__pyx_m) {
    __Pyx_AddTraceback("init bzrlib._bencode_pyx");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init bzrlib._bencode_pyx");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */

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 void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *number, *more_or_less;

    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, num_found);
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;

    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();

    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;

    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}


static PyObject *__Pyx_CreateClass(
    PyObject *bases, PyObject *dict, PyObject *name, const char *modname)
{
    PyObject *py_modname;
    PyObject *result = 0;

    #if PY_MAJOR_VERSION < 3
    py_modname = PyString_FromString(modname);
    #else
    py_modname = PyUnicode_FromString(modname);
    #endif
    if (!py_modname)
        goto bad;
    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    result = PyClass_New(bases, dict, name);
    #else
    result = PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, name, bases, dict, NULL);
    #endif
bad:
    Py_XDECREF(py_modname);
    return result;
}

#if PY_MAJOR_VERSION < 3
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 {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(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
    }

    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

#else /* Python 3+ */

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;

    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (!PyExceptionClass_Check(type)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }

    PyErr_SetObject(type, value);

    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }

bad:
    return;
}
#endif

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    long size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];

    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(class_name);
    #else
    py_name = PyUnicode_FromString(class_name);
    #endif
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    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 (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning), 
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        PyErr_Warn(NULL, warning);
        #else
        PyErr_WarnEx(NULL, warning, 0);
        #endif
    }
    else if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError, 
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

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

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*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(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
