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

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


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

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

static char __pyx_mdoc[] = "Pyrex implementation of _read_stanza_*.";

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

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

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

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

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

/* Declarations from bzrlib._rio_pyx */


/* Declarations from implementation of bzrlib._rio_pyx */

static int __pyx_f_6bzrlib_8_rio_pyx__valid_tag_char(char); /*proto*/
static PyObject *__pyx_f_6bzrlib_8_rio_pyx__split_first_line_utf8(char *,int,char *,Py_ssize_t *); /*proto*/
static PyObject *__pyx_f_6bzrlib_8_rio_pyx__split_first_line_unicode(Py_UNICODE *,int,Py_UNICODE *,Py_ssize_t *); /*proto*/

static char __pyx_k1[] = "invalid tag in line %r";
static char __pyx_k2[] = "tag/value separator not found in line %r";
static char __pyx_k3[] = "strict";
static char __pyx_k4[] = "%r is not a plain string";
static char __pyx_k5[] = "invalid continuation line %r";
static char __pyx_k6[] = "_valid_tag";
static char __pyx_k7[] = "invalid rio tag %r";
static char __pyx_k8[] = "Stanza";
static char __pyx_k9[] = "from_pairs";
static char __pyx_k10[] = "%r is not a unicode string";
static char __pyx_k11[] = "bzrlib.rio";

static PyObject *__pyx_n_Stanza;
static PyObject *__pyx_n__valid_tag;
static PyObject *__pyx_n_from_pairs;

static PyObject *__pyx_k1p;
static PyObject *__pyx_k2p;
static PyObject *__pyx_k4p;
static PyObject *__pyx_k5p;
static PyObject *__pyx_k7p;
static PyObject *__pyx_k10p;
static PyObject *__pyx_k11p;

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_Stanza, 1, __pyx_k8, sizeof(__pyx_k8)},
  {&__pyx_n__valid_tag, 1, __pyx_k6, sizeof(__pyx_k6)},
  {&__pyx_n_from_pairs, 1, __pyx_k9, sizeof(__pyx_k9)},
  {&__pyx_k1p, 0, __pyx_k1, sizeof(__pyx_k1)},
  {&__pyx_k2p, 0, __pyx_k2, sizeof(__pyx_k2)},
  {&__pyx_k4p, 0, __pyx_k4, sizeof(__pyx_k4)},
  {&__pyx_k5p, 0, __pyx_k5, sizeof(__pyx_k5)},
  {&__pyx_k7p, 0, __pyx_k7, sizeof(__pyx_k7)},
  {&__pyx_k10p, 0, __pyx_k10, sizeof(__pyx_k10)},
  {&__pyx_k11p, 0, __pyx_k11, sizeof(__pyx_k11)},
  {0, 0, 0, 0}
};



/* Implementation of bzrlib._rio_pyx */

