/* Generated by Cython 0.15.1 on Sun Mar  4 01:55:46 2012 */

#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)   __Pyx_PyInt_AsInt(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
#endif

#if PY_VERSION_HEX < 0x02060000
  #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

#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)

#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #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_VERSION_HEX < 0x03020000
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#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) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#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

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

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__osmium__core
#define __PYX_HAVE_API__osmium__core
#include <string>
#include "osmium.hpp"
#include "stdint.h"
#include "time.h"
#include "osmium/osm/types.hpp"
#include "osmium/osm/tag.hpp"
#include "osmium/osm/tag_list.hpp"
#include "ios"
#include "new"
#include "stdexcept"
#include "typeinfo"
#include "osmium/osm/position.hpp"
#include "osmium/osm/bounds.hpp"
#include "osmium/osm/meta.hpp"
#include "osmium/osm/object.hpp"
#include "osmium/osm/node.hpp"
#include "osmium/osm/way_node.hpp"
#include "osmium/osm/way_node_list.hpp"
#include "osmium/osm/way.hpp"
#include "osmium/osm/relation_member.hpp"
#include "osmium/osm/relation_member_list.hpp"
#include "osmium/osm/relation.hpp"
#include "osmium/osm/area.hpp"
#include "osmium/handler.hpp"
#include "osmium/handler/debug.hpp"
#include "osmium/handler/progress.hpp"
#include "osmium/output.hpp"
#include "osmium/osmfile.hpp"
#include "pyerrors.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* 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_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#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[] = {
  "core.pyx",
  "osm.pxd",
  "handler.pxd",
  "output.pxd",
};

/*--- Type declarations ---*/
struct __pyx_obj_6osmium_3osm_TagList;
struct __pyx_obj_6osmium_3osm_WayNodeList;
struct __pyx_obj_6osmium_3osm_Object;
struct __pyx_obj_6osmium_3osm_Node;
struct StopReading_struct;
struct osmhandler_struct;
struct __pyx_obj_6osmium_7handler_Tee;
struct __pyx_obj_6osmium_3osm_Meta;
struct __pyx_obj_6osmium_3osm_Relation;
struct __pyx_obj_6osmium_6output_Base;
struct __pyx_obj_6osmium_7handler_Debug;
struct __pyx_obj_6osmium_3osm_RelationMemberList;
struct __pyx_obj_6osmium_7handler_Forward;
struct __pyx_obj_6osmium_4core_OSMFile;
struct __pyx_obj_6osmium_3osm_Bounds;
struct __pyx_obj_6osmium_7handler_Progress;
struct __pyx_obj_6osmium_3osm_Way;

/* "osmium/core.pxd":6
 * from osmium cimport output
 * 
 * cdef enum FileType:             # <<<<<<<<<<<<<<
 *     C_TYPE_OSM,
 *     C_TYPE_HISTORY,
 */
enum __pyx_t_6osmium_4core_FileType {
  __pyx_e_6osmium_4core_C_TYPE_OSM,
  __pyx_e_6osmium_4core_C_TYPE_HISTORY,
  __pyx_e_6osmium_4core_C_TYPE_CHANGE,
  __pyx_e_6osmium_4core_C_TYPE_EXCEPTION
};

/* "osmium/core.pxd":11
 *     C_TYPE_CHANGE,
 *     C_TYPE_EXCEPTION
 * cdef enum FileEncoding:             # <<<<<<<<<<<<<<
 *     C_ENC_PBF,
 *     C_ENC_XML,
 */
enum __pyx_t_6osmium_4core_FileEncoding {
  __pyx_e_6osmium_4core_C_ENC_PBF,
  __pyx_e_6osmium_4core_C_ENC_XML,
  __pyx_e_6osmium_4core_C_ENC_XMLgz,
  __pyx_e_6osmium_4core_C_ENC_XMLbz2,
  __pyx_e_6osmium_4core_C_ENC_EXCEPTION
};

/* "osmium/osm.pxd":3
 * from c_osmium.osm cimport TagList as c_TagList, ObjectPtr, WayPtr, RelationPtr, Meta as c_Meta, Bounds as c_Bounds
 * 
 * cdef class TagList:             # <<<<<<<<<<<<<<
 *     cdef ObjectPtr *c_object
 * 
 */
struct __pyx_obj_6osmium_3osm_TagList {
  PyObject_HEAD
  shared_ptr<const Osmium::OSM::Object> *c_object;
};


/* "osmium/osm.pxd":6
 *     cdef ObjectPtr *c_object
 * 
 * cdef class WayNodeList:             # <<<<<<<<<<<<<<
 *     cdef WayPtr *c_way
 * 
 */
struct __pyx_obj_6osmium_3osm_WayNodeList {
  PyObject_HEAD
  shared_ptr<const Osmium::OSM::Way> *c_way;
};


/* "osmium/osm.pxd":12
 *     cdef RelationPtr *c_relation
 * 
 * cdef class Object:             # <<<<<<<<<<<<<<
 *     """Base class for OSM objects
 * 
 */
struct __pyx_obj_6osmium_3osm_Object {
  PyObject_HEAD
  shared_ptr<const Osmium::OSM::Object> *c_object;
};


/* "osmium/osm.pxd":19
 *     cdef ObjectPtr *c_object
 * 
 * cdef class Node(Object):             # <<<<<<<<<<<<<<
 *     """OSM Node object
 * 
 */
struct __pyx_obj_6osmium_3osm_Node {
  struct __pyx_obj_6osmium_3osm_Object __pyx_base;
};


/* "handler.pxd":11
 *         pass
 * 
 * cdef public class StopReading(Exception) [object StopReading_struct, type StopReading_type]:             # <<<<<<<<<<<<<<
 *     """raise this exception to immediately stop reading the input file
 *     """
 */
struct StopReading_struct {
  PyBaseExceptionObject __pyx_base;
};

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) StopReading_type;

/* "handler.pxd":16
 *     pass
 * 
 * cdef public class Base[object osmhandler_struct, type osmhandler_type]:             # <<<<<<<<<<<<<<
 *     """base class for python implemented handlers
 *     """
 */
struct osmhandler_struct {
  PyObject_HEAD
  struct __pyx_vtabstruct_6osmium_7handler_Base *__pyx_vtab;
  struct __pyx_obj_6osmium_3osm_Node *cur_node;
};

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) osmhandler_type;

/* "handler.pxd":42
 *     cpdef show_cursor(self)
 * 
 * cdef class Tee(Base):             # <<<<<<<<<<<<<<
 *     cdef public Base handler1
 *     cdef public Base handler2
 */
struct __pyx_obj_6osmium_7handler_Tee {
  struct osmhandler_struct __pyx_base;
  struct osmhandler_struct *handler1;
  struct osmhandler_struct *handler2;
};


/* "osmium/osm.pxd":40
 * 
 * 
 * cdef class Meta:             # <<<<<<<<<<<<<<
 *     """Meta information from the header of an OSM file.
 *     """
 */
struct __pyx_obj_6osmium_3osm_Meta {
  PyObject_HEAD
  struct __pyx_vtabstruct_6osmium_3osm_Meta *__pyx_vtab;
  Osmium::OSM::Meta *c_meta;
  struct __pyx_obj_6osmium_3osm_Bounds *bounds;
};


/* "osmium/osm.pxd":31
 *     pass
 * 
 * cdef class Relation(Object):             # <<<<<<<<<<<<<<
 *     """OSM Relation object
 *     """
 */
struct __pyx_obj_6osmium_3osm_Relation {
  struct __pyx_obj_6osmium_3osm_Object __pyx_base;
};


/* "output.pxd":6
 * from osmium cimport handler
 * 
 * cdef class Base(handler.Base):             # <<<<<<<<<<<<<<
 *     cdef c_Base* c_output
 */
struct __pyx_obj_6osmium_6output_Base {
  struct osmhandler_struct __pyx_base;
  Osmium::Output::Base *c_output;
};


/* "handler.pxd":34
 *     cpdef final(self)
 * 
 * cdef class Debug(Base):             # <<<<<<<<<<<<<<
 *     cdef c_Debug *c_handler
 * 
 */
struct __pyx_obj_6osmium_7handler_Debug {
  struct osmhandler_struct __pyx_base;
  Osmium::Handler::Debug *c_handler;
};


/* "osmium/osm.pxd":9
 *     cdef WayPtr *c_way
 * 
 * cdef class RelationMemberList:             # <<<<<<<<<<<<<<
 *     cdef RelationPtr *c_relation
 * 
 */
struct __pyx_obj_6osmium_3osm_RelationMemberList {
  PyObject_HEAD
  shared_ptr<const Osmium::OSM::Relation> *c_relation;
};


/* "handler.pxd":46
 *     cdef public Base handler2
 * 
 * cdef class Forward(Base):             # <<<<<<<<<<<<<<
 *     cdef public Base handler
 */
struct __pyx_obj_6osmium_7handler_Forward {
  struct osmhandler_struct __pyx_base;
  struct osmhandler_struct *handler;
};


/* "osmium/core.pxd":18
 *     C_ENC_EXCEPTION
 * 
 * cdef class OSMFile:             # <<<<<<<<<<<<<<
 *     u"""This class describes an OSM file in one of several formats.
 *     It can be used as factory class for generating input and output OSM files.
 */
struct __pyx_obj_6osmium_4core_OSMFile {
  PyObject_HEAD
  struct __pyx_vtabstruct_6osmium_4core_OSMFile *__pyx_vtab;
  Osmium::OSMFile *c_osmfile;
};


/* "osmium/osm.pxd":36
 *     pass
 * 
 * cdef class Bounds:             # <<<<<<<<<<<<<<
 *     cdef c_Bounds* c_bounds
 * 
 */
struct __pyx_obj_6osmium_3osm_Bounds {
  PyObject_HEAD
  Osmium::OSM::Bounds *c_bounds;
};


/* "handler.pxd":37
 *     cdef c_Debug *c_handler
 * 
 * cdef class Progress(Base):             # <<<<<<<<<<<<<<
 *     cdef c_Progress *c_handler
 *     cpdef hide_cursor(self)
 */
struct __pyx_obj_6osmium_7handler_Progress {
  struct osmhandler_struct __pyx_base;
  Osmium::Handler::Progress *c_handler;
};


/* "osmium/osm.pxd":26
 *     pass
 * 
 * cdef class Way(Object):             # <<<<<<<<<<<<<<
 *     """OSM Way object
 *     """
 */
struct __pyx_obj_6osmium_3osm_Way {
  struct __pyx_obj_6osmium_3osm_Object __pyx_base;
};



/* "osmium/osm.pxd":40
 * 
 * 
 * cdef class Meta:             # <<<<<<<<<<<<<<
 *     """Meta information from the header of an OSM file.
 *     """
 */

struct __pyx_vtabstruct_6osmium_3osm_Meta {
  PyObject *(*set_from_c)(struct __pyx_obj_6osmium_3osm_Meta *, Osmium::OSM::Meta &);
};
static struct __pyx_vtabstruct_6osmium_3osm_Meta *__pyx_vtabptr_6osmium_3osm_Meta;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) osmhandler_type;

/* "handler.pxd":16
 *     pass
 * 
 * cdef public class Base[object osmhandler_struct, type osmhandler_type]:             # <<<<<<<<<<<<<<
 *     """base class for python implemented handlers
 *     """
 */

struct __pyx_vtabstruct_6osmium_7handler_Base {
  PyObject *(*handle_infile)(struct osmhandler_struct *, Osmium::OSMFile *);
  PyObject *(*init)(struct osmhandler_struct *, struct __pyx_obj_6osmium_3osm_Meta *, int __pyx_skip_dispatch);
  PyObject *(*before_nodes)(struct osmhandler_struct *, int __pyx_skip_dispatch);
  PyObject *(*node)(struct osmhandler_struct *, struct __pyx_obj_6osmium_3osm_Node *, int __pyx_skip_dispatch);
  PyObject *(*after_nodes)(struct osmhandler_struct *, int __pyx_skip_dispatch);
  PyObject *(*before_ways)(struct osmhandler_struct *, int __pyx_skip_dispatch);
  PyObject *(*way)(struct osmhandler_struct *, struct __pyx_obj_6osmium_3osm_Way *, int __pyx_skip_dispatch);
  PyObject *(*after_ways)(struct osmhandler_struct *, int __pyx_skip_dispatch);
  PyObject *(*before_relations)(struct osmhandler_struct *, int __pyx_skip_dispatch);
  PyObject *(*relation)(struct osmhandler_struct *, struct __pyx_obj_6osmium_3osm_Relation *, int __pyx_skip_dispatch);
  PyObject *(*after_relations)(struct osmhandler_struct *, int __pyx_skip_dispatch);
  PyObject *(*final)(struct osmhandler_struct *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_6osmium_7handler_Base *__pyx_vtabptr_6osmium_7handler_Base;


/* "handler.pxd":37
 *     cdef c_Debug *c_handler
 * 
 * cdef class Progress(Base):             # <<<<<<<<<<<<<<
 *     cdef c_Progress *c_handler
 *     cpdef hide_cursor(self)
 */

struct __pyx_vtabstruct_6osmium_7handler_Progress {
  struct __pyx_vtabstruct_6osmium_7handler_Base __pyx_base;
  PyObject *(*hide_cursor)(struct __pyx_obj_6osmium_7handler_Progress *, int __pyx_skip_dispatch);
  PyObject *(*show_cursor)(struct __pyx_obj_6osmium_7handler_Progress *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_6osmium_7handler_Progress *__pyx_vtabptr_6osmium_7handler_Progress;


/* "output.pxd":6
 * from osmium cimport handler
 * 
 * cdef class Base(handler.Base):             # <<<<<<<<<<<<<<
 *     cdef c_Base* c_output
 */

struct __pyx_vtabstruct_6osmium_6output_Base {
  struct __pyx_vtabstruct_6osmium_7handler_Base __pyx_base;
};
static struct __pyx_vtabstruct_6osmium_6output_Base *__pyx_vtabptr_6osmium_6output_Base;


/* "handler.pxd":46
 *     cdef public Base handler2
 * 
 * cdef class Forward(Base):             # <<<<<<<<<<<<<<
 *     cdef public Base handler
 */

struct __pyx_vtabstruct_6osmium_7handler_Forward {
  struct __pyx_vtabstruct_6osmium_7handler_Base __pyx_base;
};
static struct __pyx_vtabstruct_6osmium_7handler_Forward *__pyx_vtabptr_6osmium_7handler_Forward;


/* "handler.pxd":34
 *     cpdef final(self)
 * 
 * cdef class Debug(Base):             # <<<<<<<<<<<<<<
 *     cdef c_Debug *c_handler
 * 
 */

struct __pyx_vtabstruct_6osmium_7handler_Debug {
  struct __pyx_vtabstruct_6osmium_7handler_Base __pyx_base;
};
static struct __pyx_vtabstruct_6osmium_7handler_Debug *__pyx_vtabptr_6osmium_7handler_Debug;


/* "handler.pxd":42
 *     cpdef show_cursor(self)
 * 
 * cdef class Tee(Base):             # <<<<<<<<<<<<<<
 *     cdef public Base handler1
 *     cdef public Base handler2
 */

struct __pyx_vtabstruct_6osmium_7handler_Tee {
  struct __pyx_vtabstruct_6osmium_7handler_Base __pyx_base;
};
static struct __pyx_vtabstruct_6osmium_7handler_Tee *__pyx_vtabptr_6osmium_7handler_Tee;


/* "osmium/core.pyx":9
 * 
 * 
 * cdef class OSMFile:             # <<<<<<<<<<<<<<
 *     u"""This class describes an OSM file in one of several formats.
 *     It can be used as factory class for generating input and output OSM files.
 */

struct __pyx_vtabstruct_6osmium_4core_OSMFile {
  PyObject *(*read)(struct __pyx_obj_6osmium_4core_OSMFile *, struct osmhandler_struct *, int __pyx_skip_dispatch);
  PyObject *(*set_type_and_encoding)(struct __pyx_obj_6osmium_4core_OSMFile *, char *, int __pyx_skip_dispatch);
  PyObject *(*close)(struct __pyx_obj_6osmium_4core_OSMFile *, int __pyx_skip_dispatch);
  int (*get_fd)(struct __pyx_obj_6osmium_4core_OSMFile *, int __pyx_skip_dispatch);
  enum __pyx_t_6osmium_4core_FileType (*get_type)(struct __pyx_obj_6osmium_4core_OSMFile *, int __pyx_skip_dispatch);
  PyObject *(*set_type)(struct __pyx_obj_6osmium_4core_OSMFile *, enum __pyx_t_6osmium_4core_FileType, int __pyx_skip_dispatch);
  enum __pyx_t_6osmium_4core_FileEncoding (*get_encoding)(struct __pyx_obj_6osmium_4core_OSMFile *, int __pyx_skip_dispatch);
  PyObject *(*set_encoding)(struct __pyx_obj_6osmium_4core_OSMFile *, enum __pyx_t_6osmium_4core_FileEncoding, int __pyx_skip_dispatch);
  struct __pyx_obj_6osmium_6output_Base *(*create_output_file)(struct __pyx_obj_6osmium_4core_OSMFile *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_6osmium_4core_OSMFile *__pyx_vtabptr_6osmium_4core_OSMFile;

#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); /*proto*/
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  #define __Pyx_RefNannySetupContext(name)           __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_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #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_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */

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

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*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 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_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*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 void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static CYTHON_INLINE PyObject* __Pyx_tp_new(PyObject* type_obj) {
    return (PyObject*) (((PyTypeObject*)(type_obj))->tp_new(
        (PyTypeObject*)(type_obj), __pyx_empty_tuple, NULL));
}

#ifndef __Pyx_CppExn2PyErr
static void __Pyx_CppExn2PyErr() {
  // Catch a handful of different errors here and turn them into the
  // equivalent Python errors.
  try {
    if (PyErr_Occurred())
      ; // let the latest Python exn pass through and ignore the current one
    else
      throw;
  } catch (const std::bad_alloc& exn) {
    PyErr_SetString(PyExc_MemoryError, exn.what());
  } catch (const std::bad_cast& exn) {
    PyErr_SetString(PyExc_TypeError, exn.what());
  } catch (const std::domain_error& exn) {
    PyErr_SetString(PyExc_ValueError, exn.what());
  } catch (const std::invalid_argument& exn) {
    PyErr_SetString(PyExc_ValueError, exn.what());
  } catch (const std::ios_base::failure& exn) {
    // Unfortunately, in standard C++ we have no way of distinguishing EOF
    // from other errors here; be careful with the exception mask
    PyErr_SetString(PyExc_IOError, exn.what());
  } catch (const std::out_of_range& exn) {
    // Change out_of_range to IndexError
    PyErr_SetString(PyExc_IndexError, exn.what());
  } catch (const std::overflow_error& exn) {
    PyErr_SetString(PyExc_OverflowError, exn.what());
  } catch (const std::range_error& exn) {
    PyErr_SetString(PyExc_ArithmeticError, exn.what());
  } catch (const std::underflow_error& exn) {
    PyErr_SetString(PyExc_ArithmeticError, exn.what());
  } catch (const std::exception& exn) {
    PyErr_SetString(PyExc_RuntimeError, exn.what());
  }
  catch (...)
  {
    PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
  }
}
#endif

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_check_binary_version(void);

static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig); /*proto*/

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

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

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

static void* __Pyx_GetVtable(PyObject *dict); /*proto*/

static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig); /*proto*/

static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
                               int __pyx_lineno, const char *__pyx_filename); /*proto*/

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

/* Module declarations from 'libcpp' */

/* Module declarations from 'libcpp.string' */

/* Module declarations from 'c_osmium' */

/* Module declarations from 'libc.stdint' */

/* Module declarations from 'c_osmium.osm' */

/* Module declarations from 'c_osmium.handler' */

/* Module declarations from 'c_osmium.output' */

/* Module declarations from 'c_osmium.osmfile' */

/* Module declarations from 'osmium' */

/* Module declarations from 'osmium.osm' */
static PyTypeObject *__pyx_ptype_6osmium_3osm_TagList = 0;
static PyTypeObject *__pyx_ptype_6osmium_3osm_WayNodeList = 0;
static PyTypeObject *__pyx_ptype_6osmium_3osm_RelationMemberList = 0;
static PyTypeObject *__pyx_ptype_6osmium_3osm_Object = 0;
static PyTypeObject *__pyx_ptype_6osmium_3osm_Node = 0;
static PyTypeObject *__pyx_ptype_6osmium_3osm_Way = 0;
static PyTypeObject *__pyx_ptype_6osmium_3osm_Relation = 0;
static PyTypeObject *__pyx_ptype_6osmium_3osm_Bounds = 0;
static PyTypeObject *__pyx_ptype_6osmium_3osm_Meta = 0;
static struct __pyx_obj_6osmium_3osm_Node **__pyx_vp_6osmium_3osm__cache_node = 0;
#define __pyx_v_6osmium_3osm__cache_node (*__pyx_vp_6osmium_3osm__cache_node)
static struct __pyx_obj_6osmium_3osm_Way **__pyx_vp_6osmium_3osm__cache_way = 0;
#define __pyx_v_6osmium_3osm__cache_way (*__pyx_vp_6osmium_3osm__cache_way)
static struct __pyx_obj_6osmium_3osm_Relation **__pyx_vp_6osmium_3osm__cache_relation = 0;
#define __pyx_v_6osmium_3osm__cache_relation (*__pyx_vp_6osmium_3osm__cache_relation)
static struct __pyx_obj_6osmium_3osm_TagList **__pyx_vp_6osmium_3osm__cache_taglist = 0;
#define __pyx_v_6osmium_3osm__cache_taglist (*__pyx_vp_6osmium_3osm__cache_taglist)
static struct __pyx_obj_6osmium_3osm_WayNodeList **__pyx_vp_6osmium_3osm__cache_waynodelist = 0;
#define __pyx_v_6osmium_3osm__cache_waynodelist (*__pyx_vp_6osmium_3osm__cache_waynodelist)
static struct __pyx_obj_6osmium_3osm_RelationMemberList **__pyx_vp_6osmium_3osm__cache_relationmemberlist = 0;
#define __pyx_v_6osmium_3osm__cache_relationmemberlist (*__pyx_vp_6osmium_3osm__cache_relationmemberlist)

/* Module declarations from '__builtin__' */

/* Module declarations from 'osmium.handler' */
static PyTypeObject *__pyx_ptype_6osmium_7handler_Exception = 0;
static PyTypeObject *__pyx_ptype_6osmium_7handler_StopReading = 0;
static PyTypeObject *__pyx_ptype_6osmium_7handler_Base = 0;
static PyTypeObject *__pyx_ptype_6osmium_7handler_Debug = 0;
static PyTypeObject *__pyx_ptype_6osmium_7handler_Progress = 0;
static PyTypeObject *__pyx_ptype_6osmium_7handler_Tee = 0;
static PyTypeObject *__pyx_ptype_6osmium_7handler_Forward = 0;

/* Module declarations from 'osmium.output' */
static PyTypeObject *__pyx_ptype_6osmium_6output_Base = 0;

/* Module declarations from 'osmium.core' */
static PyTypeObject *__pyx_ptype_6osmium_4core_OSMFile = 0;
static PyObject *__pyx_f_6osmium_4core_set_debug(bool, int __pyx_skip_dispatch); /*proto*/
static bool __pyx_f_6osmium_4core_debug(int __pyx_skip_dispatch); /*proto*/
#define __Pyx_MODULE_NAME "osmium.core"
int __pyx_module_is_main_osmium__core = 0;

/* Implementation of 'osmium.core' */
static PyObject *__pyx_builtin_RuntimeError;
static char __pyx_k_1[] = "";
static char __pyx_k_2[] = "set_type_and_encoding";
static char __pyx_k_3[] = "Unknown Filetype";
static char __pyx_k__read[] = "read";
static char __pyx_k__close[] = "close";
static char __pyx_k__get_fd[] = "get_fd";
static char __pyx_k__ENC_PBF[] = "ENC_PBF";
static char __pyx_k__ENC_XML[] = "ENC_XML";
static char __pyx_k__TYPE_OSM[] = "TYPE_OSM";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__filename[] = "filename";
static char __pyx_k__get_type[] = "get_type";
static char __pyx_k__set_type[] = "set_type";
static char __pyx_k__ENC_XMLgz[] = "ENC_XMLgz";
static char __pyx_k__ENC_XMLbz2[] = "ENC_XMLbz2";
static char __pyx_k__TYPE_CHANGE[] = "TYPE_CHANGE";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static char __pyx_k__TYPE_HISTORY[] = "TYPE_HISTORY";
static char __pyx_k__get_encoding[] = "get_encoding";
static char __pyx_k__set_encoding[] = "set_encoding";
static char __pyx_k__create_output_file[] = "create_output_file";
static PyObject *__pyx_kp_b_1;
static PyObject *__pyx_n_s_2;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_n_s__ENC_PBF;
static PyObject *__pyx_n_s__ENC_XML;
static PyObject *__pyx_n_s__ENC_XMLbz2;
static PyObject *__pyx_n_s__ENC_XMLgz;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__TYPE_CHANGE;
static PyObject *__pyx_n_s__TYPE_HISTORY;
static PyObject *__pyx_n_s__TYPE_OSM;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__close;
static PyObject *__pyx_n_s__create_output_file;
static PyObject *__pyx_n_s__filename;
static PyObject *__pyx_n_s__get_encoding;
static PyObject *__pyx_n_s__get_fd;
static PyObject *__pyx_n_s__get_type;
static PyObject *__pyx_n_s__read;
static PyObject *__pyx_n_s__set_encoding;
static PyObject *__pyx_n_s__set_type;
static PyObject *__pyx_k_tuple_4;
static PyObject *__pyx_k_tuple_5;
static PyObject *__pyx_k_tuple_6;
static PyObject *__pyx_k_tuple_7;

/* "osmium/core.pyx":27
 *     ENC_XMLbz2=C_ENC_XMLbz2
 * 
 *     def __cinit__(self, filename=b""):             # <<<<<<<<<<<<<<
 *         cdef string fn_string
 *         fn_string.assign(<char*>filename)
 */

static int __pyx_pf_6osmium_4core_7OSMFile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6osmium_4core_7OSMFile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  std::string __pyx_v_fn_string;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  char *__pyx_t_1;
  Osmium::OSMFile *__pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,0};
  __Pyx_RefNannySetupContext("__cinit__");
  {
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_kp_b_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
          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), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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;
      }
    }
    __pyx_v_filename = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("osmium.core.OSMFile.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "osmium/core.pyx":29
 *     def __cinit__(self, filename=b""):
 *         cdef string fn_string
 *         fn_string.assign(<char*>filename)             # <<<<<<<<<<<<<<
 *         self.c_osmfile = new c_OSMFile(fn_string)
 * 
 */
  __pyx_t_1 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_fn_string.assign(((char *)__pyx_t_1));

  /* "osmium/core.pyx":30
 *         cdef string fn_string
 *         fn_string.assign(<char*>filename)
 *         self.c_osmfile = new c_OSMFile(fn_string)             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, filename=b""):
 */
  try {__pyx_t_2 = new Osmium::OSMFile(__pyx_v_fn_string);} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
  ((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->c_osmfile = __pyx_t_2;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("osmium.core.OSMFile.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":32
 *         self.c_osmfile = new c_OSMFile(fn_string)
 * 
 *     def __init__(self, filename=b""):             # <<<<<<<<<<<<<<
 *         u"""__init__(self, filename=b"")
 *         Create OSMFile using type and encoding from filename. If you want
 */

static int __pyx_pf_6osmium_4core_7OSMFile_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6osmium_4core_7OSMFile_1__init__[] = "__init__(self, filename=b\"\")\n        Create OSMFile using type and encoding from filename. If you want\n        to overwrite these settings you can change them later.\n\n        @param filename Filename including suffix. The type and encoding\n        of the file will be taken from the suffix.\n        An empty filename or \"-\" means stdin or stdout.\n        ";
struct wrapperbase __pyx_wrapperbase_6osmium_4core_7OSMFile_1__init__;
static int __pyx_pf_6osmium_4core_7OSMFile_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,0};
  __Pyx_RefNannySetupContext("__init__");
  {
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_kp_b_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
          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 = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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;
      }
    }
    __pyx_v_filename = values[0];
  }
  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 = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("osmium.core.OSMFile.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":43
 *         pass
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         del self.c_osmfile
 * 
 */

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

  /* "osmium/core.pyx":44
 * 
 *     def __dealloc__(self):
 *         del self.c_osmfile             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  delete ((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->c_osmfile;

  __Pyx_RefNannyFinishContext();
}

/* "osmium/core.pyx":46
 *         del self.c_osmfile
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         u"""copy(self)
 *         Create a copy of the OSMFile object.
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_3copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6osmium_4core_7OSMFile_3copy[] = "copy(self)\n        Create a copy of the OSMFile object.\n        Only attributes not related to the open file will be\n        copied.\n        ";
static PyObject *__pyx_pf_6osmium_4core_7OSMFile_3copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  struct __pyx_obj_6osmium_4core_OSMFile *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("copy");

  /* "osmium/core.pyx":52
 *         copied.
 *         """
 *         cdef OSMFile result = OSMFile()             # <<<<<<<<<<<<<<
 *         result.c_osmfile[0] = self.c_osmfile[0]
 *         return result
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6osmium_4core_OSMFile)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "osmium/core.pyx":53
 *         """
 *         cdef OSMFile result = OSMFile()
 *         result.c_osmfile[0] = self.c_osmfile[0]             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  (__pyx_v_result->c_osmfile[0]) = (((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->c_osmfile[0]);

  /* "osmium/core.pyx":54
 *         cdef OSMFile result = OSMFile()
 *         result.c_osmfile[0] = self.c_osmfile[0]
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cpdef read(self, handler.Base handler):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__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_AddTraceback("osmium.core.OSMFile.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":56
 *         return result
 * 
 *     cpdef read(self, handler.Base handler):             # <<<<<<<<<<<<<<
 *         u"""read(self, handler)
 *         Read OSM file and call methods on handler object
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_4read(PyObject *__pyx_v_self, PyObject *__pyx_v_handler); /*proto*/
static PyObject *__pyx_f_6osmium_4core_7OSMFile_read(struct __pyx_obj_6osmium_4core_OSMFile *__pyx_v_self, struct osmhandler_struct *__pyx_v_handler, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("read");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6osmium_4core_7OSMFile_4read)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(((PyObject *)__pyx_v_handler));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_handler));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_handler));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "osmium/core.pyx":60
 *         Read OSM file and call methods on handler object
 *         """
 *         handler.handle_infile(self.c_osmfile)             # <<<<<<<<<<<<<<
 * 
 *     cpdef set_type_and_encoding(self, char* suffix):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6osmium_7handler_Base *)__pyx_v_handler->__pyx_vtab)->handle_infile(__pyx_v_handler, __pyx_v_self->c_osmfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __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("osmium.core.OSMFile.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":56
 *         return result
 * 
 *     cpdef read(self, handler.Base handler):             # <<<<<<<<<<<<<<
 *         u"""read(self, handler)
 *         Read OSM file and call methods on handler object
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_4read(PyObject *__pyx_v_self, PyObject *__pyx_v_handler); /*proto*/
static char __pyx_doc_6osmium_4core_7OSMFile_4read[] = "read(self, handler)\n        Read OSM file and call methods on handler object\n        ";
static PyObject *__pyx_pf_6osmium_4core_7OSMFile_4read(PyObject *__pyx_v_self, PyObject *__pyx_v_handler) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("read");
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_handler), __pyx_ptype_6osmium_7handler_Base, 1, "handler", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6osmium_4core_OSMFile *)((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->__pyx_vtab)->read(((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self), ((struct osmhandler_struct *)__pyx_v_handler), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __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("osmium.core.OSMFile.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":62
 *         handler.handle_infile(self.c_osmfile)
 * 
 *     cpdef set_type_and_encoding(self, char* suffix):             # <<<<<<<<<<<<<<
 *         u"""set_type_and_encoding(self, suffix)
 *         Changes type and encoding according to the given suffix.
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_5set_type_and_encoding(PyObject *__pyx_v_self, PyObject *__pyx_arg_suffix); /*proto*/
static PyObject *__pyx_f_6osmium_4core_7OSMFile_set_type_and_encoding(struct __pyx_obj_6osmium_4core_OSMFile *__pyx_v_self, char *__pyx_v_suffix, int __pyx_skip_dispatch) {
  std::string __pyx_v_str_suffix;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_type_and_encoding");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6osmium_4core_7OSMFile_5set_type_and_encoding)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyBytes_FromString(__pyx_v_suffix); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __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 = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__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_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "osmium/core.pyx":67
 *         """
 *         cdef string str_suffix
 *         str_suffix.assign(suffix)             # <<<<<<<<<<<<<<
 *         self.c_osmfile.set_type_and_encoding(str_suffix)
 * 
 */
  __pyx_v_str_suffix.assign(__pyx_v_suffix);

  /* "osmium/core.pyx":68
 *         cdef string str_suffix
 *         str_suffix.assign(suffix)
 *         self.c_osmfile.set_type_and_encoding(str_suffix)             # <<<<<<<<<<<<<<
 * 
 *     cpdef close(self):
 */
  try {__pyx_v_self->c_osmfile->set_type_and_encoding(__pyx_v_str_suffix);} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("osmium.core.OSMFile.set_type_and_encoding", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":62
 *         handler.handle_infile(self.c_osmfile)
 * 
 *     cpdef set_type_and_encoding(self, char* suffix):             # <<<<<<<<<<<<<<
 *         u"""set_type_and_encoding(self, suffix)
 *         Changes type and encoding according to the given suffix.
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_5set_type_and_encoding(PyObject *__pyx_v_self, PyObject *__pyx_arg_suffix); /*proto*/
static char __pyx_doc_6osmium_4core_7OSMFile_5set_type_and_encoding[] = "set_type_and_encoding(self, suffix)\n        Changes type and encoding according to the given suffix.\n        ";
static PyObject *__pyx_pf_6osmium_4core_7OSMFile_5set_type_and_encoding(PyObject *__pyx_v_self, PyObject *__pyx_arg_suffix) {
  char *__pyx_v_suffix;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_type_and_encoding");
  assert(__pyx_arg_suffix); {
    __pyx_v_suffix = PyBytes_AsString(__pyx_arg_suffix); if (unlikely((!__pyx_v_suffix) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("osmium.core.OSMFile.set_type_and_encoding", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6osmium_4core_OSMFile *)((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->__pyx_vtab)->set_type_and_encoding(((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self), __pyx_v_suffix, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __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("osmium.core.OSMFile.set_type_and_encoding", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":70
 *         self.c_osmfile.set_type_and_encoding(str_suffix)
 * 
 *     cpdef close(self):             # <<<<<<<<<<<<<<
 *         u"""close(self)
 *         Close the associated file.
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_6close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_6osmium_4core_7OSMFile_close(struct __pyx_obj_6osmium_4core_OSMFile *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("close");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6osmium_4core_7OSMFile_6close)) {
      __Pyx_XDECREF(__pyx_r);
      __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 = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "osmium/core.pyx":74
 *         Close the associated file.
 *         """
 *         self.c_osmfile.close()             # <<<<<<<<<<<<<<
 * 
 *     cpdef int get_fd(self) except? -1:
 */
  try {__pyx_v_self->c_osmfile->close();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __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_2);
  __Pyx_AddTraceback("osmium.core.OSMFile.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":70
 *         self.c_osmfile.set_type_and_encoding(str_suffix)
 * 
 *     cpdef close(self):             # <<<<<<<<<<<<<<
 *         u"""close(self)
 *         Close the associated file.
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_6close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6osmium_4core_7OSMFile_6close[] = "close(self)\n        Close the associated file.\n        ";
static PyObject *__pyx_pf_6osmium_4core_7OSMFile_6close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("close");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6osmium_4core_OSMFile *)((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->__pyx_vtab)->close(((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __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("osmium.core.OSMFile.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":76
 *         self.c_osmfile.close()
 * 
 *     cpdef int get_fd(self) except? -1:             # <<<<<<<<<<<<<<
 *         u"""get_fd(self) -> int
 *         Return the associated file descriptor
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_7get_fd(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static int __pyx_f_6osmium_4core_7OSMFile_get_fd(struct __pyx_obj_6osmium_4core_OSMFile *__pyx_v_self, int __pyx_skip_dispatch) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_fd");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__get_fd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6osmium_4core_7OSMFile_7get_fd)) {
      __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 = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "osmium/core.pyx":80
 *         Return the associated file descriptor
 *         """
 *         return self.c_osmfile.get_fd()             # <<<<<<<<<<<<<<
 * 
 *     cpdef FileType get_type(self) except? C_TYPE_EXCEPTION:
 */
  __pyx_r = __pyx_v_self->c_osmfile->get_fd();
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("osmium.core.OSMFile.get_fd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":76
 *         self.c_osmfile.close()
 * 
 *     cpdef int get_fd(self) except? -1:             # <<<<<<<<<<<<<<
 *         u"""get_fd(self) -> int
 *         Return the associated file descriptor
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_7get_fd(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6osmium_4core_7OSMFile_7get_fd[] = "get_fd(self) -> int\n        Return the associated file descriptor\n        ";
static PyObject *__pyx_pf_6osmium_4core_7OSMFile_7get_fd(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_fd");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6osmium_4core_OSMFile *)((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->__pyx_vtab)->get_fd(((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self), 1); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __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_2);
  __Pyx_AddTraceback("osmium.core.OSMFile.get_fd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":82
 *         return self.c_osmfile.get_fd()
 * 
 *     cpdef FileType get_type(self) except? C_TYPE_EXCEPTION:             # <<<<<<<<<<<<<<
 *         u"""get_type(self) -> FileType
 *         """
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_8get_type(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static enum __pyx_t_6osmium_4core_FileType __pyx_f_6osmium_4core_7OSMFile_get_type(struct __pyx_obj_6osmium_4core_OSMFile *__pyx_v_self, int __pyx_skip_dispatch) {
  Osmium::OSMFile::FileType *__pyx_v_c_ft;
  enum __pyx_t_6osmium_4core_FileType __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  enum __pyx_t_6osmium_4core_FileType __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__get_type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6osmium_4core_7OSMFile_8get_type)) {
      __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 = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = ((enum __pyx_t_6osmium_4core_FileType)PyInt_AsLong(__pyx_t_2)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "osmium/core.pyx":86
 *         """
 *         cdef osmfile.FileType* c_ft
 *         c_ft = self.c_osmfile.get_type()             # <<<<<<<<<<<<<<
 *         if c_ft == osmfile.FileTypeOSM():
 *             return C_TYPE_OSM
 */
  __pyx_v_c_ft = __pyx_v_self->c_osmfile->get_type();

  /* "osmium/core.pyx":87
 *         cdef osmfile.FileType* c_ft
 *         c_ft = self.c_osmfile.get_type()
 *         if c_ft == osmfile.FileTypeOSM():             # <<<<<<<<<<<<<<
 *             return C_TYPE_OSM
 *         elif c_ft == osmfile.FileTypeHistory():
 */
  __pyx_t_4 = (__pyx_v_c_ft == Osmium::OSMFile::FileType::OSM());
  if (__pyx_t_4) {

    /* "osmium/core.pyx":88
 *         c_ft = self.c_osmfile.get_type()
 *         if c_ft == osmfile.FileTypeOSM():
 *             return C_TYPE_OSM             # <<<<<<<<<<<<<<
 *         elif c_ft == osmfile.FileTypeHistory():
 *             return C_TYPE_HISTORY
 */
    __pyx_r = __pyx_e_6osmium_4core_C_TYPE_OSM;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "osmium/core.pyx":89
 *         if c_ft == osmfile.FileTypeOSM():
 *             return C_TYPE_OSM
 *         elif c_ft == osmfile.FileTypeHistory():             # <<<<<<<<<<<<<<
 *             return C_TYPE_HISTORY
 *         elif c_ft == osmfile.FileTypeChange():
 */
  __pyx_t_4 = (__pyx_v_c_ft == Osmium::OSMFile::FileType::History());
  if (__pyx_t_4) {

    /* "osmium/core.pyx":90
 *             return C_TYPE_OSM
 *         elif c_ft == osmfile.FileTypeHistory():
 *             return C_TYPE_HISTORY             # <<<<<<<<<<<<<<
 *         elif c_ft == osmfile.FileTypeChange():
 *             return C_TYPE_CHANGE
 */
    __pyx_r = __pyx_e_6osmium_4core_C_TYPE_HISTORY;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "osmium/core.pyx":91
 *         elif c_ft == osmfile.FileTypeHistory():
 *             return C_TYPE_HISTORY
 *         elif c_ft == osmfile.FileTypeChange():             # <<<<<<<<<<<<<<
 *             return C_TYPE_CHANGE
 *         else:
 */
  __pyx_t_4 = (__pyx_v_c_ft == Osmium::OSMFile::FileType::Change());
  if (__pyx_t_4) {

    /* "osmium/core.pyx":92
 *             return C_TYPE_HISTORY
 *         elif c_ft == osmfile.FileTypeChange():
 *             return C_TYPE_CHANGE             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError("Unknown Filetype")
 */
    __pyx_r = __pyx_e_6osmium_4core_C_TYPE_CHANGE;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "osmium/core.pyx":94
 *             return C_TYPE_CHANGE
 *         else:
 *             raise RuntimeError("Unknown Filetype")             # <<<<<<<<<<<<<<
 * 
 *     cpdef set_type(self, FileType newtype):
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("osmium.core.OSMFile.get_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_e_6osmium_4core_C_TYPE_EXCEPTION;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":82
 *         return self.c_osmfile.get_fd()
 * 
 *     cpdef FileType get_type(self) except? C_TYPE_EXCEPTION:             # <<<<<<<<<<<<<<
 *         u"""get_type(self) -> FileType
 *         """
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_8get_type(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6osmium_4core_7OSMFile_8get_type[] = "get_type(self) -> FileType\n        ";
static PyObject *__pyx_pf_6osmium_4core_7OSMFile_8get_type(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  enum __pyx_t_6osmium_4core_FileType __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_type");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6osmium_4core_OSMFile *)((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->__pyx_vtab)->get_type(((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self), 1); if (unlikely(__pyx_t_1 == __pyx_e_6osmium_4core_C_TYPE_EXCEPTION && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(__pyx_t_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_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_2);
  __Pyx_AddTraceback("osmium.core.OSMFile.get_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":96
 *             raise RuntimeError("Unknown Filetype")
 * 
 *     cpdef set_type(self, FileType newtype):             # <<<<<<<<<<<<<<
 *         u"""set_type(self, FileType)
 *         """
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_9set_type(PyObject *__pyx_v_self, PyObject *__pyx_arg_newtype); /*proto*/
static PyObject *__pyx_f_6osmium_4core_7OSMFile_set_type(struct __pyx_obj_6osmium_4core_OSMFile *__pyx_v_self, enum __pyx_t_6osmium_4core_FileType __pyx_v_newtype, int __pyx_skip_dispatch) {
  Osmium::OSMFile::FileType *__pyx_v_c_ft;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_type");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__set_type); 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);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6osmium_4core_7OSMFile_9set_type)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyInt_FromLong(__pyx_v_newtype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__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, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "osmium/core.pyx":101
 *         cdef osmfile.FileType* c_ft
 * 
 *         if newtype == C_TYPE_OSM:             # <<<<<<<<<<<<<<
 *             c_ft = osmfile.FileTypeOSM()
 *         elif newtype == C_TYPE_HISTORY:
 */
  __pyx_t_4 = (__pyx_v_newtype == __pyx_e_6osmium_4core_C_TYPE_OSM);
  if (__pyx_t_4) {

    /* "osmium/core.pyx":102
 * 
 *         if newtype == C_TYPE_OSM:
 *             c_ft = osmfile.FileTypeOSM()             # <<<<<<<<<<<<<<
 *         elif newtype == C_TYPE_HISTORY:
 *             c_ft = osmfile.FileTypeHistory()
 */
    __pyx_v_c_ft = Osmium::OSMFile::FileType::OSM();
    goto __pyx_L3;
  }

  /* "osmium/core.pyx":103
 *         if newtype == C_TYPE_OSM:
 *             c_ft = osmfile.FileTypeOSM()
 *         elif newtype == C_TYPE_HISTORY:             # <<<<<<<<<<<<<<
 *             c_ft = osmfile.FileTypeHistory()
 *         elif newtype == C_TYPE_CHANGE:
 */
  __pyx_t_4 = (__pyx_v_newtype == __pyx_e_6osmium_4core_C_TYPE_HISTORY);
  if (__pyx_t_4) {

    /* "osmium/core.pyx":104
 *             c_ft = osmfile.FileTypeOSM()
 *         elif newtype == C_TYPE_HISTORY:
 *             c_ft = osmfile.FileTypeHistory()             # <<<<<<<<<<<<<<
 *         elif newtype == C_TYPE_CHANGE:
 *             c_ft = osmfile.FileTypeChange()
 */
    __pyx_v_c_ft = Osmium::OSMFile::FileType::History();
    goto __pyx_L3;
  }

  /* "osmium/core.pyx":105
 *         elif newtype == C_TYPE_HISTORY:
 *             c_ft = osmfile.FileTypeHistory()
 *         elif newtype == C_TYPE_CHANGE:             # <<<<<<<<<<<<<<
 *             c_ft = osmfile.FileTypeChange()
 *         else:
 */
  __pyx_t_4 = (__pyx_v_newtype == __pyx_e_6osmium_4core_C_TYPE_CHANGE);
  if (__pyx_t_4) {

    /* "osmium/core.pyx":106
 *             c_ft = osmfile.FileTypeHistory()
 *         elif newtype == C_TYPE_CHANGE:
 *             c_ft = osmfile.FileTypeChange()             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError("Unknown Filetype")
 */
    __pyx_v_c_ft = Osmium::OSMFile::FileType::Change();
    goto __pyx_L3;
  }
  /*else*/ {

    /* "osmium/core.pyx":108
 *             c_ft = osmfile.FileTypeChange()
 *         else:
 *             raise RuntimeError("Unknown Filetype")             # <<<<<<<<<<<<<<
 * 
 *         self.c_osmfile.set_type(c_ft)
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "osmium/core.pyx":110
 *             raise RuntimeError("Unknown Filetype")
 * 
 *         self.c_osmfile.set_type(c_ft)             # <<<<<<<<<<<<<<
 * 
 *     cpdef FileEncoding get_encoding(self) except? C_ENC_EXCEPTION:
 */
  __pyx_v_self->c_osmfile->set_type(__pyx_v_c_ft);

  __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("osmium.core.OSMFile.set_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":96
 *             raise RuntimeError("Unknown Filetype")
 * 
 *     cpdef set_type(self, FileType newtype):             # <<<<<<<<<<<<<<
 *         u"""set_type(self, FileType)
 *         """
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_9set_type(PyObject *__pyx_v_self, PyObject *__pyx_arg_newtype); /*proto*/
static char __pyx_doc_6osmium_4core_7OSMFile_9set_type[] = "set_type(self, FileType)\n        ";
static PyObject *__pyx_pf_6osmium_4core_7OSMFile_9set_type(PyObject *__pyx_v_self, PyObject *__pyx_arg_newtype) {
  enum __pyx_t_6osmium_4core_FileType __pyx_v_newtype;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_type");
  assert(__pyx_arg_newtype); {
    __pyx_v_newtype = ((enum __pyx_t_6osmium_4core_FileType)PyInt_AsLong(__pyx_arg_newtype)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("osmium.core.OSMFile.set_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6osmium_4core_OSMFile *)((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->__pyx_vtab)->set_type(((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self), __pyx_v_newtype, 1); 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("osmium.core.OSMFile.set_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":112
 *         self.c_osmfile.set_type(c_ft)
 * 
 *     cpdef FileEncoding get_encoding(self) except? C_ENC_EXCEPTION:             # <<<<<<<<<<<<<<
 *         u"""get_encoding(self) -> FileEncoding
 *         """
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_10get_encoding(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static enum __pyx_t_6osmium_4core_FileEncoding __pyx_f_6osmium_4core_7OSMFile_get_encoding(struct __pyx_obj_6osmium_4core_OSMFile *__pyx_v_self, int __pyx_skip_dispatch) {
  Osmium::OSMFile::FileEncoding *__pyx_v_c_enc;
  enum __pyx_t_6osmium_4core_FileEncoding __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  enum __pyx_t_6osmium_4core_FileEncoding __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_encoding");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__get_encoding); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6osmium_4core_7OSMFile_10get_encoding)) {
      __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 = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = ((enum __pyx_t_6osmium_4core_FileEncoding)PyInt_AsLong(__pyx_t_2)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "osmium/core.pyx":116
 *         """
 *         cdef osmfile.FileEncoding* c_enc
 *         c_enc = self.c_osmfile.get_encoding()             # <<<<<<<<<<<<<<
 * 
 *         if c_enc == osmfile.FileEncodingPBF():
 */
  __pyx_v_c_enc = __pyx_v_self->c_osmfile->get_encoding();

  /* "osmium/core.pyx":118
 *         c_enc = self.c_osmfile.get_encoding()
 * 
 *         if c_enc == osmfile.FileEncodingPBF():             # <<<<<<<<<<<<<<
 *             return C_ENC_PBF
 *         elif c_enc == osmfile.FileEncodingXML():
 */
  __pyx_t_4 = (__pyx_v_c_enc == Osmium::OSMFile::FileEncoding::PBF());
  if (__pyx_t_4) {

    /* "osmium/core.pyx":119
 * 
 *         if c_enc == osmfile.FileEncodingPBF():
 *             return C_ENC_PBF             # <<<<<<<<<<<<<<
 *         elif c_enc == osmfile.FileEncodingXML():
 *             return C_ENC_XML
 */
    __pyx_r = __pyx_e_6osmium_4core_C_ENC_PBF;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "osmium/core.pyx":120
 *         if c_enc == osmfile.FileEncodingPBF():
 *             return C_ENC_PBF
 *         elif c_enc == osmfile.FileEncodingXML():             # <<<<<<<<<<<<<<
 *             return C_ENC_XML
 *         elif c_enc == osmfile.FileEncodingXMLgz():
 */
  __pyx_t_4 = (__pyx_v_c_enc == Osmium::OSMFile::FileEncoding::XML());
  if (__pyx_t_4) {

    /* "osmium/core.pyx":121
 *             return C_ENC_PBF
 *         elif c_enc == osmfile.FileEncodingXML():
 *             return C_ENC_XML             # <<<<<<<<<<<<<<
 *         elif c_enc == osmfile.FileEncodingXMLgz():
 *             return C_ENC_XMLgz
 */
    __pyx_r = __pyx_e_6osmium_4core_C_ENC_XML;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "osmium/core.pyx":122
 *         elif c_enc == osmfile.FileEncodingXML():
 *             return C_ENC_XML
 *         elif c_enc == osmfile.FileEncodingXMLgz():             # <<<<<<<<<<<<<<
 *             return C_ENC_XMLgz
 *         elif c_enc == osmfile.FileEncodingXMLbz2():
 */
  __pyx_t_4 = (__pyx_v_c_enc == Osmium::OSMFile::FileEncoding::XMLgz());
  if (__pyx_t_4) {

    /* "osmium/core.pyx":123
 *             return C_ENC_XML
 *         elif c_enc == osmfile.FileEncodingXMLgz():
 *             return C_ENC_XMLgz             # <<<<<<<<<<<<<<
 *         elif c_enc == osmfile.FileEncodingXMLbz2():
 *             return C_ENC_XMLbz2
 */
    __pyx_r = __pyx_e_6osmium_4core_C_ENC_XMLgz;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "osmium/core.pyx":124
 *         elif c_enc == osmfile.FileEncodingXMLgz():
 *             return C_ENC_XMLgz
 *         elif c_enc == osmfile.FileEncodingXMLbz2():             # <<<<<<<<<<<<<<
 *             return C_ENC_XMLbz2
 *         else:
 */
  __pyx_t_4 = (__pyx_v_c_enc == Osmium::OSMFile::FileEncoding::XMLbz2());
  if (__pyx_t_4) {

    /* "osmium/core.pyx":125
 *             return C_ENC_XMLgz
 *         elif c_enc == osmfile.FileEncodingXMLbz2():
 *             return C_ENC_XMLbz2             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError("Unknown Filetype")
 */
    __pyx_r = __pyx_e_6osmium_4core_C_ENC_XMLbz2;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "osmium/core.pyx":127
 *             return C_ENC_XMLbz2
 *         else:
 *             raise RuntimeError("Unknown Filetype")             # <<<<<<<<<<<<<<
 * 
 *     cpdef set_encoding(self, FileEncoding newenc):
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("osmium.core.OSMFile.get_encoding", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_e_6osmium_4core_C_ENC_EXCEPTION;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":112
 *         self.c_osmfile.set_type(c_ft)
 * 
 *     cpdef FileEncoding get_encoding(self) except? C_ENC_EXCEPTION:             # <<<<<<<<<<<<<<
 *         u"""get_encoding(self) -> FileEncoding
 *         """
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_10get_encoding(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6osmium_4core_7OSMFile_10get_encoding[] = "get_encoding(self) -> FileEncoding\n        ";
static PyObject *__pyx_pf_6osmium_4core_7OSMFile_10get_encoding(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  enum __pyx_t_6osmium_4core_FileEncoding __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_encoding");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6osmium_4core_OSMFile *)((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->__pyx_vtab)->get_encoding(((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self), 1); if (unlikely(__pyx_t_1 == __pyx_e_6osmium_4core_C_ENC_EXCEPTION && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __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_2);
  __Pyx_AddTraceback("osmium.core.OSMFile.get_encoding", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":129
 *             raise RuntimeError("Unknown Filetype")
 * 
 *     cpdef set_encoding(self, FileEncoding newenc):             # <<<<<<<<<<<<<<
 *         u"""set_encoding(self, FileEncoding)
 *         """
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_11set_encoding(PyObject *__pyx_v_self, PyObject *__pyx_arg_newenc); /*proto*/
static PyObject *__pyx_f_6osmium_4core_7OSMFile_set_encoding(struct __pyx_obj_6osmium_4core_OSMFile *__pyx_v_self, enum __pyx_t_6osmium_4core_FileEncoding __pyx_v_newenc, int __pyx_skip_dispatch) {
  Osmium::OSMFile::FileEncoding *__pyx_v_c_enc;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_encoding");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__set_encoding); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6osmium_4core_7OSMFile_11set_encoding)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyInt_FromLong(__pyx_v_newenc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__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, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "osmium/core.pyx":134
 *         cdef osmfile.FileEncoding* c_enc
 * 
 *         if newenc == C_ENC_PBF:             # <<<<<<<<<<<<<<
 *             c_enc = osmfile.FileEncodingPBF()
 *         elif newenc == C_ENC_XML:
 */
  __pyx_t_4 = (__pyx_v_newenc == __pyx_e_6osmium_4core_C_ENC_PBF);
  if (__pyx_t_4) {

    /* "osmium/core.pyx":135
 * 
 *         if newenc == C_ENC_PBF:
 *             c_enc = osmfile.FileEncodingPBF()             # <<<<<<<<<<<<<<
 *         elif newenc == C_ENC_XML:
 *             c_enc = osmfile.FileEncodingXML()
 */
    __pyx_v_c_enc = Osmium::OSMFile::FileEncoding::PBF();
    goto __pyx_L3;
  }

  /* "osmium/core.pyx":136
 *         if newenc == C_ENC_PBF:
 *             c_enc = osmfile.FileEncodingPBF()
 *         elif newenc == C_ENC_XML:             # <<<<<<<<<<<<<<
 *             c_enc = osmfile.FileEncodingXML()
 *         elif newenc == C_ENC_XMLgz:
 */
  __pyx_t_4 = (__pyx_v_newenc == __pyx_e_6osmium_4core_C_ENC_XML);
  if (__pyx_t_4) {

    /* "osmium/core.pyx":137
 *             c_enc = osmfile.FileEncodingPBF()
 *         elif newenc == C_ENC_XML:
 *             c_enc = osmfile.FileEncodingXML()             # <<<<<<<<<<<<<<
 *         elif newenc == C_ENC_XMLgz:
 *             c_enc = osmfile.FileEncodingXMLgz()
 */
    __pyx_v_c_enc = Osmium::OSMFile::FileEncoding::XML();
    goto __pyx_L3;
  }

  /* "osmium/core.pyx":138
 *         elif newenc == C_ENC_XML:
 *             c_enc = osmfile.FileEncodingXML()
 *         elif newenc == C_ENC_XMLgz:             # <<<<<<<<<<<<<<
 *             c_enc = osmfile.FileEncodingXMLgz()
 *         elif newenc == C_ENC_XMLbz2:
 */
  __pyx_t_4 = (__pyx_v_newenc == __pyx_e_6osmium_4core_C_ENC_XMLgz);
  if (__pyx_t_4) {

    /* "osmium/core.pyx":139
 *             c_enc = osmfile.FileEncodingXML()
 *         elif newenc == C_ENC_XMLgz:
 *             c_enc = osmfile.FileEncodingXMLgz()             # <<<<<<<<<<<<<<
 *         elif newenc == C_ENC_XMLbz2:
 *             c_enc = osmfile.FileEncodingXMLbz2()
 */
    __pyx_v_c_enc = Osmium::OSMFile::FileEncoding::XMLgz();
    goto __pyx_L3;
  }

  /* "osmium/core.pyx":140
 *         elif newenc == C_ENC_XMLgz:
 *             c_enc = osmfile.FileEncodingXMLgz()
 *         elif newenc == C_ENC_XMLbz2:             # <<<<<<<<<<<<<<
 *             c_enc = osmfile.FileEncodingXMLbz2()
 *         else:
 */
  __pyx_t_4 = (__pyx_v_newenc == __pyx_e_6osmium_4core_C_ENC_XMLbz2);
  if (__pyx_t_4) {

    /* "osmium/core.pyx":141
 *             c_enc = osmfile.FileEncodingXMLgz()
 *         elif newenc == C_ENC_XMLbz2:
 *             c_enc = osmfile.FileEncodingXMLbz2()             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError("Unknown Filetype")
 */
    __pyx_v_c_enc = Osmium::OSMFile::FileEncoding::XMLbz2();
    goto __pyx_L3;
  }
  /*else*/ {

    /* "osmium/core.pyx":143
 *             c_enc = osmfile.FileEncodingXMLbz2()
 *         else:
 *             raise RuntimeError("Unknown Filetype")             # <<<<<<<<<<<<<<
 * 
 *         self.c_osmfile.set_encoding(c_enc)
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "osmium/core.pyx":145
 *             raise RuntimeError("Unknown Filetype")
 * 
 *         self.c_osmfile.set_encoding(c_enc)             # <<<<<<<<<<<<<<
 * 
 *     cpdef output.Base create_output_file(self):
 */
  __pyx_v_self->c_osmfile->set_encoding(__pyx_v_c_enc);

  __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("osmium.core.OSMFile.set_encoding", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":129
 *             raise RuntimeError("Unknown Filetype")
 * 
 *     cpdef set_encoding(self, FileEncoding newenc):             # <<<<<<<<<<<<<<
 *         u"""set_encoding(self, FileEncoding)
 *         """
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_11set_encoding(PyObject *__pyx_v_self, PyObject *__pyx_arg_newenc); /*proto*/
static char __pyx_doc_6osmium_4core_7OSMFile_11set_encoding[] = "set_encoding(self, FileEncoding)\n        ";
static PyObject *__pyx_pf_6osmium_4core_7OSMFile_11set_encoding(PyObject *__pyx_v_self, PyObject *__pyx_arg_newenc) {
  enum __pyx_t_6osmium_4core_FileEncoding __pyx_v_newenc;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_encoding");
  assert(__pyx_arg_newenc); {
    __pyx_v_newenc = ((enum __pyx_t_6osmium_4core_FileEncoding)PyInt_AsLong(__pyx_arg_newenc)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("osmium.core.OSMFile.set_encoding", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6osmium_4core_OSMFile *)((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->__pyx_vtab)->set_encoding(((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self), __pyx_v_newenc, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __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("osmium.core.OSMFile.set_encoding", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":147
 *         self.c_osmfile.set_encoding(c_enc)
 * 
 *     cpdef output.Base create_output_file(self):             # <<<<<<<<<<<<<<
 *         cdef output.Base res = output.Base.__new__(output.Base)
 *         res.c_output = self.c_osmfile.create_output_file()
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_12create_output_file(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_6osmium_6output_Base *__pyx_f_6osmium_4core_7OSMFile_create_output_file(struct __pyx_obj_6osmium_4core_OSMFile *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_6osmium_6output_Base *__pyx_v_res = 0;
  struct __pyx_obj_6osmium_6output_Base *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Osmium::Output::Base *__pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_output_file");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__create_output_file); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6osmium_4core_7OSMFile_12create_output_file)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __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 = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6osmium_6output_Base))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_6osmium_6output_Base *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "osmium/core.pyx":148
 * 
 *     cpdef output.Base create_output_file(self):
 *         cdef output.Base res = output.Base.__new__(output.Base)             # <<<<<<<<<<<<<<
 *         res.c_output = self.c_osmfile.create_output_file()
 *         if res.c_output is NULL:
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_6osmium_6output_Base)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6osmium_6output_Base)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_res = ((struct __pyx_obj_6osmium_6output_Base *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "osmium/core.pyx":149
 *     cpdef output.Base create_output_file(self):
 *         cdef output.Base res = output.Base.__new__(output.Base)
 *         res.c_output = self.c_osmfile.create_output_file()             # <<<<<<<<<<<<<<
 *         if res.c_output is NULL:
 *             return None
 */
  try {__pyx_t_3 = __pyx_v_self->c_osmfile->create_output_file();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
  __pyx_v_res->c_output = __pyx_t_3;

  /* "osmium/core.pyx":150
 *         cdef output.Base res = output.Base.__new__(output.Base)
 *         res.c_output = self.c_osmfile.create_output_file()
 *         if res.c_output is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         else:
 */
  __pyx_t_4 = (__pyx_v_res->c_output == NULL);
  if (__pyx_t_4) {

    /* "osmium/core.pyx":151
 *         res.c_output = self.c_osmfile.create_output_file()
 *         if res.c_output is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         else:
 *             return res
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(Py_None);
    __pyx_r = ((struct __pyx_obj_6osmium_6output_Base *)Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "osmium/core.pyx":153
 *             return None
 *         else:
 *             return res             # <<<<<<<<<<<<<<
 * 
 * cpdef set_debug(bool d):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_res));
    __pyx_r = __pyx_v_res;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = ((struct __pyx_obj_6osmium_6output_Base *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("osmium.core.OSMFile.create_output_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_res);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":147
 *         self.c_osmfile.set_encoding(c_enc)
 * 
 *     cpdef output.Base create_output_file(self):             # <<<<<<<<<<<<<<
 *         cdef output.Base res = output.Base.__new__(output.Base)
 *         res.c_output = self.c_osmfile.create_output_file()
 */

static PyObject *__pyx_pf_6osmium_4core_7OSMFile_12create_output_file(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6osmium_4core_7OSMFile_12create_output_file(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_output_file");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6osmium_4core_OSMFile *)((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self)->__pyx_vtab)->create_output_file(((struct __pyx_obj_6osmium_4core_OSMFile *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __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("osmium.core.OSMFile.create_output_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":155
 *             return res
 * 
 * cpdef set_debug(bool d):             # <<<<<<<<<<<<<<
 *     c_osmium.set_debug(d)
 * 
 */

static PyObject *__pyx_pf_6osmium_4core_set_debug(PyObject *__pyx_self, PyObject *__pyx_arg_d); /*proto*/
static PyObject *__pyx_f_6osmium_4core_set_debug(bool __pyx_v_d, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_debug");

  /* "osmium/core.pyx":156
 * 
 * cpdef set_debug(bool d):
 *     c_osmium.set_debug(d)             # <<<<<<<<<<<<<<
 * 
 * cpdef bool debug():
 */
  Osmium::set_debug(__pyx_v_d);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":155
 *             return res
 * 
 * cpdef set_debug(bool d):             # <<<<<<<<<<<<<<
 *     c_osmium.set_debug(d)
 * 
 */

static PyObject *__pyx_pf_6osmium_4core_set_debug(PyObject *__pyx_self, PyObject *__pyx_arg_d); /*proto*/
static PyObject *__pyx_pf_6osmium_4core_set_debug(PyObject *__pyx_self, PyObject *__pyx_arg_d) {
  bool __pyx_v_d;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_debug");
  __pyx_self = __pyx_self;
  assert(__pyx_arg_d); {
    __pyx_v_d = __Pyx_PyObject_IsTrue(__pyx_arg_d); if (unlikely((__pyx_v_d == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("osmium.core.set_debug", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6osmium_4core_set_debug(__pyx_v_d, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __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("osmium.core.set_debug", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":158
 *     c_osmium.set_debug(d)
 * 
 * cpdef bool debug():             # <<<<<<<<<<<<<<
 *     return c_osmium.debug()
 * 
 */

static PyObject *__pyx_pf_6osmium_4core_1debug(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static bool __pyx_f_6osmium_4core_debug(int __pyx_skip_dispatch) {
  bool __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("debug");

  /* "osmium/core.pyx":159
 * 
 * cpdef bool debug():
 *     return c_osmium.debug()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Osmium::debug();
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "osmium/core.pyx":158
 *     c_osmium.set_debug(d)
 * 
 * cpdef bool debug():             # <<<<<<<<<<<<<<
 *     return c_osmium.debug()
 * 
 */

static PyObject *__pyx_pf_6osmium_4core_1debug(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6osmium_4core_1debug(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("debug");
  __pyx_self = __pyx_self;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6osmium_4core_debug(0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __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("osmium.core.debug", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_6osmium_4core_OSMFile __pyx_vtable_6osmium_4core_OSMFile;

static PyObject *__pyx_tp_new_6osmium_4core_OSMFile(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6osmium_4core_OSMFile *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6osmium_4core_OSMFile *)o);
  p->__pyx_vtab = __pyx_vtabptr_6osmium_4core_OSMFile;
  if (__pyx_pf_6osmium_4core_7OSMFile___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6osmium_4core_OSMFile(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_6osmium_4core_7OSMFile_2__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_6osmium_4core_OSMFile[] = {
  {__Pyx_NAMESTR("copy"), (PyCFunction)__pyx_pf_6osmium_4core_7OSMFile_3copy, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6osmium_4core_7OSMFile_3copy)},
  {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pf_6osmium_4core_7OSMFile_4read, METH_O, __Pyx_DOCSTR(__pyx_doc_6osmium_4core_7OSMFile_4read)},
  {__Pyx_NAMESTR("set_type_and_encoding"), (PyCFunction)__pyx_pf_6osmium_4core_7OSMFile_5set_type_and_encoding, METH_O, __Pyx_DOCSTR(__pyx_doc_6osmium_4core_7OSMFile_5set_type_and_encoding)},
  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_6osmium_4core_7OSMFile_6close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6osmium_4core_7OSMFile_6close)},
  {__Pyx_NAMESTR("get_fd"), (PyCFunction)__pyx_pf_6osmium_4core_7OSMFile_7get_fd, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6osmium_4core_7OSMFile_7get_fd)},
  {__Pyx_NAMESTR("get_type"), (PyCFunction)__pyx_pf_6osmium_4core_7OSMFile_8get_type, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6osmium_4core_7OSMFile_8get_type)},
  {__Pyx_NAMESTR("set_type"), (PyCFunction)__pyx_pf_6osmium_4core_7OSMFile_9set_type, METH_O, __Pyx_DOCSTR(__pyx_doc_6osmium_4core_7OSMFile_9set_type)},
  {__Pyx_NAMESTR("get_encoding"), (PyCFunction)__pyx_pf_6osmium_4core_7OSMFile_10get_encoding, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6osmium_4core_7OSMFile_10get_encoding)},
  {__Pyx_NAMESTR("set_encoding"), (PyCFunction)__pyx_pf_6osmium_4core_7OSMFile_11set_encoding, METH_O, __Pyx_DOCSTR(__pyx_doc_6osmium_4core_7OSMFile_11set_encoding)},
  {__Pyx_NAMESTR("create_output_file"), (PyCFunction)__pyx_pf_6osmium_4core_7OSMFile_12create_output_file, METH_NOARGS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_OSMFile = {
  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_OSMFile = {
  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_OSMFile = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_OSMFile = {
  #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
};

static PyTypeObject __pyx_type_6osmium_4core_OSMFile = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("osmium.core.OSMFile"), /*tp_name*/
  sizeof(struct __pyx_obj_6osmium_4core_OSMFile), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6osmium_4core_OSMFile, /*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_OSMFile, /*tp_as_number*/
  &__pyx_tp_as_sequence_OSMFile, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_OSMFile, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_OSMFile, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("This class describes an OSM file in one of several formats.\n    It can be used as factory class for generating input and output OSM files.\n\n    If the filename is empty, this means stdin or stdout is used. If you set\n    the filename to \"-\" it will be treated the same.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6osmium_4core_OSMFile, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6osmium_4core_7OSMFile_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6osmium_4core_OSMFile, /*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("set_debug"), (PyCFunction)__pyx_pf_6osmium_4core_set_debug, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("debug"), (PyCFunction)__pyx_pf_6osmium_4core_1debug, METH_NOARGS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("core"),
    0, /* 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_b_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 0, 0},
  {&__pyx_n_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 1},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_n_s__ENC_PBF, __pyx_k__ENC_PBF, sizeof(__pyx_k__ENC_PBF), 0, 0, 1, 1},
  {&__pyx_n_s__ENC_XML, __pyx_k__ENC_XML, sizeof(__pyx_k__ENC_XML), 0, 0, 1, 1},
  {&__pyx_n_s__ENC_XMLbz2, __pyx_k__ENC_XMLbz2, sizeof(__pyx_k__ENC_XMLbz2), 0, 0, 1, 1},
  {&__pyx_n_s__ENC_XMLgz, __pyx_k__ENC_XMLgz, sizeof(__pyx_k__ENC_XMLgz), 0, 0, 1, 1},
  {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s__TYPE_CHANGE, __pyx_k__TYPE_CHANGE, sizeof(__pyx_k__TYPE_CHANGE), 0, 0, 1, 1},
  {&__pyx_n_s__TYPE_HISTORY, __pyx_k__TYPE_HISTORY, sizeof(__pyx_k__TYPE_HISTORY), 0, 0, 1, 1},
  {&__pyx_n_s__TYPE_OSM, __pyx_k__TYPE_OSM, sizeof(__pyx_k__TYPE_OSM), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1},
  {&__pyx_n_s__create_output_file, __pyx_k__create_output_file, sizeof(__pyx_k__create_output_file), 0, 0, 1, 1},
  {&__pyx_n_s__filename, __pyx_k__filename, sizeof(__pyx_k__filename), 0, 0, 1, 1},
  {&__pyx_n_s__get_encoding, __pyx_k__get_encoding, sizeof(__pyx_k__get_encoding), 0, 0, 1, 1},
  {&__pyx_n_s__get_fd, __pyx_k__get_fd, sizeof(__pyx_k__get_fd), 0, 0, 1, 1},
  {&__pyx_n_s__get_type, __pyx_k__get_type, sizeof(__pyx_k__get_type), 0, 0, 1, 1},
  {&__pyx_n_s__read, __pyx_k__read, sizeof(__pyx_k__read), 0, 0, 1, 1},
  {&__pyx_n_s__set_encoding, __pyx_k__set_encoding, sizeof(__pyx_k__set_encoding), 0, 0, 1, 1},
  {&__pyx_n_s__set_type, __pyx_k__set_type, sizeof(__pyx_k__set_type), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");

  /* "osmium/core.pyx":94
 *             return C_TYPE_CHANGE
 *         else:
 *             raise RuntimeError("Unknown Filetype")             # <<<<<<<<<<<<<<
 * 
 *     cpdef set_type(self, FileType newtype):
 */
  __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_4));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));

  /* "osmium/core.pyx":108
 *             c_ft = osmfile.FileTypeChange()
 *         else:
 *             raise RuntimeError("Unknown Filetype")             # <<<<<<<<<<<<<<
 * 
 *         self.c_osmfile.set_type(c_ft)
 */
  __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_5));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5));

  /* "osmium/core.pyx":127
 *             return C_ENC_XMLbz2
 *         else:
 *             raise RuntimeError("Unknown Filetype")             # <<<<<<<<<<<<<<
 * 
 *     cpdef set_encoding(self, FileEncoding newenc):
 */
  __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_6));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6));

  /* "osmium/core.pyx":143
 *             c_enc = osmfile.FileEncodingXMLbz2()
 *         else:
 *             raise RuntimeError("Unknown Filetype")             # <<<<<<<<<<<<<<
 * 
 *         self.c_osmfile.set_encoding(c_enc)
 */
  __pyx_k_tuple_7 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_7));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7));
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  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;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initcore(void); /*proto*/
PyMODINIT_FUNC initcore(void)
#else
PyMODINIT_FUNC PyInit_core(void); /*proto*/
PyMODINIT_FUNC PyInit_core(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __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");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_core(void)");
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __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("core"), __pyx_methods, 0, 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_osmium__core) {
    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;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("set_debug", (void (*)(void))__pyx_f_6osmium_4core_set_debug, "PyObject *(bool, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("debug", (void (*)(void))__pyx_f_6osmium_4core_debug, "bool (int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Type init code ---*/
  __pyx_vtabptr_6osmium_4core_OSMFile = &__pyx_vtable_6osmium_4core_OSMFile;
  __pyx_vtable_6osmium_4core_OSMFile.read = (PyObject *(*)(struct __pyx_obj_6osmium_4core_OSMFile *, struct osmhandler_struct *, int __pyx_skip_dispatch))__pyx_f_6osmium_4core_7OSMFile_read;
  __pyx_vtable_6osmium_4core_OSMFile.set_type_and_encoding = (PyObject *(*)(struct __pyx_obj_6osmium_4core_OSMFile *, char *, int __pyx_skip_dispatch))__pyx_f_6osmium_4core_7OSMFile_set_type_and_encoding;
  __pyx_vtable_6osmium_4core_OSMFile.close = (PyObject *(*)(struct __pyx_obj_6osmium_4core_OSMFile *, int __pyx_skip_dispatch))__pyx_f_6osmium_4core_7OSMFile_close;
  __pyx_vtable_6osmium_4core_OSMFile.get_fd = (int (*)(struct __pyx_obj_6osmium_4core_OSMFile *, int __pyx_skip_dispatch))__pyx_f_6osmium_4core_7OSMFile_get_fd;
  __pyx_vtable_6osmium_4core_OSMFile.get_type = (enum __pyx_t_6osmium_4core_FileType (*)(struct __pyx_obj_6osmium_4core_OSMFile *, int __pyx_skip_dispatch))__pyx_f_6osmium_4core_7OSMFile_get_type;
  __pyx_vtable_6osmium_4core_OSMFile.set_type = (PyObject *(*)(struct __pyx_obj_6osmium_4core_OSMFile *, enum __pyx_t_6osmium_4core_FileType, int __pyx_skip_dispatch))__pyx_f_6osmium_4core_7OSMFile_set_type;
  __pyx_vtable_6osmium_4core_OSMFile.get_encoding = (enum __pyx_t_6osmium_4core_FileEncoding (*)(struct __pyx_obj_6osmium_4core_OSMFile *, int __pyx_skip_dispatch))__pyx_f_6osmium_4core_7OSMFile_get_encoding;
  __pyx_vtable_6osmium_4core_OSMFile.set_encoding = (PyObject *(*)(struct __pyx_obj_6osmium_4core_OSMFile *, enum __pyx_t_6osmium_4core_FileEncoding, int __pyx_skip_dispatch))__pyx_f_6osmium_4core_7OSMFile_set_encoding;
  __pyx_vtable_6osmium_4core_OSMFile.create_output_file = (struct __pyx_obj_6osmium_6output_Base *(*)(struct __pyx_obj_6osmium_4core_OSMFile *, int __pyx_skip_dispatch))__pyx_f_6osmium_4core_7OSMFile_create_output_file;
  if (PyType_Ready(&__pyx_type_6osmium_4core_OSMFile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6osmium_4core_OSMFile, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_6osmium_4core_7OSMFile_1__init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_6osmium_4core_7OSMFile_1__init__.doc = __pyx_doc_6osmium_4core_7OSMFile_1__init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6osmium_4core_7OSMFile_1__init__;
    }
  }
  if (__Pyx_SetVtable(__pyx_type_6osmium_4core_OSMFile.tp_dict, __pyx_vtabptr_6osmium_4core_OSMFile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "OSMFile", (PyObject *)&__pyx_type_6osmium_4core_OSMFile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_4core_OSMFile = &__pyx_type_6osmium_4core_OSMFile;
  /*--- Type import code ---*/
  __pyx_ptype_6osmium_3osm_TagList = __Pyx_ImportType("osmium.osm", "TagList", sizeof(struct __pyx_obj_6osmium_3osm_TagList), 1); if (unlikely(!__pyx_ptype_6osmium_3osm_TagList)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_3osm_WayNodeList = __Pyx_ImportType("osmium.osm", "WayNodeList", sizeof(struct __pyx_obj_6osmium_3osm_WayNodeList), 1); if (unlikely(!__pyx_ptype_6osmium_3osm_WayNodeList)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_3osm_RelationMemberList = __Pyx_ImportType("osmium.osm", "RelationMemberList", sizeof(struct __pyx_obj_6osmium_3osm_RelationMemberList), 1); if (unlikely(!__pyx_ptype_6osmium_3osm_RelationMemberList)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_3osm_Object = __Pyx_ImportType("osmium.osm", "Object", sizeof(struct __pyx_obj_6osmium_3osm_Object), 1); if (unlikely(!__pyx_ptype_6osmium_3osm_Object)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_3osm_Node = __Pyx_ImportType("osmium.osm", "Node", sizeof(struct __pyx_obj_6osmium_3osm_Node), 1); if (unlikely(!__pyx_ptype_6osmium_3osm_Node)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_3osm_Way = __Pyx_ImportType("osmium.osm", "Way", sizeof(struct __pyx_obj_6osmium_3osm_Way), 1); if (unlikely(!__pyx_ptype_6osmium_3osm_Way)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_3osm_Relation = __Pyx_ImportType("osmium.osm", "Relation", sizeof(struct __pyx_obj_6osmium_3osm_Relation), 1); if (unlikely(!__pyx_ptype_6osmium_3osm_Relation)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_3osm_Bounds = __Pyx_ImportType("osmium.osm", "Bounds", sizeof(struct __pyx_obj_6osmium_3osm_Bounds), 1); if (unlikely(!__pyx_ptype_6osmium_3osm_Bounds)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_3osm_Meta = __Pyx_ImportType("osmium.osm", "Meta", sizeof(struct __pyx_obj_6osmium_3osm_Meta), 1); if (unlikely(!__pyx_ptype_6osmium_3osm_Meta)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6osmium_3osm_Meta = (struct __pyx_vtabstruct_6osmium_3osm_Meta*)__Pyx_GetVtable(__pyx_ptype_6osmium_3osm_Meta->tp_dict); if (unlikely(!__pyx_vtabptr_6osmium_3osm_Meta)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_7handler_Exception = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "Exception", sizeof(PyBaseExceptionObject), 0); if (unlikely(!__pyx_ptype_6osmium_7handler_Exception)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_7handler_StopReading = __Pyx_ImportType("osmium.handler", "StopReading", sizeof(struct StopReading_struct), 1); if (unlikely(!__pyx_ptype_6osmium_7handler_StopReading)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_7handler_Base = __Pyx_ImportType("osmium.handler", "Base", sizeof(struct osmhandler_struct), 1); if (unlikely(!__pyx_ptype_6osmium_7handler_Base)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6osmium_7handler_Base = (struct __pyx_vtabstruct_6osmium_7handler_Base*)__Pyx_GetVtable(__pyx_ptype_6osmium_7handler_Base->tp_dict); if (unlikely(!__pyx_vtabptr_6osmium_7handler_Base)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_7handler_Debug = __Pyx_ImportType("osmium.handler", "Debug", sizeof(struct __pyx_obj_6osmium_7handler_Debug), 1); if (unlikely(!__pyx_ptype_6osmium_7handler_Debug)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6osmium_7handler_Debug = (struct __pyx_vtabstruct_6osmium_7handler_Debug*)__Pyx_GetVtable(__pyx_ptype_6osmium_7handler_Debug->tp_dict); if (unlikely(!__pyx_vtabptr_6osmium_7handler_Debug)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_7handler_Progress = __Pyx_ImportType("osmium.handler", "Progress", sizeof(struct __pyx_obj_6osmium_7handler_Progress), 1); if (unlikely(!__pyx_ptype_6osmium_7handler_Progress)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6osmium_7handler_Progress = (struct __pyx_vtabstruct_6osmium_7handler_Progress*)__Pyx_GetVtable(__pyx_ptype_6osmium_7handler_Progress->tp_dict); if (unlikely(!__pyx_vtabptr_6osmium_7handler_Progress)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_7handler_Tee = __Pyx_ImportType("osmium.handler", "Tee", sizeof(struct __pyx_obj_6osmium_7handler_Tee), 1); if (unlikely(!__pyx_ptype_6osmium_7handler_Tee)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6osmium_7handler_Tee = (struct __pyx_vtabstruct_6osmium_7handler_Tee*)__Pyx_GetVtable(__pyx_ptype_6osmium_7handler_Tee->tp_dict); if (unlikely(!__pyx_vtabptr_6osmium_7handler_Tee)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_7handler_Forward = __Pyx_ImportType("osmium.handler", "Forward", sizeof(struct __pyx_obj_6osmium_7handler_Forward), 1); if (unlikely(!__pyx_ptype_6osmium_7handler_Forward)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6osmium_7handler_Forward = (struct __pyx_vtabstruct_6osmium_7handler_Forward*)__Pyx_GetVtable(__pyx_ptype_6osmium_7handler_Forward->tp_dict); if (unlikely(!__pyx_vtabptr_6osmium_7handler_Forward)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6osmium_6output_Base = __Pyx_ImportType("osmium.output", "Base", sizeof(struct __pyx_obj_6osmium_6output_Base), 1); if (unlikely(!__pyx_ptype_6osmium_6output_Base)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6osmium_6output_Base = (struct __pyx_vtabstruct_6osmium_6output_Base*)__Pyx_GetVtable(__pyx_ptype_6osmium_6output_Base->tp_dict); if (unlikely(!__pyx_vtabptr_6osmium_6output_Base)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("osmium.osm"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_cache_node", (void **)&__pyx_vp_6osmium_3osm__cache_node, "struct __pyx_obj_6osmium_3osm_Node *") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_cache_way", (void **)&__pyx_vp_6osmium_3osm__cache_way, "struct __pyx_obj_6osmium_3osm_Way *") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_cache_relation", (void **)&__pyx_vp_6osmium_3osm__cache_relation, "struct __pyx_obj_6osmium_3osm_Relation *") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_cache_taglist", (void **)&__pyx_vp_6osmium_3osm__cache_taglist, "struct __pyx_obj_6osmium_3osm_TagList *") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_cache_waynodelist", (void **)&__pyx_vp_6osmium_3osm__cache_waynodelist, "struct __pyx_obj_6osmium_3osm_WayNodeList *") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_cache_relationmemberlist", (void **)&__pyx_vp_6osmium_3osm__cache_relationmemberlist, "struct __pyx_obj_6osmium_3osm_RelationMemberList *") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "osmium/core.pyx":18
 * 
 *     # Define constants for FileType and FileEncoding
 *     TYPE_OSM = C_TYPE_OSM             # <<<<<<<<<<<<<<
 *     TYPE_HISTORY = C_TYPE_HISTORY
 *     TYPE_CHANGE = C_TYPE_CHANGE
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_e_6osmium_4core_C_TYPE_OSM); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6osmium_4core_OSMFile->tp_dict, __pyx_n_s__TYPE_OSM, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_6osmium_4core_OSMFile);

  /* "osmium/core.pyx":19
 *     # Define constants for FileType and FileEncoding
 *     TYPE_OSM = C_TYPE_OSM
 *     TYPE_HISTORY = C_TYPE_HISTORY             # <<<<<<<<<<<<<<
 *     TYPE_CHANGE = C_TYPE_CHANGE
 * 
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_e_6osmium_4core_C_TYPE_HISTORY); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6osmium_4core_OSMFile->tp_dict, __pyx_n_s__TYPE_HISTORY, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_6osmium_4core_OSMFile);

  /* "osmium/core.pyx":20
 *     TYPE_OSM = C_TYPE_OSM
 *     TYPE_HISTORY = C_TYPE_HISTORY
 *     TYPE_CHANGE = C_TYPE_CHANGE             # <<<<<<<<<<<<<<
 * 
 *     ENC_PBF=C_ENC_PBF
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_e_6osmium_4core_C_TYPE_CHANGE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6osmium_4core_OSMFile->tp_dict, __pyx_n_s__TYPE_CHANGE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_6osmium_4core_OSMFile);

  /* "osmium/core.pyx":22
 *     TYPE_CHANGE = C_TYPE_CHANGE
 * 
 *     ENC_PBF=C_ENC_PBF             # <<<<<<<<<<<<<<
 *     ENC_XML=C_ENC_XML
 *     ENC_XMLgz=C_ENC_XMLgz
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_e_6osmium_4core_C_ENC_PBF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6osmium_4core_OSMFile->tp_dict, __pyx_n_s__ENC_PBF, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_6osmium_4core_OSMFile);

  /* "osmium/core.pyx":23
 * 
 *     ENC_PBF=C_ENC_PBF
 *     ENC_XML=C_ENC_XML             # <<<<<<<<<<<<<<
 *     ENC_XMLgz=C_ENC_XMLgz
 *     ENC_XMLbz2=C_ENC_XMLbz2
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_e_6osmium_4core_C_ENC_XML); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6osmium_4core_OSMFile->tp_dict, __pyx_n_s__ENC_XML, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_6osmium_4core_OSMFile);

  /* "osmium/core.pyx":24
 *     ENC_PBF=C_ENC_PBF
 *     ENC_XML=C_ENC_XML
 *     ENC_XMLgz=C_ENC_XMLgz             # <<<<<<<<<<<<<<
 *     ENC_XMLbz2=C_ENC_XMLbz2
 * 
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_e_6osmium_4core_C_ENC_XMLgz); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6osmium_4core_OSMFile->tp_dict, __pyx_n_s__ENC_XMLgz, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_6osmium_4core_OSMFile);

  /* "osmium/core.pyx":25
 *     ENC_XML=C_ENC_XML
 *     ENC_XMLgz=C_ENC_XMLgz
 *     ENC_XMLbz2=C_ENC_XMLbz2             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self, filename=b""):
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_e_6osmium_4core_C_ENC_XMLbz2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6osmium_4core_OSMFile->tp_dict, __pyx_n_s__ENC_XMLbz2, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_6osmium_4core_OSMFile);

  /* "osmium/core.pyx":163
 * 
 * # Initialization code
 * c_osmium.init(True)             # <<<<<<<<<<<<<<
 */
  Osmium::init(1);

  /* "osmium/core.pyx":1
 * from libcpp.string cimport string             # <<<<<<<<<<<<<<
 * 
 * cimport c_osmium
 */
  __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));
  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_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    __Pyx_AddTraceback("init osmium.core", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init osmium.core");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */

#if CYTHON_REFNANNY
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;
}
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result) {
        if (dict != __pyx_b) {
            PyErr_Clear();
            result = PyObject_GetAttr(__pyx_b, 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 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 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 *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";
    }
    PyErr_Format(PyExc_TypeError,
                 "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

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


#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    /* cause is unused */
    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, PyObject *cause) {
    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;
    }

    if (cause) {
        PyObject *fixed_cause;
        if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        }
        else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        }
        else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        if (!value) {
            value = PyObject_CallObject(type, NULL);
        }
        PyException_SetCause(value, fixed_cause);
    }

    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 int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

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 (unsigned long)PyLong_AsUnsignedLong(x);
        } else {
            return (unsigned long)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 (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (unsigned PY_LONG_LONG)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 (long)PyLong_AsUnsignedLong(x);
        } else {
            return (long)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 (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (PY_LONG_LONG)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 (signed long)PyLong_AsUnsignedLong(x);
        } else {
            return (signed long)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 (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (signed PY_LONG_LONG)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_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;

    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

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,
    size_t 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 > (Py_ssize_t)size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        if (PyErr_Warn(NULL, warning) < 0) goto bad;
        #else
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
        #endif
    }
    else if (((PyTypeObject *)result)->tp_basicsize != (Py_ssize_t)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 NULL;
}
#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

static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

#ifndef __PYX_HAVE_RT_ImportVoidPtr
#define __PYX_HAVE_RT_ImportVoidPtr
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;

    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, name);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%s does not export expected C variable %s",
                PyModule_GetName(module), name);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C variable %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    *p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C variable %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), name, sig, desc);
        goto bad;
    }
    *p = PyCObject_AsVoidPtr(cobj);}
#endif
    if (!(*p))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

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

static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
                               int __pyx_lineno, const char *__pyx_filename) {
    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 */