static int __pyx_f_6bzrlib_8_rio_pyx__valid_tag_char(char __pyx_v_c) {
  int __pyx_r;
  int __pyx_1;
  __pyx_1 = (__pyx_v_c == '_');
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_c == '-');
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_c >= 'a');
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_c <= 'z');
      }
      if (!__pyx_1) {
        __pyx_1 = (__pyx_v_c >= 'A');
        if (__pyx_1) {
          __pyx_1 = (__pyx_v_c <= 'Z');
        }
        if (!__pyx_1) {
          __pyx_1 = (__pyx_v_c >= '0');
          if (__pyx_1) {
            __pyx_1 = (__pyx_v_c <= '9');
          }
        }
      }
    }
  }
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_8_rio_pyx__valid_tag(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6bzrlib_8_rio_pyx__valid_tag(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  char *__pyx_v_c_tag;
  Py_ssize_t __pyx_v_c_len;
  int __pyx_v_i;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_ssize_t __pyx_4;
  static char *__pyx_argnames[] = {"tag",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_tag)) return 0;
  Py_INCREF(__pyx_v_tag);

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

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":65 */
  __pyx_v_c_tag = PyString_AS_STRING(__pyx_v_tag);

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

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":67 */
  __pyx_1 = (__pyx_v_c_len < 1);
  if (__pyx_1) {
    Py_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":69 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_c_len; ++__pyx_v_i) {
    __pyx_1 = (!__pyx_f_6bzrlib_8_rio_pyx__valid_tag_char((__pyx_v_c_tag[__pyx_v_i])));
    if (__pyx_1) {
      Py_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":72 */
  Py_INCREF(Py_True);
  __pyx_r = Py_True;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._rio_pyx._valid_tag");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_tag);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_8_rio_pyx__split_first_line_utf8(char *__pyx_v_line,int __pyx_v_len,char *__pyx_v_value,Py_ssize_t *__pyx_v_value_len) {
  int __pyx_v_i;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":78 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_len; ++__pyx_v_i) {
    __pyx_1 = ((__pyx_v_line[__pyx_v_i]) == ':');
    if (__pyx_1) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":80 */
      __pyx_1 = ((__pyx_v_line[(__pyx_v_i + 1)]) != ' ');
      if (__pyx_1) {
        __pyx_2 = PyString_FromString(__pyx_v_line); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;}
        __pyx_3 = PyNumber_Remainder(__pyx_k1p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
        __pyx_3 = 0;
        __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __Pyx_Raise(__pyx_3, 0, 0);
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;}
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":82 */
      memcpy(__pyx_v_value,((__pyx_v_line + __pyx_v_i) + 2),((__pyx_v_len - __pyx_v_i) - 2));

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":83 */
      (__pyx_v_value_len[0]) = ((__pyx_v_len - __pyx_v_i) - 2);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":84 */
      __pyx_2 = PyString_FromStringAndSize(__pyx_v_line,__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":85 */
  __pyx_3 = PyString_FromString(__pyx_v_line); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;}
  __pyx_2 = PyNumber_Remainder(__pyx_k2p, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __Pyx_Raise(__pyx_2, 0, 0);
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._rio_pyx._split_first_line_utf8");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_8_rio_pyx__split_first_line_unicode(Py_UNICODE *__pyx_v_line,int __pyx_v_len,Py_UNICODE *__pyx_v_value,Py_ssize_t *__pyx_v_value_len) {
  int __pyx_v_i;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":91 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_len; ++__pyx_v_i) {
    __pyx_1 = ((__pyx_v_line[__pyx_v_i]) == ':');
    if (__pyx_1) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":93 */
      __pyx_1 = ((__pyx_v_line[(__pyx_v_i + 1)]) != ' ');
      if (__pyx_1) {
        __pyx_2 = PyUnicode_FromUnicode(__pyx_v_line,__pyx_v_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;}
        __pyx_3 = PyNumber_Remainder(__pyx_k1p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
        __pyx_3 = 0;
        __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __Pyx_Raise(__pyx_3, 0, 0);
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;}
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":96 */
      memcpy(__pyx_v_value,(&(__pyx_v_line[(__pyx_v_i + 2)])),(((__pyx_v_len - __pyx_v_i) - 2) * (sizeof(Py_UNICODE))));

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":97 */
      (__pyx_v_value_len[0]) = ((__pyx_v_len - __pyx_v_i) - 2);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":98 */
      __pyx_2 = PyUnicode_EncodeASCII(__pyx_v_line,__pyx_v_i,__pyx_k3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":99 */
  __pyx_3 = PyUnicode_FromUnicode(__pyx_v_line,__pyx_v_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;}
  __pyx_2 = PyNumber_Remainder(__pyx_k2p, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __Pyx_Raise(__pyx_2, 0, 0);
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; goto __pyx_L1;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._rio_pyx._split_first_line_unicode");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_8_rio_pyx__read_stanza_utf8(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6bzrlib_8_rio_pyx__read_stanza_utf8(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_line_iter = 0;
  char *__pyx_v_c_line;
  Py_ssize_t __pyx_v_c_len;
  char *__pyx_v_accum_value;
  char *__pyx_v_new_accum_value;
  Py_ssize_t __pyx_v_accum_len;
  Py_ssize_t __pyx_v_accum_size;
  PyObject *__pyx_v_pairs;
  PyObject *__pyx_v_tag;
  PyObject *__pyx_v_line;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  static char *__pyx_argnames[] = {"line_iter",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_line_iter)) return 0;
  Py_INCREF(__pyx_v_line_iter);
  __pyx_v_pairs = Py_None; Py_INCREF(Py_None);
  __pyx_v_tag = Py_None; Py_INCREF(Py_None);
  __pyx_v_line = Py_None; Py_INCREF(Py_None);

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

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":109 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_tag);
  __pyx_v_tag = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":110 */
  __pyx_v_accum_len = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":111 */
  __pyx_v_accum_size = 4096;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":112 */
  __pyx_v_accum_value = ((char *)malloc(__pyx_v_accum_size));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":113 */
  __pyx_2 = (__pyx_v_accum_value == NULL);
  if (__pyx_2) {
    __Pyx_Raise(PyExc_MemoryError, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

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

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":116 */
    __pyx_1 = PyObject_GetIter(__pyx_v_line_iter); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L4;}
    for (;;) {
      __pyx_3 = PyIter_Next(__pyx_1);
      if (!__pyx_3) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L4;}
        break;
      }
      Py_DECREF(__pyx_v_line);
      __pyx_v_line = __pyx_3;
      __pyx_3 = 0;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":117 */
      __pyx_2 = __pyx_v_line == Py_None;
      if (__pyx_2) {
        goto __pyx_L7;
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":119 */
      __pyx_2 = (!PyString_CheckExact(__pyx_v_line));
      if (__pyx_2) {
        __pyx_3 = PyNumber_Remainder(__pyx_k4p, __pyx_v_line); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L4;}
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L4;}
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
        __pyx_3 = 0;
        __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L4;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __Pyx_Raise(__pyx_3, 0, 0);
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L4;}
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":121 */
      __pyx_v_c_line = PyString_AS_STRING(__pyx_v_line);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":122 */
      __pyx_5 = PyString_GET_SIZE(__pyx_v_line); if (__pyx_5 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L4;}
      __pyx_v_c_len = __pyx_5;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":123 */
      __pyx_2 = (__pyx_v_c_len < 1);
      if (__pyx_2) {
        goto __pyx_L7;
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":125 */
      __pyx_2 = (__pyx_v_c_len == 1);
      if (__pyx_2) {
        __pyx_2 = ((__pyx_v_c_line[0]) == '\n');
      }
      if (__pyx_2) {
        goto __pyx_L7;
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":127 */
      __pyx_2 = ((__pyx_v_accum_len + __pyx_v_c_len) > __pyx_v_accum_size);
      if (__pyx_2) {

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":128 */
        __pyx_v_accum_size = (__pyx_v_accum_len + __pyx_v_c_len);

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":129 */
        __pyx_v_new_accum_value = ((char *)realloc(__pyx_v_accum_value,__pyx_v_accum_size));

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":130 */
        __pyx_2 = (__pyx_v_new_accum_value == NULL);
        if (__pyx_2) {
          __Pyx_Raise(PyExc_MemoryError, 0, 0);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L4;}
          goto __pyx_L13;
        }
        /*else*/ {
          __pyx_v_accum_value = __pyx_v_new_accum_value;
        }
        __pyx_L13:;
        goto __pyx_L12;
      }
      __pyx_L12:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":134 */
      __pyx_2 = ((__pyx_v_c_line[0]) == '\t');
      if (__pyx_2) {

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":135 */
        __pyx_2 = __pyx_v_tag == Py_None;
        if (__pyx_2) {
          __pyx_4 = PyNumber_Remainder(__pyx_k5p, __pyx_v_line); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; goto __pyx_L4;}
          __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; goto __pyx_L4;}
          PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
          __pyx_4 = 0;
          __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; goto __pyx_L4;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          __Pyx_Raise(__pyx_4, 0, 0);
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; goto __pyx_L4;}
          goto __pyx_L15;
        }
        __pyx_L15:;

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":137 */
        memcpy((__pyx_v_accum_value + __pyx_v_accum_len),(__pyx_v_c_line + 1),(__pyx_v_c_len - 1));

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":138 */
        __pyx_v_accum_len = ((__pyx_v_accum_len + __pyx_v_c_len) - 1);
        goto __pyx_L14;
      }
      /*else*/ {

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":140 */
        __pyx_2 = __pyx_v_tag != Py_None;
        if (__pyx_2) {
          __pyx_3 = PyUnicode_DecodeUTF8(__pyx_v_accum_value,(__pyx_v_accum_len - 1),__pyx_k3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L4;}
          __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L4;}
          Py_INCREF(__pyx_v_tag);
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_tag);
          PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
          __pyx_3 = 0;
          __pyx_2 = PyList_Append(__pyx_v_pairs,__pyx_4); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L4;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          goto __pyx_L16;
        }
        __pyx_L16:;

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":144 */
        __pyx_3 = __pyx_f_6bzrlib_8_rio_pyx__split_first_line_utf8(__pyx_v_c_line,__pyx_v_c_len,__pyx_v_accum_value,(&__pyx_v_accum_len)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L4;}
        Py_DECREF(__pyx_v_tag);
        __pyx_v_tag = __pyx_3;
        __pyx_3 = 0;

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":146 */
        __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__valid_tag); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; goto __pyx_L4;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; goto __pyx_L4;}
        Py_INCREF(__pyx_v_tag);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_tag);
        __pyx_6 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; goto __pyx_L4;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_2 = PyObject_IsTrue(__pyx_6); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; goto __pyx_L4;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        __pyx_7 = (!__pyx_2);
        if (__pyx_7) {
          __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L4;}
          Py_INCREF(__pyx_v_tag);
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_tag);
          __pyx_3 = PyNumber_Remainder(__pyx_k7p, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L4;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L4;}
          PyTuple_SET_ITEM(__pyx_6, 0, __pyx_3);
          __pyx_3 = 0;
          __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L4;}
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          __Pyx_Raise(__pyx_4, 0, 0);
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L4;}
          goto __pyx_L17;
        }
        __pyx_L17:;
      }
      __pyx_L14:;
    }
    __pyx_L7:;
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":148 */
    __pyx_2 = __pyx_v_tag != Py_None;
    if (__pyx_2) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":149 */
      __pyx_3 = PyUnicode_DecodeUTF8(__pyx_v_accum_value,(__pyx_v_accum_len - 1),__pyx_k3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L4;}
      __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L4;}
      Py_INCREF(__pyx_v_tag);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_tag);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
      __pyx_3 = 0;
      __pyx_7 = PyList_Append(__pyx_v_pairs,__pyx_6); if (__pyx_7 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; goto __pyx_L4;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":151 */
      __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_Stanza); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L4;}
      __pyx_1 = PyObject_GetAttr(__pyx_4, __pyx_n_from_pairs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L4;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L4;}
      Py_INCREF(__pyx_v_pairs);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_pairs);
      __pyx_6 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L4;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_r = __pyx_6;
      __pyx_6 = 0;
      goto __pyx_L3;
      goto __pyx_L18;
    }
    /*else*/ {
      Py_INCREF(Py_None);
      __pyx_r = Py_None;
      goto __pyx_L3;
    }
    __pyx_L18:;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L3: __pyx_why = 3; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_4); __pyx_4 = 0;
      Py_XDECREF(__pyx_1); __pyx_1 = 0;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      Py_XDECREF(__pyx_6); __pyx_6 = 0;
      PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;
    free(__pyx_v_accum_value);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1;
      }
    }
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("bzrlib._rio_pyx._read_stanza_utf8");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pairs);
  Py_DECREF(__pyx_v_tag);
  Py_DECREF(__pyx_v_line);
  Py_DECREF(__pyx_v_line_iter);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_8_rio_pyx__read_stanza_unicode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6bzrlib_8_rio_pyx__read_stanza_unicode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_unicode_iter = 0;
  Py_UNICODE *__pyx_v_c_line;
  int __pyx_v_c_len;
  Py_UNICODE *__pyx_v_accum_value;
  Py_UNICODE *__pyx_v_new_accum_value;
  Py_ssize_t __pyx_v_accum_len;
  Py_ssize_t __pyx_v_accum_size;
  PyObject *__pyx_v_pairs;
  PyObject *__pyx_v_tag;
  PyObject *__pyx_v_line;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  static char *__pyx_argnames[] = {"unicode_iter",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_unicode_iter)) return 0;
  Py_INCREF(__pyx_v_unicode_iter);
  __pyx_v_pairs = Py_None; Py_INCREF(Py_None);
  __pyx_v_tag = Py_None; Py_INCREF(Py_None);
  __pyx_v_line = Py_None; Py_INCREF(Py_None);

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

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":164 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_tag);
  __pyx_v_tag = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":165 */
  __pyx_v_accum_len = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":166 */
  __pyx_v_accum_size = 4096;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":167 */
  __pyx_v_accum_value = ((Py_UNICODE *)malloc((__pyx_v_accum_size * (sizeof(Py_UNICODE)))));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":168 */
  __pyx_2 = (__pyx_v_accum_value == NULL);
  if (__pyx_2) {
    __Pyx_Raise(PyExc_MemoryError, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

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

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":171 */
    __pyx_1 = PyObject_GetIter(__pyx_v_unicode_iter); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L4;}
    for (;;) {
      __pyx_3 = PyIter_Next(__pyx_1);
      if (!__pyx_3) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L4;}
        break;
      }
      Py_DECREF(__pyx_v_line);
      __pyx_v_line = __pyx_3;
      __pyx_3 = 0;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":172 */
      __pyx_2 = __pyx_v_line == Py_None;
      if (__pyx_2) {
        goto __pyx_L7;
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":174 */
      __pyx_2 = (!PyUnicode_CheckExact(__pyx_v_line));
      if (__pyx_2) {
        __pyx_3 = PyNumber_Remainder(__pyx_k10p, __pyx_v_line); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L4;}
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L4;}
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
        __pyx_3 = 0;
        __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L4;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __Pyx_Raise(__pyx_3, 0, 0);
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L4;}
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":176 */
      __pyx_v_c_line = PyUnicode_AS_UNICODE(__pyx_v_line);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":177 */
      __pyx_5 = PyUnicode_GET_SIZE(__pyx_v_line); if (__pyx_5 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L4;}
      __pyx_v_c_len = __pyx_5;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":178 */
      __pyx_2 = (__pyx_v_c_len < 1);
      if (__pyx_2) {
        goto __pyx_L7;
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":180 */
      __pyx_2 = Py_UNICODE_ISLINEBREAK((__pyx_v_c_line[0]));
      if (__pyx_2) {
        goto __pyx_L7;
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":182 */
      __pyx_2 = ((__pyx_v_accum_len + __pyx_v_c_len) > __pyx_v_accum_size);
      if (__pyx_2) {

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":183 */
        __pyx_v_accum_size = (__pyx_v_accum_len + __pyx_v_c_len);

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":184 */
        __pyx_v_new_accum_value = ((Py_UNICODE *)realloc(__pyx_v_accum_value,(__pyx_v_accum_size * (sizeof(Py_UNICODE)))));

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":186 */
        __pyx_2 = (__pyx_v_new_accum_value == NULL);
        if (__pyx_2) {
          __Pyx_Raise(PyExc_MemoryError, 0, 0);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L4;}
          goto __pyx_L13;
        }
        /*else*/ {
          __pyx_v_accum_value = __pyx_v_new_accum_value;
        }
        __pyx_L13:;
        goto __pyx_L12;
      }
      __pyx_L12:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":190 */
      __pyx_2 = ((__pyx_v_c_line[0]) == '\t');
      if (__pyx_2) {

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":191 */
        __pyx_2 = __pyx_v_tag == Py_None;
        if (__pyx_2) {
          __pyx_4 = PyNumber_Remainder(__pyx_k5p, __pyx_v_line); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; goto __pyx_L4;}
          __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; goto __pyx_L4;}
          PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
          __pyx_4 = 0;
          __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; goto __pyx_L4;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          __Pyx_Raise(__pyx_4, 0, 0);
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; goto __pyx_L4;}
          goto __pyx_L15;
        }
        __pyx_L15:;

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":193 */
        memcpy((&(__pyx_v_accum_value[__pyx_v_accum_len])),(&(__pyx_v_c_line[1])),((__pyx_v_c_len - 1) * (sizeof(Py_UNICODE))));

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":195 */
        __pyx_v_accum_len = (__pyx_v_accum_len + (__pyx_v_c_len - 1));
        goto __pyx_L14;
      }
      /*else*/ {

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":197 */
        __pyx_2 = __pyx_v_tag != Py_None;
        if (__pyx_2) {
          __pyx_3 = PyUnicode_FromUnicode(__pyx_v_accum_value,(__pyx_v_accum_len - 1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; goto __pyx_L4;}
          __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; goto __pyx_L4;}
          Py_INCREF(__pyx_v_tag);
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_tag);
          PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
          __pyx_3 = 0;
          __pyx_2 = PyList_Append(__pyx_v_pairs,__pyx_4); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L4;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          goto __pyx_L16;
        }
        __pyx_L16:;

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":200 */
        __pyx_3 = __pyx_f_6bzrlib_8_rio_pyx__split_first_line_unicode(__pyx_v_c_line,__pyx_v_c_len,__pyx_v_accum_value,(&__pyx_v_accum_len)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; goto __pyx_L4;}
        Py_DECREF(__pyx_v_tag);
        __pyx_v_tag = __pyx_3;
        __pyx_3 = 0;

        /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":202 */
        __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__valid_tag); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L4;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L4;}
        Py_INCREF(__pyx_v_tag);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_tag);
        __pyx_6 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L4;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_2 = PyObject_IsTrue(__pyx_6); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L4;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        __pyx_7 = (!__pyx_2);
        if (__pyx_7) {
          __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L4;}
          Py_INCREF(__pyx_v_tag);
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_tag);
          __pyx_3 = PyNumber_Remainder(__pyx_k7p, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L4;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L4;}
          PyTuple_SET_ITEM(__pyx_6, 0, __pyx_3);
          __pyx_3 = 0;
          __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L4;}
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          __Pyx_Raise(__pyx_4, 0, 0);
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L4;}
          goto __pyx_L17;
        }
        __pyx_L17:;
      }
      __pyx_L14:;
    }
    __pyx_L7:;
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":204 */
    __pyx_2 = __pyx_v_tag != Py_None;
    if (__pyx_2) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":205 */
      __pyx_3 = PyUnicode_FromUnicode(__pyx_v_accum_value,(__pyx_v_accum_len - 1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L4;}
      __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L4;}
      Py_INCREF(__pyx_v_tag);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_tag);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
      __pyx_3 = 0;
      __pyx_7 = PyList_Append(__pyx_v_pairs,__pyx_6); if (__pyx_7 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L4;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":207 */
      __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_Stanza); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L4;}
      __pyx_1 = PyObject_GetAttr(__pyx_4, __pyx_n_from_pairs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L4;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L4;}
      Py_INCREF(__pyx_v_pairs);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_pairs);
      __pyx_6 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L4;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_r = __pyx_6;
      __pyx_6 = 0;
      goto __pyx_L3;
      goto __pyx_L18;
    }
    /*else*/ {
      Py_INCREF(Py_None);
      __pyx_r = Py_None;
      goto __pyx_L3;
    }
    __pyx_L18:;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L3: __pyx_why = 3; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_4); __pyx_4 = 0;
      Py_XDECREF(__pyx_1); __pyx_1 = 0;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      Py_XDECREF(__pyx_6); __pyx_6 = 0;
      PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;
    free(__pyx_v_accum_value);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1;
      }
    }
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("bzrlib._rio_pyx._read_stanza_unicode");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pairs);
  Py_DECREF(__pyx_v_tag);
  Py_DECREF(__pyx_v_line);
  Py_DECREF(__pyx_v_unicode_iter);
  return __pyx_r;
}

static struct PyMethodDef __pyx_methods[] = {
  {"_valid_tag", (PyCFunction)__pyx_f_6bzrlib_8_rio_pyx__valid_tag, METH_VARARGS|METH_KEYWORDS, 0},
  {"_read_stanza_utf8", (PyCFunction)__pyx_f_6bzrlib_8_rio_pyx__read_stanza_utf8, METH_VARARGS|METH_KEYWORDS, 0},
  {"_read_stanza_unicode", (PyCFunction)__pyx_f_6bzrlib_8_rio_pyx__read_stanza_unicode, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

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

PyMODINIT_FUNC init_rio_pyx(void); /*proto*/
PyMODINIT_FUNC init_rio_pyx(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_rio_pyx", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":50 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
  Py_INCREF(__pyx_n_Stanza);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n_Stanza);
  __pyx_2 = __Pyx_Import(__pyx_k11p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_Stanza); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Stanza, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_rio_pyx.pyx":158 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("bzrlib._rio_pyx");
}

static char *__pyx_filenames[] = {
  "_rio_pyx.pyx",
};

/* Runtime support code */

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

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

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

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

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *__import__ = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
    if (!__import__)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunction(__import__, "OOOO",
        name, global_dict, empty_dict, list);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(__import__);
    Py_XDECREF(empty_dict);
    return module;
}

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

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