/* Generated by Cython 0.12.1 on Sat Jul  3 12:18:09 2010 */

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

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#endif

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

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

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

#endif

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

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

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

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyString_Type                PyUnicode_Type
  #define PyString_CheckExact          PyUnicode_CheckExact
#else
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_CheckExact           PyString_CheckExact
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)

#endif

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

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

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

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#define __PYX_HAVE_API__gevent__core
#include "libevent-internal.h"
#include "sys/types.h"
#include "frameobject.h"
#include "libevent.h"
#include "string.h"
#include "errno.h"

#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #else
    #define CYTHON_INLINE 
  #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 */

#if PY_MAJOR_VERSION < 3
#define __Pyx_PyBytes_FromString          PyString_FromString
#define __Pyx_PyBytes_FromStringAndSize   PyString_FromStringAndSize
#define __Pyx_PyBytes_AsString            PyString_AsString
#else
#define __Pyx_PyBytes_FromString          PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize   PyBytes_FromStringAndSize
#define __Pyx_PyBytes_AsString            PyBytes_AsString
#endif

#define __Pyx_PyBytes_FromUString(s)      __Pyx_PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)        ((unsigned char*) __Pyx_PyBytes_AsString(s))

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

#if !defined(T_PYSSIZET)
#if PY_VERSION_HEX < 0x02050000
#define T_PYSSIZET T_INT
#elif !defined(T_LONGLONG)
#define T_PYSSIZET \
        ((sizeof(Py_ssize_t) == sizeof(int))  ? T_INT  : \
        ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
#else
#define T_PYSSIZET \
        ((sizeof(Py_ssize_t) == sizeof(int))          ? T_INT      : \
        ((sizeof(Py_ssize_t) == sizeof(long))         ? T_LONG     : \
        ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))
#endif
#endif


#if !defined(T_ULONGLONG)
#define __Pyx_T_UNSIGNED_INT(x) \
        ((sizeof(x) == sizeof(unsigned char))  ? T_UBYTE : \
        ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \
        ((sizeof(x) == sizeof(unsigned int))   ? T_UINT : \
        ((sizeof(x) == sizeof(unsigned long))  ? T_ULONG : -1))))
#else
#define __Pyx_T_UNSIGNED_INT(x) \
        ((sizeof(x) == sizeof(unsigned char))  ? T_UBYTE : \
        ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \
        ((sizeof(x) == sizeof(unsigned int))   ? T_UINT : \
        ((sizeof(x) == sizeof(unsigned long))  ? T_ULONG : \
        ((sizeof(x) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))))
#endif
#if !defined(T_LONGLONG)
#define __Pyx_T_SIGNED_INT(x) \
        ((sizeof(x) == sizeof(char))  ? T_BYTE : \
        ((sizeof(x) == sizeof(short)) ? T_SHORT : \
        ((sizeof(x) == sizeof(int))   ? T_INT : \
        ((sizeof(x) == sizeof(long))  ? T_LONG : -1))))
#else
#define __Pyx_T_SIGNED_INT(x) \
        ((sizeof(x) == sizeof(char))  ? T_BYTE : \
        ((sizeof(x) == sizeof(short)) ? T_SHORT : \
        ((sizeof(x) == sizeof(int))   ? T_INT : \
        ((sizeof(x) == sizeof(long))  ? T_LONG : \
        ((sizeof(x) == sizeof(PY_LONG_LONG))   ? T_LONGLONG : -1)))))
#endif

#define __Pyx_T_FLOATING(x) \
        ((sizeof(x) == sizeof(float)) ? T_FLOAT : \
        ((sizeof(x) == sizeof(double)) ? T_DOUBLE : -1))

#if !defined(T_SIZET)
#if !defined(T_ULONGLONG)
#define T_SIZET \
        ((sizeof(size_t) == sizeof(unsigned int))  ? T_UINT  : \
        ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
#else
#define T_SIZET \
        ((sizeof(size_t) == sizeof(unsigned int))          ? T_UINT      : \
        ((sizeof(size_t) == sizeof(unsigned long))         ? T_ULONG     : \
        ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))
#endif
#endif

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;


/* Type declarations */

typedef void (*__pyx_t_6gevent_4core_event_handler)(int, short, void *);

typedef void *__pyx_t_6gevent_4core_event_base;

/* "/home/denis/work/gevent/gevent/core.pyx":165
 * 
 * 
 * cdef class event:             # <<<<<<<<<<<<<<
 *     """Create a new event object with a user callback.
 * 
 */

struct __pyx_obj_6gevent_4core_event {
  PyObject_HEAD
  struct __pyx_vtabstruct_6gevent_4core_event *__pyx_vtab;
  struct event ev;
  PyObject *_callback;
  PyObject *_arg;
  int _incref;
};

/* "/home/denis/work/gevent/gevent/core.pyx":413
 * 
 * 
 * cdef class active_event(event):             # <<<<<<<<<<<<<<
 *     """An event that is scheduled to run in the current loop iteration"""
 * 
 */

struct __pyx_obj_6gevent_4core_active_event {
  struct __pyx_obj_6gevent_4core_event __pyx_base;
};

/* "/home/denis/work/gevent/gevent/evhttp.pxi":106
 * 
 * 
 * cdef class http_request:             # <<<<<<<<<<<<<<
 *     """Wrapper around libevent's :class:`evhttp_request` structure."""
 * 
 */

struct __pyx_obj_6gevent_4core_http_request {
  PyObject_HEAD
  PyObject *__weakref__;
  struct evhttp_request *__pyx___obj;
  PyObject *_input_buffer;
  PyObject *_output_buffer;
  PyObject *default_response_headers;
};

/* "/home/denis/work/gevent/gevent/core.pyx":343
 * 
 * 
 * cdef class read_event(event):             # <<<<<<<<<<<<<<
 *     """Create a new scheduled event with evtype=EV_READ"""
 * 
 */

struct __pyx_obj_6gevent_4core_read_event {
  struct __pyx_obj_6gevent_4core_event __pyx_base;
};

/* "/home/denis/work/gevent/gevent/evhttp.pxi":415
 * 
 * 
 * cdef class http_connection:             # <<<<<<<<<<<<<<
 * 
 *     cdef evhttp_connection* __obj
 */

struct __pyx_obj_6gevent_4core_http_connection {
  PyObject_HEAD
  struct evhttp_connection *__pyx___obj;
};

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":20
 * 
 * 
 * cdef class buffer:             # <<<<<<<<<<<<<<
 *     """file-like wrapper for libevent's :class:`evbuffer` structure.
 * 
 */

struct __pyx_obj_6gevent_4core_buffer {
  PyObject_HEAD
  struct evbuffer *__pyx___obj;
};

/* "/home/denis/work/gevent/gevent/core.pyx":403
 * 
 * 
 * cdef class signal(event):             # <<<<<<<<<<<<<<
 *     """Create a new persistent signal event"""
 * 
 */

struct __pyx_obj_6gevent_4core_signal {
  struct __pyx_obj_6gevent_4core_event __pyx_base;
};

/* "/home/denis/work/gevent/gevent/core.pyx":393
 * 
 * 
 * cdef class timer(event):             # <<<<<<<<<<<<<<
 *     """Create a new scheduled timer"""
 * 
 */

struct __pyx_obj_6gevent_4core_timer {
  struct __pyx_obj_6gevent_4core_event __pyx_base;
};

/* "/home/denis/work/gevent/gevent/core.pyx":354
 * 
 * 
 * cdef class write_event(event):             # <<<<<<<<<<<<<<
 *     """Create a new scheduled event with evtype=EV_WRITE"""
 * 
 */

struct __pyx_obj_6gevent_4core_write_event {
  struct __pyx_obj_6gevent_4core_event __pyx_base;
};

/* "/home/denis/work/gevent/gevent/evhttp.pxi":508
 * 
 * 
 * cdef class http:             # <<<<<<<<<<<<<<
 *     cdef evhttp* __obj
 *     cdef public object handle
 */

struct __pyx_obj_6gevent_4core_http {
  PyObject_HEAD
  struct evhttp *__pyx___obj;
  PyObject *handle;
  PyObject *default_response_headers;
  PyObject *_requests;
};


/* "/home/denis/work/gevent/gevent/core.pyx":165
 * 
 * 
 * cdef class event:             # <<<<<<<<<<<<<<
 *     """Create a new event object with a user callback.
 * 
 */

struct __pyx_vtabstruct_6gevent_4core_event {
  PyObject *(*_addref)(struct __pyx_obj_6gevent_4core_event *);
  PyObject *(*_delref)(struct __pyx_obj_6gevent_4core_event *);
};
static struct __pyx_vtabstruct_6gevent_4core_event *__pyx_vtabptr_6gevent_4core_event;


/* "/home/denis/work/gevent/gevent/core.pyx":343
 * 
 * 
 * cdef class read_event(event):             # <<<<<<<<<<<<<<
 *     """Create a new scheduled event with evtype=EV_READ"""
 * 
 */

struct __pyx_vtabstruct_6gevent_4core_read_event {
  struct __pyx_vtabstruct_6gevent_4core_event __pyx_base;
};
static struct __pyx_vtabstruct_6gevent_4core_read_event *__pyx_vtabptr_6gevent_4core_read_event;


/* "/home/denis/work/gevent/gevent/core.pyx":413
 * 
 * 
 * cdef class active_event(event):             # <<<<<<<<<<<<<<
 *     """An event that is scheduled to run in the current loop iteration"""
 * 
 */

struct __pyx_vtabstruct_6gevent_4core_active_event {
  struct __pyx_vtabstruct_6gevent_4core_event __pyx_base;
};
static struct __pyx_vtabstruct_6gevent_4core_active_event *__pyx_vtabptr_6gevent_4core_active_event;


/* "/home/denis/work/gevent/gevent/core.pyx":354
 * 
 * 
 * cdef class write_event(event):             # <<<<<<<<<<<<<<
 *     """Create a new scheduled event with evtype=EV_WRITE"""
 * 
 */

struct __pyx_vtabstruct_6gevent_4core_write_event {
  struct __pyx_vtabstruct_6gevent_4core_event __pyx_base;
};
static struct __pyx_vtabstruct_6gevent_4core_write_event *__pyx_vtabptr_6gevent_4core_write_event;


/* "/home/denis/work/gevent/gevent/core.pyx":393
 * 
 * 
 * cdef class timer(event):             # <<<<<<<<<<<<<<
 *     """Create a new scheduled timer"""
 * 
 */

struct __pyx_vtabstruct_6gevent_4core_timer {
  struct __pyx_vtabstruct_6gevent_4core_event __pyx_base;
};
static struct __pyx_vtabstruct_6gevent_4core_timer *__pyx_vtabptr_6gevent_4core_timer;


/* "/home/denis/work/gevent/gevent/core.pyx":403
 * 
 * 
 * cdef class signal(event):             # <<<<<<<<<<<<<<
 *     """Create a new persistent signal event"""
 * 
 */

struct __pyx_vtabstruct_6gevent_4core_signal {
  struct __pyx_vtabstruct_6gevent_4core_event __pyx_base;
};
static struct __pyx_vtabstruct_6gevent_4core_signal *__pyx_vtabptr_6gevent_4core_signal;

#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif

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

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*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_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

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

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

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void);

static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
static int __Pyx_EndUnpack(PyObject *); /*proto*/

static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (PyList_Append(L, x) < 0) return NULL;
        Py_INCREF(Py_None);
        return Py_None; /* this is just to have an accurate signature */
    }
    else {
        PyObject *r, *m;
        m = __Pyx_GetAttrString(L, "append");
        if (!m) return NULL;
        r = PyObject_CallFunctionObjArgs(m, x, NULL);
        Py_DECREF(m);
        return r;
    }
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
    const char* function_name, int kw_allowed); /*proto*/

static PyObject* __Pyx_PyEval_CallObjectWithKeywords(PyObject*, PyObject*, PyObject*); /*proto*/

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

#define __Pyx_SetItemInt(o, i, v, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_SetItemInt_Fast(o, i, v, size <= sizeof(long)) : \
                                                    __Pyx_SetItemInt_Generic(o, to_py_func(i), v))

static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}

static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int fits_long) {
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        Py_INCREF(v);
        Py_DECREF(PyList_GET_ITEM(o, i));
        PyList_SET_ITEM(o, i, v);
        return 1;
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && (likely(i >= 0)))
        return PySequence_SetItem(o, i, v);
    else {
        PyObject *j = fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i);
        return __Pyx_SetItemInt_Generic(o, j, v);
    }
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

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

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

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

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

#ifndef __PYX_FORCE_INIT_THREADS
  #if PY_VERSION_HEX < 0x02040200
    #define __PYX_FORCE_INIT_THREADS 1
  #else
    #define __PYX_FORCE_INIT_THREADS 0
  #endif
#endif

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_ev_uint16_t(ev_uint16_t);

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 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 void __Pyx_WriteUnraisable(const char *name); /*proto*/

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

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

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from gevent.core */

static PyTypeObject *__pyx_ptype_6gevent_4core_event = 0;
static PyTypeObject *__pyx_ptype_6gevent_4core_read_event = 0;
static PyTypeObject *__pyx_ptype_6gevent_4core_write_event = 0;
static PyTypeObject *__pyx_ptype_6gevent_4core_timer = 0;
static PyTypeObject *__pyx_ptype_6gevent_4core_signal = 0;
static PyTypeObject *__pyx_ptype_6gevent_4core_active_event = 0;
static PyTypeObject *__pyx_ptype_6gevent_4core_buffer = 0;
static PyTypeObject *__pyx_ptype_6gevent_4core_http_request = 0;
static PyTypeObject *__pyx_ptype_6gevent_4core_http_connection = 0;
static PyTypeObject *__pyx_ptype_6gevent_4core_http = 0;
static void __pyx_f_6gevent_4core___event_handler(int, short, void *); /*proto*/
static void __pyx_f_6gevent_4core___simple_handler(int, short, void *); /*proto*/
static void __pyx_f_6gevent_4core___evdns_callback(int, char, int, int, void *, void *); /*proto*/
static void __pyx_f_6gevent_4core__http_cb_handler(struct evhttp_request *, void *); /*proto*/
static void __pyx_f_6gevent_4core__http_closecb_handler(struct evhttp_connection *, void *); /*proto*/
static void __pyx_f_6gevent_4core__http_cb_reply_error(struct evhttp_request *, void *); /*proto*/
static void __pyx_f_6gevent_4core_report_internal_error(struct evhttp_request *); /*proto*/
#define __Pyx_MODULE_NAME "gevent.core"
int __pyx_module_is_main_gevent__core = 0;

/* Implementation of gevent.core */
static PyObject *__pyx_builtin_UserWarning;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_hex;
static PyObject *__pyx_builtin_DeprecationWarning;
static PyObject *__pyx_builtin_IOError;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_min;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_RuntimeError;
static char __pyx_k_1[] = "Failed to execute callback for %s\n\n";
static char __pyx_k_2[] = "|";
static char __pyx_k_3[] = "Negative timeouts are deprecated. Use None to disable timeout.";
static char __pyx_k_4[] = "event_add(fileno=%s) returned %s";
static char __pyx_k_5[] = " pending";
static char __pyx_k_6[] = "";
static char __pyx_k_7[] = " %s";
static char __pyx_k_8[] = "<%s at %s%s fd=%s%s flags=%s cb=%s arg=%s>";
static char __pyx_k_9[] = "\n";
static char __pyx_k_10[] = " ";
static char __pyx_k_11[] = "%s%s fd=%s%s flags=%s\n  cb  = %s\n  arg = %s";
static char __pyx_k_16[] = "evdns_resolve_ipv4(%r, %r) returned %s";
static char __pyx_k_17[] = "evdns_resolve_ip6(%r, %r) returned %s";
static char __pyx_k_18[] = "evdns_resolve_reverse(%r, %r) returned %s";
static char __pyx_k_19[] = "evdns_resolve_reverse_ipv6(%r, %r) returned %s";
static char __pyx_k_20[] = "evbuffer_drain(0x%x, %s) returned %s\n";
static char __pyx_k_21[] = "default_response_headers";
static char __pyx_k_22[] = "\"%s %s HTTP/%s.%s\" %s:%s";
static char __pyx_k_23[] = " response=%s";
static char __pyx_k_24[] = " input=%s";
static char __pyx_k_25[] = " output=%s";
static char __pyx_k_26[] = "<Error>";
static char __pyx_k_27[] = "<%s %s>";
static char __pyx_k_28[] = "<%s _obj=0x%x %s>";
static char __pyx_k_29[] = "_add_default_response_headers";
static char __pyx_k_30[] = "Expected str or buffer: %r";
static char __pyx_k_31[] = "Internal error in evhttp_add_header";
static char __pyx_k_32[] = "HttpConnectionDeleted";
static char __pyx_k_33[] = "<%s _obj=0x%x%s>";
static char __pyx_k_34[] = "%s: Failed to handle request: %s\n\n";
static char __pyx_k_35[] = "Content-type";
static char __pyx_k_36[] = "text/plain";
static char __pyx_k_37[] = "Content-length";
static char __pyx_k_38[] = "Internal Server Error";
static char __pyx_k_39[] = "127.0.0.1";
static char __pyx_k_40[] = "evhttp_bind_socket(%r, %r) returned %r";
static char __pyx_k_41[] = "evhttp_accept_socket(%r) returned %r";
static char __pyx_k_42[] = "User callback that will be called once the event is signalled.\n\n        The prototype: ``callback(event instance, evtype)``.\n        ";
static char __pyx_k_43[] = "Optional object set and read only by the user.";
static char __pyx_k_44[] = "Return True if the event is still scheduled to run.";
static char __pyx_k_45[] = "Wrappers around libevent API.\n\nThis module provides a mechanism to execute a function when a\nspecific event on a file handle, file descriptor, or signal occurs,\nor after a given time has passed. It also provides wrappers around\nstructures and functions from libevent-dns and libevent-http.\n\nThis module does not work with the greenlets. A callback passed\nto a method from this module will be executed in the event loop,\nwhich is running in the :class:`Hub <gevent.hub.Hub>` greenlet.\nTherefore it must not use any synchronous gevent API,\nthat is, the functions that switch to the Hub. It's OK to call asynchronous\nstuff like :func:`gevent.spawn`, :meth:`Event.set <gevent.event.Event.set` or\n:meth:`Queue.put_nowait <gevent.queue.Queue.put_nowait>`.\n\nThe code is based on pyevent_.\n\n.. _pyevent: http://code.google.com/p/pyevent/\n";
static char __pyx_k_46[] = "Dug Song <dugsong@monkey.org>";
static char __pyx_k_47[] = "Martin Murray <mmurray@monkey.org>";
static char __pyx_k_48[] = "Copyright (c) 2004 Dug Song";
static char __pyx_k_49[] = "Copyright (c) 2003 Martin Murray";
static char __pyx_k_50[] = "http://monkey.org/~dugsong/pyevent/";
static char __pyx_k_51[] = "0.4+";
static char __pyx_k_52[] = "Create a new scheduled event with evtype=EV_READ|EV_WRITE";
static char __pyx_k_53[] = "dns_resolve_reverse_ipv6";
static char __pyx_k_54[] = "DNS_ERR_SERVERFAILED";
static char __pyx_k_55[] = "1.3.99-trunk";
static char __pyx_k_56[] = "libevent version mismatch: system version is %r but this gevent is compiled against %r";
static char __pyx_k_57[] = "Raised when an attribute is accessed of http_request instance whose _obj is 0";
static char __pyx_k_58[] = "Raised when an attribute is accessed of http_connection instance whose _obj is 0";
static char __pyx_k_59[] = "event.add (line 273)";
static char __pyx_k_60[] = "event.cancel (line 300)";
static char __pyx_k_61[] = "init (line 427)";
static char __pyx_k_62[] = "dispatch (line 432)";
static char __pyx_k_63[] = "loop (line 445)";
static char __pyx_k_64[] = "get_version (line 461)";
static char __pyx_k_65[] = "get_method (line 466)";
static char __pyx_k_66[] = "get_header_version (line 479)";
static char __pyx_k_67[] = "reinit (line 490)";
static char __pyx_k_68[] = "dns_init (line 40)";
static char __pyx_k_69[] = "dns_shutdown (line 45)";
static char __pyx_k_70[] = "dns_resolve_ipv4 (line 84)";
static char __pyx_k_71[] = "dns_resolve_ipv6 (line 97)";
static char __pyx_k_72[] = "dns_resolve_reverse (line 110)";
static char __pyx_k_73[] = "dns_resolve_reverse_ipv6 (line 123)";
static char __pyx_k_74[] = "buffer.read (line 57)";
static char __pyx_k_75[] = "http_request.remove_input_header (line 392)";
static char __pyx_k_76[] = "http_request.remove_output_header (line 398)";
static char __pyx_k_77[] = "remove_output_header";
static char __pyx_k__21[] = "21";
static char __pyx_k__ev[] = "ev";
static char __pyx_k__fd[] = "fd";
static char __pyx_k__id[] = "id";
static char __pyx_k__tb[] = "tb";
static char __pyx_k__BSD[] = "BSD";
static char __pyx_k__GET[] = "GET";
static char __pyx_k__PUT[] = "PUT";
static char __pyx_k__add[] = "add";
static char __pyx_k__arg[] = "arg";
static char __pyx_k__buf[] = "buf";
static char __pyx_k__get[] = "get";
static char __pyx_k__hex[] = "hex";
static char __pyx_k__key[] = "key";
static char __pyx_k__min[] = "min";
static char __pyx_k__msg[] = "msg";
static char __pyx_k__pop[] = "pop";
static char __pyx_k__sys[] = "sys";
static char __pyx_k__typ[] = "typ";
static char __pyx_k__uri[] = "uri";
static char __pyx_k__HEAD[] = "HEAD";
static char __pyx_k__INIT[] = "INIT";
static char __pyx_k__POST[] = "POST";
static char __pyx_k__READ[] = "READ";
static char __pyx_k___arg[] = "_arg";
static char __pyx_k___obj[] = "_obj";
static char __pyx_k__code[] = "code";
static char __pyx_k__hint[] = "hint";
static char __pyx_k__http[] = "http";
static char __pyx_k__init[] = "init";
static char __pyx_k__join[] = "join";
static char __pyx_k__keys[] = "keys";
static char __pyx_k__kind[] = "kind";
static char __pyx_k__loop[] = "loop";
static char __pyx_k__name[] = "name";
static char __pyx_k__peer[] = "peer";
static char __pyx_k__port[] = "port";
static char __pyx_k__read[] = "read";
static char __pyx_k__self[] = "self";
static char __pyx_k__size[] = "size";
static char __pyx_k__type[] = "type";
static char __pyx_k__warn[] = "warn";
static char __pyx_k__WRITE[] = "WRITE";
static char __pyx_k____obj[] = "__obj";
static char __pyx_k__close[] = "close";
static char __pyx_k__ev_fd[] = "ev_fd";
static char __pyx_k__evcon[] = "evcon";
static char __pyx_k__event[] = "event";
static char __pyx_k__flags[] = "flags";
static char __pyx_k__major[] = "major";
static char __pyx_k__minor[] = "minor";
static char __pyx_k__timer[] = "timer";
static char __pyx_k__value[] = "value";
static char __pyx_k__write[] = "write";
static char __pyx_k__ACTIVE[] = "ACTIVE";
static char __pyx_k__DELETE[] = "DELETE";
static char __pyx_k__SIGNAL[] = "SIGNAL";
static char __pyx_k__buffer[] = "buffer";
static char __pyx_k__cancel[] = "cancel";
static char __pyx_k__detach[] = "detach";
static char __pyx_k__evtype[] = "evtype";
static char __pyx_k__handle[] = "handle";
static char __pyx_k__indent[] = "indent";
static char __pyx_k__pprint[] = "pprint";
static char __pyx_k__reason[] = "reason";
static char __pyx_k__reinit[] = "reinit";
static char __pyx_k__signal[] = "signal";
static char __pyx_k__stderr[] = "stderr";
static char __pyx_k__tv_sec[] = "tv_sec";
static char __pyx_k__DNS_PTR[] = "DNS_PTR";
static char __pyx_k__IOError[] = "IOError";
static char __pyx_k__PERSIST[] = "PERSIST";
static char __pyx_k__TIMEOUT[] = "TIMEOUT";
static char __pyx_k____all__[] = "__all__";
static char __pyx_k____url__[] = "__url__";
static char __pyx_k___addref[] = "_addref";
static char __pyx_k___delref[] = "_delref";
static char __pyx_k___format[] = "_format";
static char __pyx_k___incref[] = "_incref";
static char __pyx_k__address[] = "address";
static char __pyx_k__chunked[] = "chunked";
static char __pyx_k__deleted[] = "deleted";
static char __pyx_k__pending[] = "pending";
static char __pyx_k__persist[] = "persist";
static char __pyx_k__pformat[] = "pformat";
static char __pyx_k__replace[] = "replace";
static char __pyx_k__seconds[] = "seconds";
static char __pyx_k__timeout[] = "timeout";
static char __pyx_k__tv_usec[] = "tv_usec";
static char __pyx_k__typestr[] = "typestr";
static char __pyx_k__weakref[] = "weakref";
static char __pyx_k__INSERTED[] = "INSERTED";
static char __pyx_k__INTERNAL[] = "INTERNAL";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____name__[] = "__name__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__callback[] = "callback";
static char __pyx_k__dispatch[] = "dispatch";
static char __pyx_k__dns_init[] = "dns_init";
static char __pyx_k__ev_flags[] = "ev_flags";
static char __pyx_k__exc_type[] = "exc_type";
static char __pyx_k__nonblock[] = "nonblock";
static char __pyx_k__readline[] = "readline";
static char __pyx_k__warnings[] = "warnings";
static char __pyx_k__Exception[] = "Exception";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k____class__[] = "__class__";
static char __pyx_k___callback[] = "_callback";
static char __pyx_k___requests[] = "_requests";
static char __pyx_k__ev_events[] = "ev_events";
static char __pyx_k__exc_clear[] = "exc_clear";
static char __pyx_k__exc_value[] = "exc_value";
static char __pyx_k__flags_str[] = "flags_str";
static char __pyx_k__packed_ip[] = "packed_ip";
static char __pyx_k__print_exc[] = "print_exc";
static char __pyx_k__signalnum[] = "signalnum";
static char __pyx_k__traceback[] = "traceback";
static char __pyx_k__Connection[] = "Connection";
static char __pyx_k__DNS_IPv4_A[] = "DNS_IPv4_A";
static char __pyx_k____author__[] = "__author__";
static char __pyx_k__events_str[] = "events_str";
static char __pyx_k__get_method[] = "get_method";
static char __pyx_k__read_event[] = "read_event";
static char __pyx_k__stacklevel[] = "stacklevel";
static char __pyx_k__UserWarning[] = "UserWarning";
static char __pyx_k____license__[] = "__license__";
static char __pyx_k____version__[] = "__version__";
static char __pyx_k__get_version[] = "get_version";
static char __pyx_k__remote_host[] = "remote_host";
static char __pyx_k__remote_port[] = "remote_port";
static char __pyx_k__write_event[] = "write_event";
static char __pyx_k__DNS_ERR_NONE[] = "DNS_ERR_NONE";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static char __pyx_k__active_event[] = "active_event";
static char __pyx_k__dns_shutdown[] = "dns_shutdown";
static char __pyx_k__http_request[] = "http_request";
static char __pyx_k__input_buffer[] = "input_buffer";
static char __pyx_k__DNS_IPv6_AAAA[] = "DNS_IPv6_AAAA";
static char __pyx_k__ObjectDeleted[] = "ObjectDeleted";
static char __pyx_k__StopIteration[] = "StopIteration";
static char __pyx_k____copyright__[] = "__copyright__";
static char __pyx_k___input_buffer[] = "_input_buffer";
static char __pyx_k__exc_traceback[] = "exc_traceback";
static char __pyx_k__fail_requests[] = "fail_requests";
static char __pyx_k__input_headers[] = "input_headers";
static char __pyx_k__output_buffer[] = "output_buffer";
static char __pyx_k__response_code[] = "response_code";
static char __pyx_k__AttributeError[] = "AttributeError";
static char __pyx_k__DNS_ERR_FORMAT[] = "DNS_ERR_FORMAT";
static char __pyx_k__EVHTTP_REQUEST[] = "EVHTTP_REQUEST";
static char __pyx_k__EVHTTP_REQ_GET[] = "EVHTTP_REQ_GET";
static char __pyx_k__EVHTTP_REQ_PUT[] = "EVHTTP_REQ_PUT";
static char __pyx_k___output_buffer[] = "_output_buffer";
static char __pyx_k__output_headers[] = "output_headers";
static char __pyx_k__DNS_ERR_NOTIMPL[] = "DNS_ERR_NOTIMPL";
static char __pyx_k__DNS_ERR_REFUSED[] = "DNS_ERR_REFUSED";
static char __pyx_k__DNS_ERR_TIMEOUT[] = "DNS_ERR_TIMEOUT";
static char __pyx_k__DNS_ERR_UNKNOWN[] = "DNS_ERR_UNKNOWN";
static char __pyx_k__EVHTTP_REQ_HEAD[] = "EVHTTP_REQ_HEAD";
static char __pyx_k__EVHTTP_REQ_POST[] = "EVHTTP_REQ_POST";
static char __pyx_k__EVHTTP_RESPONSE[] = "EVHTTP_RESPONSE";
static char __pyx_k__http_connection[] = "http_connection";
static char __pyx_k__readwrite_event[] = "readwrite_event";
static char __pyx_k__DNS_ERR_NOTEXIST[] = "DNS_ERR_NOTEXIST";
static char __pyx_k__DNS_ERR_SHUTDOWN[] = "DNS_ERR_SHUTDOWN";
static char __pyx_k__HTTP_method2name[] = "HTTP_method2name";
static char __pyx_k__dns_resolve_ipv4[] = "dns_resolve_ipv4";
static char __pyx_k__dns_resolve_ipv6[] = "dns_resolve_ipv6";
static char __pyx_k__DNS_ERR_TRUNCATED[] = "DNS_ERR_TRUNCATED";
static char __pyx_k__EVHTTP_REQ_DELETE[] = "EVHTTP_REQ_DELETE";
static char __pyx_k__WeakKeyDictionary[] = "WeakKeyDictionary";
static char __pyx_k__add_output_header[] = "add_output_header";
static char __pyx_k__dns_err_to_string[] = "dns_err_to_string";
static char __pyx_k__DeprecationWarning[] = "DeprecationWarning";
static char __pyx_k__HttpRequestDeleted[] = "HttpRequestDeleted";
static char __pyx_k__find_output_header[] = "find_output_header";
static char __pyx_k__get_header_version[] = "get_header_version";
static char __pyx_k__response_code_line[] = "response_code_line";
static char __pyx_k__DNS_QUERY_NO_SEARCH[] = "DNS_QUERY_NO_SEARCH";
static char __pyx_k__NotImplementedError[] = "NotImplementedError";
static char __pyx_k__dns_resolve_reverse[] = "dns_resolve_reverse";
static char __pyx_k__remove_input_header[] = "remove_input_header";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_10;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_16;
static PyObject *__pyx_kp_s_17;
static PyObject *__pyx_kp_s_18;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_kp_s_20;
static PyObject *__pyx_n_s_21;
static PyObject *__pyx_kp_s_22;
static PyObject *__pyx_kp_s_23;
static PyObject *__pyx_kp_s_24;
static PyObject *__pyx_kp_s_25;
static PyObject *__pyx_kp_s_26;
static PyObject *__pyx_kp_s_27;
static PyObject *__pyx_kp_s_28;
static PyObject *__pyx_n_s_29;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_30;
static PyObject *__pyx_kp_s_31;
static PyObject *__pyx_n_s_32;
static PyObject *__pyx_kp_s_33;
static PyObject *__pyx_kp_s_34;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_40;
static PyObject *__pyx_kp_s_41;
static PyObject *__pyx_kp_s_46;
static PyObject *__pyx_kp_s_47;
static PyObject *__pyx_kp_s_48;
static PyObject *__pyx_kp_s_49;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_50;
static PyObject *__pyx_kp_s_51;
static PyObject *__pyx_kp_s_52;
static PyObject *__pyx_n_s_53;
static PyObject *__pyx_n_s_54;
static PyObject *__pyx_kp_s_55;
static PyObject *__pyx_kp_s_56;
static PyObject *__pyx_kp_s_57;
static PyObject *__pyx_kp_s_58;
static PyObject *__pyx_kp_u_59;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_u_60;
static PyObject *__pyx_kp_u_61;
static PyObject *__pyx_kp_u_62;
static PyObject *__pyx_kp_u_63;
static PyObject *__pyx_kp_u_64;
static PyObject *__pyx_kp_u_65;
static PyObject *__pyx_kp_u_66;
static PyObject *__pyx_kp_u_67;
static PyObject *__pyx_kp_u_68;
static PyObject *__pyx_kp_u_69;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_u_70;
static PyObject *__pyx_kp_u_71;
static PyObject *__pyx_kp_u_72;
static PyObject *__pyx_kp_u_73;
static PyObject *__pyx_kp_u_74;
static PyObject *__pyx_kp_u_75;
static PyObject *__pyx_kp_u_76;
static PyObject *__pyx_n_s_77;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__ACTIVE;
static PyObject *__pyx_n_s__AttributeError;
static PyObject *__pyx_n_s__BSD;
static PyObject *__pyx_n_s__DELETE;
static PyObject *__pyx_n_s__DNS_ERR_FORMAT;
static PyObject *__pyx_n_s__DNS_ERR_NONE;
static PyObject *__pyx_n_s__DNS_ERR_NOTEXIST;
static PyObject *__pyx_n_s__DNS_ERR_NOTIMPL;
static PyObject *__pyx_n_s__DNS_ERR_REFUSED;
static PyObject *__pyx_n_s__DNS_ERR_SHUTDOWN;
static PyObject *__pyx_n_s__DNS_ERR_TIMEOUT;
static PyObject *__pyx_n_s__DNS_ERR_TRUNCATED;
static PyObject *__pyx_n_s__DNS_ERR_UNKNOWN;
static PyObject *__pyx_n_s__DNS_IPv4_A;
static PyObject *__pyx_n_s__DNS_IPv6_AAAA;
static PyObject *__pyx_n_s__DNS_PTR;
static PyObject *__pyx_n_s__DNS_QUERY_NO_SEARCH;
static PyObject *__pyx_n_s__DeprecationWarning;
static PyObject *__pyx_n_s__EVHTTP_REQUEST;
static PyObject *__pyx_n_s__EVHTTP_REQ_DELETE;
static PyObject *__pyx_n_s__EVHTTP_REQ_GET;
static PyObject *__pyx_n_s__EVHTTP_REQ_HEAD;
static PyObject *__pyx_n_s__EVHTTP_REQ_POST;
static PyObject *__pyx_n_s__EVHTTP_REQ_PUT;
static PyObject *__pyx_n_s__EVHTTP_RESPONSE;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__GET;
static PyObject *__pyx_n_s__HEAD;
static PyObject *__pyx_n_s__HTTP_method2name;
static PyObject *__pyx_n_s__HttpRequestDeleted;
static PyObject *__pyx_n_s__INIT;
static PyObject *__pyx_n_s__INSERTED;
static PyObject *__pyx_n_s__INTERNAL;
static PyObject *__pyx_n_s__IOError;
static PyObject *__pyx_n_s__NotImplementedError;
static PyObject *__pyx_n_s__ObjectDeleted;
static PyObject *__pyx_n_s__PERSIST;
static PyObject *__pyx_n_s__POST;
static PyObject *__pyx_n_s__PUT;
static PyObject *__pyx_n_s__READ;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__SIGNAL;
static PyObject *__pyx_n_s__StopIteration;
static PyObject *__pyx_n_s__TIMEOUT;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__UserWarning;
static PyObject *__pyx_n_s__WRITE;
static PyObject *__pyx_n_s__WeakKeyDictionary;
static PyObject *__pyx_n_s____all__;
static PyObject *__pyx_n_s____author__;
static PyObject *__pyx_n_s____class__;
static PyObject *__pyx_n_s____copyright__;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____license__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____name__;
static PyObject *__pyx_n_s____obj;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s____url__;
static PyObject *__pyx_n_s____version__;
static PyObject *__pyx_n_s___addref;
static PyObject *__pyx_n_s___arg;
static PyObject *__pyx_n_s___callback;
static PyObject *__pyx_n_s___delref;
static PyObject *__pyx_n_s___format;
static PyObject *__pyx_n_s___incref;
static PyObject *__pyx_n_s___input_buffer;
static PyObject *__pyx_n_s___obj;
static PyObject *__pyx_n_s___output_buffer;
static PyObject *__pyx_n_s___requests;
static PyObject *__pyx_n_s__active_event;
static PyObject *__pyx_n_s__add;
static PyObject *__pyx_n_s__add_output_header;
static PyObject *__pyx_n_s__address;
static PyObject *__pyx_n_s__arg;
static PyObject *__pyx_n_s__buf;
static PyObject *__pyx_n_s__buffer;
static PyObject *__pyx_n_s__callback;
static PyObject *__pyx_n_s__cancel;
static PyObject *__pyx_n_s__chunked;
static PyObject *__pyx_n_s__code;
static PyObject *__pyx_n_s__deleted;
static PyObject *__pyx_n_s__detach;
static PyObject *__pyx_n_s__dispatch;
static PyObject *__pyx_n_s__dns_err_to_string;
static PyObject *__pyx_n_s__dns_init;
static PyObject *__pyx_n_s__dns_resolve_ipv4;
static PyObject *__pyx_n_s__dns_resolve_ipv6;
static PyObject *__pyx_n_s__dns_resolve_reverse;
static PyObject *__pyx_n_s__dns_shutdown;
static PyObject *__pyx_n_s__ev;
static PyObject *__pyx_n_s__ev_events;
static PyObject *__pyx_n_s__ev_fd;
static PyObject *__pyx_n_s__ev_flags;
static PyObject *__pyx_n_s__evcon;
static PyObject *__pyx_n_s__event;
static PyObject *__pyx_n_s__events_str;
static PyObject *__pyx_n_s__evtype;
static PyObject *__pyx_n_s__exc_clear;
static PyObject *__pyx_n_s__exc_traceback;
static PyObject *__pyx_n_s__exc_type;
static PyObject *__pyx_n_s__exc_value;
static PyObject *__pyx_n_s__fail_requests;
static PyObject *__pyx_n_s__fd;
static PyObject *__pyx_n_s__find_output_header;
static PyObject *__pyx_n_s__flags;
static PyObject *__pyx_n_s__flags_str;
static PyObject *__pyx_n_s__get;
static PyObject *__pyx_n_s__get_header_version;
static PyObject *__pyx_n_s__get_method;
static PyObject *__pyx_n_s__get_version;
static PyObject *__pyx_n_s__handle;
static PyObject *__pyx_n_s__hex;
static PyObject *__pyx_n_s__hint;
static PyObject *__pyx_n_s__http;
static PyObject *__pyx_n_s__http_connection;
static PyObject *__pyx_n_s__http_request;
static PyObject *__pyx_n_s__id;
static PyObject *__pyx_n_s__indent;
static PyObject *__pyx_n_s__init;
static PyObject *__pyx_n_s__input_buffer;
static PyObject *__pyx_n_s__input_headers;
static PyObject *__pyx_n_s__join;
static PyObject *__pyx_n_s__key;
static PyObject *__pyx_n_s__keys;
static PyObject *__pyx_n_s__kind;
static PyObject *__pyx_n_s__loop;
static PyObject *__pyx_n_s__major;
static PyObject *__pyx_n_s__min;
static PyObject *__pyx_n_s__minor;
static PyObject *__pyx_n_s__msg;
static PyObject *__pyx_n_s__name;
static PyObject *__pyx_n_s__nonblock;
static PyObject *__pyx_n_s__output_buffer;
static PyObject *__pyx_n_s__output_headers;
static PyObject *__pyx_n_s__packed_ip;
static PyObject *__pyx_n_s__peer;
static PyObject *__pyx_n_s__pending;
static PyObject *__pyx_n_s__persist;
static PyObject *__pyx_n_s__pformat;
static PyObject *__pyx_n_s__pop;
static PyObject *__pyx_n_s__port;
static PyObject *__pyx_n_s__pprint;
static PyObject *__pyx_n_s__print_exc;
static PyObject *__pyx_n_s__read;
static PyObject *__pyx_n_s__read_event;
static PyObject *__pyx_n_s__readline;
static PyObject *__pyx_n_s__readwrite_event;
static PyObject *__pyx_n_s__reason;
static PyObject *__pyx_n_s__reinit;
static PyObject *__pyx_n_s__remote_host;
static PyObject *__pyx_n_s__remote_port;
static PyObject *__pyx_n_s__remove_input_header;
static PyObject *__pyx_n_s__replace;
static PyObject *__pyx_n_s__response_code;
static PyObject *__pyx_n_s__response_code_line;
static PyObject *__pyx_n_s__seconds;
static PyObject *__pyx_n_s__self;
static PyObject *__pyx_n_s__signal;
static PyObject *__pyx_n_s__signalnum;
static PyObject *__pyx_n_s__size;
static PyObject *__pyx_n_s__stacklevel;
static PyObject *__pyx_n_s__stderr;
static PyObject *__pyx_n_s__sys;
static PyObject *__pyx_n_s__tb;
static PyObject *__pyx_n_s__timeout;
static PyObject *__pyx_n_s__timer;
static PyObject *__pyx_n_s__traceback;
static PyObject *__pyx_n_s__tv_sec;
static PyObject *__pyx_n_s__tv_usec;
static PyObject *__pyx_n_s__typ;
static PyObject *__pyx_n_s__type;
static PyObject *__pyx_n_s__typestr;
static PyObject *__pyx_n_s__uri;
static PyObject *__pyx_n_s__value;
static PyObject *__pyx_n_s__warn;
static PyObject *__pyx_n_s__warnings;
static PyObject *__pyx_n_s__weakref;
static PyObject *__pyx_n_s__write;
static PyObject *__pyx_n_s__write_event;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_5;
static PyObject *__pyx_int_8;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_int_65;
static PyObject *__pyx_int_66;
static PyObject *__pyx_int_67;
static PyObject *__pyx_int_68;
static PyObject *__pyx_k_12;
static PyObject *__pyx_k_13;
static PyObject *__pyx_k_14;
static PyObject *__pyx_k_15;

/* "/home/denis/work/gevent/gevent/core.pyx":149
 * 
 * 
 * cdef void __event_handler(int fd, short evtype, void *arg) with gil:             # <<<<<<<<<<<<<<
 *     cdef event self = <event>arg
 *     try:
 */

static  void __pyx_f_6gevent_4core___event_handler(int __pyx_v_fd, short __pyx_v_evtype, void *__pyx_v_arg) {
  struct __pyx_obj_6gevent_4core_event *__pyx_v_self = 0;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyGILState_STATE _save = PyGILState_Ensure();
  __Pyx_RefNannySetupContext("__event_handler");

  /* "/home/denis/work/gevent/gevent/core.pyx":150
 * 
 * cdef void __event_handler(int fd, short evtype, void *arg) with gil:
 *     cdef event self = <event>arg             # <<<<<<<<<<<<<<
 *     try:
 *         self._callback(self, evtype)
 */
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6gevent_4core_event *)__pyx_v_arg)));
  __pyx_v_self = ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_arg);

  /* "/home/denis/work/gevent/gevent/core.pyx":151
 * cdef void __event_handler(int fd, short evtype, void *arg) with gil:
 *     cdef event self = <event>arg
 *     try:             # <<<<<<<<<<<<<<
 *         self._callback(self, evtype)
 *     except:
 */
  /*try:*/ {
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      __Pyx_XGOTREF(__pyx_save_exc_type);
      __Pyx_XGOTREF(__pyx_save_exc_value);
      __Pyx_XGOTREF(__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/denis/work/gevent/gevent/core.pyx":152
 *     cdef event self = <event>arg
 *     try:
 *         self._callback(self, evtype)             # <<<<<<<<<<<<<<
 *     except:
 *         traceback.print_exc()
 */
        __pyx_t_1 = PyInt_FromLong(__pyx_v_evtype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_Call(__pyx_v_self->_callback, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "/home/denis/work/gevent/gevent/core.pyx":153
 *     try:
 *         self._callback(self, evtype)
 *     except:             # <<<<<<<<<<<<<<
 *         traceback.print_exc()
 *         try:
 */
      /*except:*/ {
        __Pyx_AddTraceback("gevent.core.__event_handler");
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_3);

        /* "/home/denis/work/gevent/gevent/core.pyx":154
 *         self._callback(self, evtype)
 *     except:
 *         traceback.print_exc()             # <<<<<<<<<<<<<<
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (self, ))
 */
        __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__traceback); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__print_exc); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "/home/denis/work/gevent/gevent/core.pyx":155
 *     except:
 *         traceback.print_exc()
 *         try:             # <<<<<<<<<<<<<<
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (self, ))
 *         except:
 */
        {
          PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
          __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
          __Pyx_XGOTREF(__pyx_save_exc_type);
          __Pyx_XGOTREF(__pyx_save_exc_value);
          __Pyx_XGOTREF(__pyx_save_exc_tb);
          /*try:*/ {

            /* "/home/denis/work/gevent/gevent/core.pyx":156
 *         traceback.print_exc()
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (self, ))             # <<<<<<<<<<<<<<
 *         except:
 *             traceback.print_exc()
 */
            __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__stderr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_INCREF(((PyObject *)__pyx_v_self));
            PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
            __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_6);
            __pyx_t_6 = 0;
            __pyx_t_6 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          }
          __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
          __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
          __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
          goto __pyx_L23_try_end;
          __pyx_L16_error:;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "/home/denis/work/gevent/gevent/core.pyx":157
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (self, ))
 *         except:             # <<<<<<<<<<<<<<
 *             traceback.print_exc()
 *         sys.exc_clear()
 */
          /*except:*/ {
            __Pyx_AddTraceback("gevent.core.__event_handler");
            if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L18_except_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_GOTREF(__pyx_t_4);

            /* "/home/denis/work/gevent/gevent/core.pyx":158
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (self, ))
 *         except:
 *             traceback.print_exc()             # <<<<<<<<<<<<<<
 *         sys.exc_clear()
 *     finally:
 */
            __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__traceback); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L18_except_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_8 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__print_exc); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L18_except_error;}
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L18_except_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L17_exception_handled;
          }
          __pyx_L18_except_error:;
          __Pyx_XGIVEREF(__pyx_save_exc_type);
          __Pyx_XGIVEREF(__pyx_save_exc_value);
          __Pyx_XGIVEREF(__pyx_save_exc_tb);
          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
          goto __pyx_L8_except_error;
          __pyx_L17_exception_handled:;
          __Pyx_XGIVEREF(__pyx_save_exc_type);
          __Pyx_XGIVEREF(__pyx_save_exc_value);
          __Pyx_XGIVEREF(__pyx_save_exc_tb);
          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
          __pyx_L23_try_end:;
        }

        /* "/home/denis/work/gevent/gevent/core.pyx":159
 *         except:
 *             traceback.print_exc()
 *         sys.exc_clear()             # <<<<<<<<<<<<<<
 *     finally:
 *         if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):
 */
        __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__exc_clear); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L7_exception_handled;
      }
      __pyx_L8_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L4;
      __pyx_L7_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L13_try_end:;
    }
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/denis/work/gevent/gevent/core.pyx":161
 *         sys.exc_clear()
 *     finally:
 *         if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):             # <<<<<<<<<<<<<<
 *             self._delref()
 * 
 */
    __pyx_t_9 = (!event_pending((&__pyx_v_self->ev), (((EV_READ | EV_WRITE) | EV_SIGNAL) | EV_TIMEOUT), NULL));
    if (__pyx_t_9) {

      /* "/home/denis/work/gevent/gevent/core.pyx":162
 *     finally:
 *         if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):
 *             self._delref()             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_4core_event *)__pyx_v_self->__pyx_vtab)->_delref(__pyx_v_self); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L26_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L27;
    }
    __pyx_L27:;
    goto __pyx_L28;
    __pyx_L26_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L28:;
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("gevent.core.__event_handler");
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
  PyGILState_Release(_save);
}

/* "/home/denis/work/gevent/gevent/core.pyx":177
 *     cdef int _incref # 1 if we already INCREFed this object once (because libevent references it)
 * 
 *     def __init__(self, short evtype, int handle, callback, arg=None):             # <<<<<<<<<<<<<<
 *         self._callback = callback
 *         self._arg = arg
 */

static int __pyx_pf_6gevent_4core_5event___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6gevent_4core_5event___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  short __pyx_v_evtype;
  int __pyx_v_handle;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_arg = 0;
  void *__pyx_v_c_self;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__evtype,&__pyx_n_s__handle,&__pyx_n_s__callback,&__pyx_n_s__arg,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__evtype);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__handle);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__arg);
        if (unlikely(value)) { values[3] = 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 = 177; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_evtype = __Pyx_PyInt_AsShort(values[0]); if (unlikely((__pyx_v_evtype == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_handle = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_handle == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[2];
    __pyx_v_arg = values[3];
  } else {
    __pyx_v_arg = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4:
      __pyx_v_arg = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3:
      __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 2);
      __pyx_v_handle = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_handle == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_evtype = __Pyx_PyInt_AsShort(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_evtype == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.event.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_arg);

  /* "/home/denis/work/gevent/gevent/core.pyx":178
 * 
 *     def __init__(self, short evtype, int handle, callback, arg=None):
 *         self._callback = callback             # <<<<<<<<<<<<<<
 *         self._arg = arg
 *         self._incref = 0
 */
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback = __pyx_v_callback;

  /* "/home/denis/work/gevent/gevent/core.pyx":179
 *     def __init__(self, short evtype, int handle, callback, arg=None):
 *         self._callback = callback
 *         self._arg = arg             # <<<<<<<<<<<<<<
 *         self._incref = 0
 *         cdef void* c_self = <void*>self
 */
  __Pyx_INCREF(__pyx_v_arg);
  __Pyx_GIVEREF(__pyx_v_arg);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg = __pyx_v_arg;

  /* "/home/denis/work/gevent/gevent/core.pyx":180
 *         self._callback = callback
 *         self._arg = arg
 *         self._incref = 0             # <<<<<<<<<<<<<<
 *         cdef void* c_self = <void*>self
 *         if evtype == 0 and not handle:
 */
  ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_incref = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":181
 *         self._arg = arg
 *         self._incref = 0
 *         cdef void* c_self = <void*>self             # <<<<<<<<<<<<<<
 *         if evtype == 0 and not handle:
 *             evtimer_set(&self.ev, __event_handler, c_self)
 */
  __pyx_v_c_self = ((void *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/core.pyx":182
 *         self._incref = 0
 *         cdef void* c_self = <void*>self
 *         if evtype == 0 and not handle:             # <<<<<<<<<<<<<<
 *             evtimer_set(&self.ev, __event_handler, c_self)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_evtype == 0);
  if (__pyx_t_1) {
    __pyx_t_2 = (!__pyx_v_handle);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/denis/work/gevent/gevent/core.pyx":183
 *         cdef void* c_self = <void*>self
 *         if evtype == 0 and not handle:
 *             evtimer_set(&self.ev, __event_handler, c_self)             # <<<<<<<<<<<<<<
 *         else:
 *             event_set(&self.ev, handle, evtype, __event_handler, c_self)
 */
    evtimer_set((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), __pyx_f_6gevent_4core___event_handler, __pyx_v_c_self);
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/core.pyx":185
 *             evtimer_set(&self.ev, __event_handler, c_self)
 *         else:
 *             event_set(&self.ev, handle, evtype, __event_handler, c_self)             # <<<<<<<<<<<<<<
 * 
 *     cdef _addref(self):
 */
    event_set((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), __pyx_v_handle, __pyx_v_evtype, __pyx_f_6gevent_4core___event_handler, __pyx_v_c_self);
  }
  __pyx_L6:;

  __pyx_r = 0;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_callback);
  __Pyx_DECREF(__pyx_v_arg);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":187
 *             event_set(&self.ev, handle, evtype, __event_handler, c_self)
 * 
 *     cdef _addref(self):             # <<<<<<<<<<<<<<
 *         if self._incref <= 0:
 *             Py_INCREF(self)
 */

static  PyObject *__pyx_f_6gevent_4core_5event__addref(struct __pyx_obj_6gevent_4core_event *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_addref");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/core.pyx":188
 * 
 *     cdef _addref(self):
 *         if self._incref <= 0:             # <<<<<<<<<<<<<<
 *             Py_INCREF(self)
 *             self._incref += 1
 */
  __pyx_t_1 = (__pyx_v_self->_incref <= 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":189
 *     cdef _addref(self):
 *         if self._incref <= 0:
 *             Py_INCREF(self)             # <<<<<<<<<<<<<<
 *             self._incref += 1
 * 
 */
    Py_INCREF(((PyObject *)__pyx_v_self));

    /* "/home/denis/work/gevent/gevent/core.pyx":190
 *         if self._incref <= 0:
 *             Py_INCREF(self)
 *             self._incref += 1             # <<<<<<<<<<<<<<
 * 
 *     cdef _delref(self):
 */
    __pyx_v_self->_incref += 1;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":192
 *             self._incref += 1
 * 
 *     cdef _delref(self):             # <<<<<<<<<<<<<<
 *         if self._incref > 0:
 *             Py_DECREF(self)
 */

static  PyObject *__pyx_f_6gevent_4core_5event__delref(struct __pyx_obj_6gevent_4core_event *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_delref");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/core.pyx":193
 * 
 *     cdef _delref(self):
 *         if self._incref > 0:             # <<<<<<<<<<<<<<
 *             Py_DECREF(self)
 *             self._incref -= 1
 */
  __pyx_t_1 = (__pyx_v_self->_incref > 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":194
 *     cdef _delref(self):
 *         if self._incref > 0:
 *             Py_DECREF(self)             # <<<<<<<<<<<<<<
 *             self._incref -= 1
 * 
 */
    Py_DECREF(((PyObject *)__pyx_v_self));

    /* "/home/denis/work/gevent/gevent/core.pyx":195
 *         if self._incref > 0:
 *             Py_DECREF(self)
 *             self._incref -= 1             # <<<<<<<<<<<<<<
 * 
 *     property callback:
 */
    __pyx_v_self->_incref -= 1;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":203
 *         """
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._callback
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_5event_8callback___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event_8callback___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":204
 * 
 *         def __get__(self):
 *             return self._callback             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, new):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  __pyx_r = ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback;
  goto __pyx_L0;

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

/* "/home/denis/work/gevent/gevent/core.pyx":206
 *             return self._callback
 * 
 *         def __set__(self, new):             # <<<<<<<<<<<<<<
 *             self._callback = new
 * 
 */

static int __pyx_pf_6gevent_4core_5event_8callback___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_new); /*proto*/
static int __pyx_pf_6gevent_4core_5event_8callback___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_new) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__set__");

  /* "/home/denis/work/gevent/gevent/core.pyx":207
 * 
 *         def __set__(self, new):
 *             self._callback = new             # <<<<<<<<<<<<<<
 * 
 *     property arg:
 */
  __Pyx_INCREF(__pyx_v_new);
  __Pyx_GIVEREF(__pyx_v_new);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback = __pyx_v_new;

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

/* "/home/denis/work/gevent/gevent/core.pyx":212
 *         """Optional object set and read only by the user."""
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._arg
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_5event_3arg___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event_3arg___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":213
 * 
 *         def __get__(self):
 *             return self._arg             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, new):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  __pyx_r = ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg;
  goto __pyx_L0;

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

/* "/home/denis/work/gevent/gevent/core.pyx":215
 *             return self._arg
 * 
 *         def __set__(self, new):             # <<<<<<<<<<<<<<
 *             self._arg = new
 * 
 */

static int __pyx_pf_6gevent_4core_5event_3arg___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_new); /*proto*/
static int __pyx_pf_6gevent_4core_5event_3arg___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_new) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__set__");

  /* "/home/denis/work/gevent/gevent/core.pyx":216
 * 
 *         def __set__(self, new):
 *             self._arg = new             # <<<<<<<<<<<<<<
 * 
 *     property pending:
 */
  __Pyx_INCREF(__pyx_v_new);
  __Pyx_GIVEREF(__pyx_v_new);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg = __pyx_v_new;

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

/* "/home/denis/work/gevent/gevent/core.pyx":221
 *         """Return True if the event is still scheduled to run."""
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return event_pending(&self.ev, EV_TIMEOUT|EV_SIGNAL|EV_READ|EV_WRITE, NULL)
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_5event_7pending___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event_7pending___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":222
 * 
 *         def __get__(self):
 *             return event_pending(&self.ev, EV_TIMEOUT|EV_SIGNAL|EV_READ|EV_WRITE, NULL)             # <<<<<<<<<<<<<<
 * 
 *     property fd:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(event_pending((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), (((EV_TIMEOUT | EV_SIGNAL) | EV_READ) | EV_WRITE), NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __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("gevent.core.event.pending.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":226
 *     property fd:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.ev.ev_fd
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_5event_2fd___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event_2fd___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":227
 * 
 *         def __get__(self):
 *             return self.ev.ev_fd             # <<<<<<<<<<<<<<
 * 
 *     property events:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev.ev_fd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __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("gevent.core.event.fd.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":231
 *     property events:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.ev.ev_events
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_5event_6events___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event_6events___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":232
 * 
 *         def __get__(self):
 *             return self.ev.ev_events             # <<<<<<<<<<<<<<
 * 
 *     property events_str:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev.ev_events); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __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("gevent.core.event.events.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":236
 *     property events_str:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             result = []
 *             cdef short events = self.ev.ev_events
 */

static PyObject *__pyx_pf_6gevent_4core_5event_10events_str___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event_10events_str___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_result;
  short __pyx_v_events;
  short __pyx_v_c_event;
  PyObject *__pyx_v_event;
  PyObject *__pyx_v_txt;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  short __pyx_t_8;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_event = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_txt = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/core.pyx":237
 * 
 *         def __get__(self):
 *             result = []             # <<<<<<<<<<<<<<
 *             cdef short events = self.ev.ev_events
 *             cdef short c_event
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(__pyx_v_result);
  __pyx_v_result = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":238
 *         def __get__(self):
 *             result = []
 *             cdef short events = self.ev.ev_events             # <<<<<<<<<<<<<<
 *             cdef short c_event
 *             for (event, txt) in ((EV_TIMEOUT, 'TIMEOUT'), (EV_READ, 'READ'), (EV_WRITE, 'WRITE'),
 */
  __pyx_v_events = ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev.ev_events;

  /* "/home/denis/work/gevent/gevent/core.pyx":240
 *             cdef short events = self.ev.ev_events
 *             cdef short c_event
 *             for (event, txt) in ((EV_TIMEOUT, 'TIMEOUT'), (EV_READ, 'READ'), (EV_WRITE, 'WRITE'),             # <<<<<<<<<<<<<<
 *                                  (EV_SIGNAL, 'SIGNAL'), (EV_PERSIST, 'PERSIST')):
 *                 c_event = event
 */
  __pyx_t_1 = PyInt_FromLong(EV_TIMEOUT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__TIMEOUT));
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__TIMEOUT));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__TIMEOUT));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(EV_READ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__READ));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__READ));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__READ));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(EV_WRITE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__WRITE));
  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__WRITE));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__WRITE));
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":241
 *             cdef short c_event
 *             for (event, txt) in ((EV_TIMEOUT, 'TIMEOUT'), (EV_READ, 'READ'), (EV_WRITE, 'WRITE'),
 *                                  (EV_SIGNAL, 'SIGNAL'), (EV_PERSIST, 'PERSIST')):             # <<<<<<<<<<<<<<
 *                 c_event = event
 *                 if events & c_event:
 */
  __pyx_t_1 = PyInt_FromLong(EV_SIGNAL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__SIGNAL));
  PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_n_s__SIGNAL));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SIGNAL));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(EV_PERSIST); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__PERSIST));
  PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__PERSIST));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PERSIST));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = 0; __pyx_t_7 = __pyx_t_1; __Pyx_INCREF(__pyx_t_7);
  } else {
    __pyx_t_2 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {

    /* "/home/denis/work/gevent/gevent/core.pyx":240
 *             cdef short events = self.ev.ev_events
 *             cdef short c_event
 *             for (event, txt) in ((EV_TIMEOUT, 'TIMEOUT'), (EV_READ, 'READ'), (EV_WRITE, 'WRITE'),             # <<<<<<<<<<<<<<
 *                                  (EV_SIGNAL, 'SIGNAL'), (EV_PERSIST, 'PERSIST')):
 *                 c_event = event
 */
    if (likely(PyList_CheckExact(__pyx_t_7))) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_7)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_7))) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
    } else {
      __pyx_t_1 = PyIter_Next(__pyx_t_7);
      if (!__pyx_t_1) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) {
      PyObject* tuple = __pyx_t_1;
      __pyx_t_6 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_6);
      __pyx_t_5 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_event);
      __pyx_v_event = __pyx_t_6;
      __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_v_txt);
      __pyx_v_txt = __pyx_t_5;
      __pyx_t_5 = 0;
    } else {
      __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_4, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_4, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_EndUnpack(__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_v_event);
      __pyx_v_event = __pyx_t_6;
      __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_v_txt);
      __pyx_v_txt = __pyx_t_5;
      __pyx_t_5 = 0;
    }

    /* "/home/denis/work/gevent/gevent/core.pyx":242
 *             for (event, txt) in ((EV_TIMEOUT, 'TIMEOUT'), (EV_READ, 'READ'), (EV_WRITE, 'WRITE'),
 *                                  (EV_SIGNAL, 'SIGNAL'), (EV_PERSIST, 'PERSIST')):
 *                 c_event = event             # <<<<<<<<<<<<<<
 *                 if events & c_event:
 *                     result.append(txt)
 */
    __pyx_t_8 = __Pyx_PyInt_AsShort(__pyx_v_event); if (unlikely((__pyx_t_8 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_event = __pyx_t_8;

    /* "/home/denis/work/gevent/gevent/core.pyx":243
 *                                  (EV_SIGNAL, 'SIGNAL'), (EV_PERSIST, 'PERSIST')):
 *                 c_event = event
 *                 if events & c_event:             # <<<<<<<<<<<<<<
 *                     result.append(txt)
 *                     c_event = c_event ^ 0xffffff
 */
    __pyx_t_8 = (__pyx_v_events & __pyx_v_c_event);
    if (__pyx_t_8) {

      /* "/home/denis/work/gevent/gevent/core.pyx":244
 *                 c_event = event
 *                 if events & c_event:
 *                     result.append(txt)             # <<<<<<<<<<<<<<
 *                     c_event = c_event ^ 0xffffff
 *                     events = events & c_event
 */
      __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_v_txt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "/home/denis/work/gevent/gevent/core.pyx":245
 *                 if events & c_event:
 *                     result.append(txt)
 *                     c_event = c_event ^ 0xffffff             # <<<<<<<<<<<<<<
 *                     events = events & c_event
 *             if events:
 */
      __pyx_v_c_event = (__pyx_v_c_event ^ 0xffffff);

      /* "/home/denis/work/gevent/gevent/core.pyx":246
 *                     result.append(txt)
 *                     c_event = c_event ^ 0xffffff
 *                     events = events & c_event             # <<<<<<<<<<<<<<
 *             if events:
 *                 result.append(hex(events))
 */
      __pyx_v_events = (__pyx_v_events & __pyx_v_c_event);
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":247
 *                     c_event = c_event ^ 0xffffff
 *                     events = events & c_event
 *             if events:             # <<<<<<<<<<<<<<
 *                 result.append(hex(events))
 *             return '|'.join(result)
 */
  __pyx_t_8 = __pyx_v_events;
  if (__pyx_t_8) {

    /* "/home/denis/work/gevent/gevent/core.pyx":248
 *                     events = events & c_event
 *             if events:
 *                 result.append(hex(events))             # <<<<<<<<<<<<<<
 *             return '|'.join(result)
 * 
 */
    __pyx_t_7 = PyInt_FromLong(__pyx_v_events); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_Call(__pyx_builtin_hex, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/denis/work/gevent/gevent/core.pyx":249
 *             if events:
 *                 result.append(hex(events))
 *             return '|'.join(result)             # <<<<<<<<<<<<<<
 * 
 *     property flags:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_result);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_result);
  __Pyx_GIVEREF(__pyx_v_result);
  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("gevent.core.event.events_str.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_DECREF(__pyx_v_event);
  __Pyx_DECREF(__pyx_v_txt);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":253
 *     property flags:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.ev.ev_flags
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_5event_5flags___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event_5flags___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":254
 * 
 *         def __get__(self):
 *             return self.ev.ev_flags             # <<<<<<<<<<<<<<
 * 
 *     property flags_str:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev.ev_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __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("gevent.core.event.flags.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":258
 *     property flags_str:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             result = []
 *             cdef int flags = self.ev.ev_flags
 */

static PyObject *__pyx_pf_6gevent_4core_5event_9flags_str___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event_9flags_str___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_result;
  int __pyx_v_flags;
  int __pyx_v_c_flag;
  PyObject *__pyx_v_flag;
  PyObject *__pyx_v_txt;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_flag = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_txt = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/core.pyx":259
 * 
 *         def __get__(self):
 *             result = []             # <<<<<<<<<<<<<<
 *             cdef int flags = self.ev.ev_flags
 *             cdef int c_flag
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(__pyx_v_result);
  __pyx_v_result = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":260
 *         def __get__(self):
 *             result = []
 *             cdef int flags = self.ev.ev_flags             # <<<<<<<<<<<<<<
 *             cdef int c_flag
 *             for (flag, txt) in ((EVLIST_TIMEOUT, 'TIMEOUT'), (EVLIST_INSERTED, 'INSERTED'), (EVLIST_SIGNAL, 'SIGNAL'),
 */
  __pyx_v_flags = ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev.ev_flags;

  /* "/home/denis/work/gevent/gevent/core.pyx":262
 *             cdef int flags = self.ev.ev_flags
 *             cdef int c_flag
 *             for (flag, txt) in ((EVLIST_TIMEOUT, 'TIMEOUT'), (EVLIST_INSERTED, 'INSERTED'), (EVLIST_SIGNAL, 'SIGNAL'),             # <<<<<<<<<<<<<<
 *                                 (EVLIST_ACTIVE, 'ACTIVE'), (EVLIST_INTERNAL, 'INTERNAL'), (EVLIST_INIT, 'INIT')):
 *                 c_flag = flag
 */
  __pyx_t_1 = PyInt_FromLong(EVLIST_TIMEOUT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__TIMEOUT));
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__TIMEOUT));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__TIMEOUT));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(EVLIST_INSERTED); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__INSERTED));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__INSERTED));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__INSERTED));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(EVLIST_SIGNAL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__SIGNAL));
  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__SIGNAL));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SIGNAL));
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":263
 *             cdef int c_flag
 *             for (flag, txt) in ((EVLIST_TIMEOUT, 'TIMEOUT'), (EVLIST_INSERTED, 'INSERTED'), (EVLIST_SIGNAL, 'SIGNAL'),
 *                                 (EVLIST_ACTIVE, 'ACTIVE'), (EVLIST_INTERNAL, 'INTERNAL'), (EVLIST_INIT, 'INIT')):             # <<<<<<<<<<<<<<
 *                 c_flag = flag
 *                 if flags & c_flag:
 */
  __pyx_t_1 = PyInt_FromLong(EVLIST_ACTIVE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__ACTIVE));
  PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_n_s__ACTIVE));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ACTIVE));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(EVLIST_INTERNAL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__INTERNAL));
  PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__INTERNAL));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__INTERNAL));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(EVLIST_INIT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__INIT));
  PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_n_s__INIT));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__INIT));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = 0; __pyx_t_8 = __pyx_t_1; __Pyx_INCREF(__pyx_t_8);
  } else {
    __pyx_t_2 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {

    /* "/home/denis/work/gevent/gevent/core.pyx":262
 *             cdef int flags = self.ev.ev_flags
 *             cdef int c_flag
 *             for (flag, txt) in ((EVLIST_TIMEOUT, 'TIMEOUT'), (EVLIST_INSERTED, 'INSERTED'), (EVLIST_SIGNAL, 'SIGNAL'),             # <<<<<<<<<<<<<<
 *                                 (EVLIST_ACTIVE, 'ACTIVE'), (EVLIST_INTERNAL, 'INTERNAL'), (EVLIST_INIT, 'INIT')):
 *                 c_flag = flag
 */
    if (likely(PyList_CheckExact(__pyx_t_8))) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_8)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_8))) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
    } else {
      __pyx_t_1 = PyIter_Next(__pyx_t_8);
      if (!__pyx_t_1) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) {
      PyObject* tuple = __pyx_t_1;
      __pyx_t_7 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_7);
      __pyx_t_6 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_flag);
      __pyx_v_flag = __pyx_t_7;
      __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_v_txt);
      __pyx_v_txt = __pyx_t_6;
      __pyx_t_6 = 0;
    } else {
      __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_5, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_5, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_EndUnpack(__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_v_flag);
      __pyx_v_flag = __pyx_t_7;
      __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_v_txt);
      __pyx_v_txt = __pyx_t_6;
      __pyx_t_6 = 0;
    }

    /* "/home/denis/work/gevent/gevent/core.pyx":264
 *             for (flag, txt) in ((EVLIST_TIMEOUT, 'TIMEOUT'), (EVLIST_INSERTED, 'INSERTED'), (EVLIST_SIGNAL, 'SIGNAL'),
 *                                 (EVLIST_ACTIVE, 'ACTIVE'), (EVLIST_INTERNAL, 'INTERNAL'), (EVLIST_INIT, 'INIT')):
 *                 c_flag = flag             # <<<<<<<<<<<<<<
 *                 if flags & c_flag:
 *                     result.append(txt)
 */
    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_v_flag); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_flag = __pyx_t_9;

    /* "/home/denis/work/gevent/gevent/core.pyx":265
 *                                 (EVLIST_ACTIVE, 'ACTIVE'), (EVLIST_INTERNAL, 'INTERNAL'), (EVLIST_INIT, 'INIT')):
 *                 c_flag = flag
 *                 if flags & c_flag:             # <<<<<<<<<<<<<<
 *                     result.append(txt)
 *                     c_flag = c_flag ^ 0xffffffff
 */
    __pyx_t_9 = (__pyx_v_flags & __pyx_v_c_flag);
    if (__pyx_t_9) {

      /* "/home/denis/work/gevent/gevent/core.pyx":266
 *                 c_flag = flag
 *                 if flags & c_flag:
 *                     result.append(txt)             # <<<<<<<<<<<<<<
 *                     c_flag = c_flag ^ 0xffffffff
 *                     flags = flags & c_flag
 */
      __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_v_txt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "/home/denis/work/gevent/gevent/core.pyx":267
 *                 if flags & c_flag:
 *                     result.append(txt)
 *                     c_flag = c_flag ^ 0xffffffff             # <<<<<<<<<<<<<<
 *                     flags = flags & c_flag
 *             if flags:
 */
      __pyx_v_c_flag = (__pyx_v_c_flag ^ 0xffffffff);

      /* "/home/denis/work/gevent/gevent/core.pyx":268
 *                     result.append(txt)
 *                     c_flag = c_flag ^ 0xffffffff
 *                     flags = flags & c_flag             # <<<<<<<<<<<<<<
 *             if flags:
 *                 result.append(hex(flags))
 */
      __pyx_v_flags = (__pyx_v_flags & __pyx_v_c_flag);
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":269
 *                     c_flag = c_flag ^ 0xffffffff
 *                     flags = flags & c_flag
 *             if flags:             # <<<<<<<<<<<<<<
 *                 result.append(hex(flags))
 *             return '|'.join(result)
 */
  __pyx_t_9 = __pyx_v_flags;
  if (__pyx_t_9) {

    /* "/home/denis/work/gevent/gevent/core.pyx":270
 *                     flags = flags & c_flag
 *             if flags:
 *                 result.append(hex(flags))             # <<<<<<<<<<<<<<
 *             return '|'.join(result)
 * 
 */
    __pyx_t_8 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyObject_Call(__pyx_builtin_hex, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/denis/work/gevent/gevent/core.pyx":271
 *             if flags:
 *                 result.append(hex(flags))
 *             return '|'.join(result)             # <<<<<<<<<<<<<<
 * 
 *     def add(self, timeout=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_result);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_result);
  __Pyx_GIVEREF(__pyx_v_result);
  __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("gevent.core.event.flags_str.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_DECREF(__pyx_v_flag);
  __Pyx_DECREF(__pyx_v_txt);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":273
 *             return '|'.join(result)
 * 
 *     def add(self, timeout=None):             # <<<<<<<<<<<<<<
 *         """Add event to be executed after an optional *timeout* - number of seconds
 *         after which the event will be executed."""
 */

static PyObject *__pyx_pf_6gevent_4core_5event_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6gevent_4core_5event_add[] = "Add event to be executed after an optional *timeout* - number of seconds\n        after which the event will be executed.";
static PyObject *__pyx_pf_6gevent_4core_5event_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_timeout = 0;
  struct timeval __pyx_v_tv;
  double __pyx_v_c_timeout;
  int __pyx_v_result;
  PyObject *__pyx_v_errno;
  PyObject *__pyx_v_warnings;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  double __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__timeout,0};
  __Pyx_RefNannySetupContext("add");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timeout);
        if (unlikely(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), "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_timeout = values[0];
  } else {
    __pyx_v_timeout = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_timeout = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.event.add");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_timeout);
  __pyx_v_errno = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_warnings = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/core.pyx":279
 *         cdef double c_timeout
 *         cdef int result
 *         errno = 0  # event_add sometime does not set errno             # <<<<<<<<<<<<<<
 *         if timeout is None:
 *             result = event_add(&self.ev, NULL)
 */
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_DECREF(__pyx_v_errno);
  __pyx_v_errno = __pyx_int_0;

  /* "/home/denis/work/gevent/gevent/core.pyx":280
 *         cdef int result
 *         errno = 0  # event_add sometime does not set errno
 *         if timeout is None:             # <<<<<<<<<<<<<<
 *             result = event_add(&self.ev, NULL)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_timeout == Py_None);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":281
 *         errno = 0  # event_add sometime does not set errno
 *         if timeout is None:
 *             result = event_add(&self.ev, NULL)             # <<<<<<<<<<<<<<
 *         else:
 *             c_timeout = <double>timeout
 */
    __pyx_v_result = event_add((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), NULL);
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/core.pyx":283
 *             result = event_add(&self.ev, NULL)
 *         else:
 *             c_timeout = <double>timeout             # <<<<<<<<<<<<<<
 *             if c_timeout < 0.0:
 *                 #raise ValueError('Expected a non-negative number or None: %r' % (timeout, ))
 */
    __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_timeout); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_timeout = ((double)__pyx_t_2);

    /* "/home/denis/work/gevent/gevent/core.pyx":284
 *         else:
 *             c_timeout = <double>timeout
 *             if c_timeout < 0.0:             # <<<<<<<<<<<<<<
 *                 #raise ValueError('Expected a non-negative number or None: %r' % (timeout, ))
 *                 import warnings
 */
    __pyx_t_1 = (__pyx_v_c_timeout < 0.0);
    if (__pyx_t_1) {

      /* "/home/denis/work/gevent/gevent/core.pyx":286
 *             if c_timeout < 0.0:
 *                 #raise ValueError('Expected a non-negative number or None: %r' % (timeout, ))
 *                 import warnings             # <<<<<<<<<<<<<<
 *                 warnings.warn('Negative timeouts are deprecated. Use None to disable timeout.', DeprecationWarning, stacklevel=2)
 *                 result = event_add(&self.ev, NULL)
 */
      __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s__warnings), 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_v_warnings);
      __pyx_v_warnings = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "/home/denis/work/gevent/gevent/core.pyx":287
 *                 #raise ValueError('Expected a non-negative number or None: %r' % (timeout, ))
 *                 import warnings
 *                 warnings.warn('Negative timeouts are deprecated. Use None to disable timeout.', DeprecationWarning, stacklevel=2)             # <<<<<<<<<<<<<<
 *                 result = event_add(&self.ev, NULL)
 *             else:
 */
      __pyx_t_3 = PyObject_GetAttr(__pyx_v_warnings, __pyx_n_s__warn); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_3));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
      __Pyx_INCREF(__pyx_builtin_DeprecationWarning);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_builtin_DeprecationWarning);
      __Pyx_GIVEREF(__pyx_builtin_DeprecationWarning);
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__stacklevel), __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "/home/denis/work/gevent/gevent/core.pyx":288
 *                 import warnings
 *                 warnings.warn('Negative timeouts are deprecated. Use None to disable timeout.', DeprecationWarning, stacklevel=2)
 *                 result = event_add(&self.ev, NULL)             # <<<<<<<<<<<<<<
 *             else:
 *                 tv.tv_sec = <long>c_timeout
 */
      __pyx_v_result = event_add((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), NULL);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/denis/work/gevent/gevent/core.pyx":290
 *                 result = event_add(&self.ev, NULL)
 *             else:
 *                 tv.tv_sec = <long>c_timeout             # <<<<<<<<<<<<<<
 *                 tv.tv_usec = <unsigned int>((c_timeout - <double>tv.tv_sec) * 1000000.0)
 *                 result = event_add(&self.ev, &tv)
 */
      __pyx_v_tv.tv_sec = ((long)__pyx_v_c_timeout);

      /* "/home/denis/work/gevent/gevent/core.pyx":291
 *             else:
 *                 tv.tv_sec = <long>c_timeout
 *                 tv.tv_usec = <unsigned int>((c_timeout - <double>tv.tv_sec) * 1000000.0)             # <<<<<<<<<<<<<<
 *                 result = event_add(&self.ev, &tv)
 *         if result < 0:
 */
      __pyx_v_tv.tv_usec = ((unsigned int)((__pyx_v_c_timeout - ((double)__pyx_v_tv.tv_sec)) * 1000000.0));

      /* "/home/denis/work/gevent/gevent/core.pyx":292
 *                 tv.tv_sec = <long>c_timeout
 *                 tv.tv_usec = <unsigned int>((c_timeout - <double>tv.tv_sec) * 1000000.0)
 *                 result = event_add(&self.ev, &tv)             # <<<<<<<<<<<<<<
 *         if result < 0:
 *             if errno:
 */
      __pyx_v_result = event_add((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), (&__pyx_v_tv));
    }
    __pyx_L7:;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/core.pyx":293
 *                 tv.tv_usec = <unsigned int>((c_timeout - <double>tv.tv_sec) * 1000000.0)
 *                 result = event_add(&self.ev, &tv)
 *         if result < 0:             # <<<<<<<<<<<<<<
 *             if errno:
 *                 raise IOError(errno, strerror(errno))
 */
  __pyx_t_1 = (__pyx_v_result < 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":294
 *                 result = event_add(&self.ev, &tv)
 *         if result < 0:
 *             if errno:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_errno); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {

      /* "/home/denis/work/gevent/gevent/core.pyx":295
 *         if result < 0:
 *             if errno:
 *                 raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 *             else:
 *                 raise IOError("event_add(fileno=%s) returned %s" % (self.fd, result))
 */
      __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_v_errno); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = __Pyx_PyBytes_FromString(strerror(__pyx_t_7)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_errno);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_errno);
      __Pyx_GIVEREF(__pyx_v_errno);
      PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_t_6));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    /*else*/ {

      /* "/home/denis/work/gevent/gevent/core.pyx":297
 *                 raise IOError(errno, strerror(errno))
 *             else:
 *                 raise IOError("event_add(fileno=%s) returned %s" % (self.fd, result))             # <<<<<<<<<<<<<<
 *         self._addref()
 * 
 */
      __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__fd); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = PyInt_FromLong(__pyx_v_result); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_6 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L9:;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/denis/work/gevent/gevent/core.pyx":298
 *             else:
 *                 raise IOError("event_add(fileno=%s) returned %s" % (self.fd, result))
 *         self._addref()             # <<<<<<<<<<<<<<
 * 
 *     def cancel(self):
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6gevent_4core_event *)((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->__pyx_vtab)->_addref(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("gevent.core.event.add");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_errno);
  __Pyx_DECREF(__pyx_v_warnings);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_timeout);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":300
 *         self._addref()
 * 
 *     def cancel(self):             # <<<<<<<<<<<<<<
 *         """Remove event from the event queue."""
 *         cdef int result
 */

static PyObject *__pyx_pf_6gevent_4core_5event_cancel(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_6gevent_4core_5event_cancel[] = "Remove event from the event queue.";
static PyObject *__pyx_pf_6gevent_4core_5event_cancel(PyObject *__pyx_v_self, PyObject *unused) {
  int __pyx_v_result;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("cancel");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/core.pyx":303
 *         """Remove event from the event queue."""
 *         cdef int result
 *         if event_pending(&self.ev, EV_TIMEOUT|EV_SIGNAL|EV_READ|EV_WRITE, NULL):             # <<<<<<<<<<<<<<
 *             result = event_del(&self.ev)
 *             if result < 0:
 */
  __pyx_t_1 = event_pending((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), (((EV_TIMEOUT | EV_SIGNAL) | EV_READ) | EV_WRITE), NULL);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":304
 *         cdef int result
 *         if event_pending(&self.ev, EV_TIMEOUT|EV_SIGNAL|EV_READ|EV_WRITE, NULL):
 *             result = event_del(&self.ev)             # <<<<<<<<<<<<<<
 *             if result < 0:
 *                 return result
 */
    __pyx_v_result = event_del((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev));

    /* "/home/denis/work/gevent/gevent/core.pyx":305
 *         if event_pending(&self.ev, EV_TIMEOUT|EV_SIGNAL|EV_READ|EV_WRITE, NULL):
 *             result = event_del(&self.ev)
 *             if result < 0:             # <<<<<<<<<<<<<<
 *                 return result
 *             self._delref()
 */
    __pyx_t_2 = (__pyx_v_result < 0);
    if (__pyx_t_2) {

      /* "/home/denis/work/gevent/gevent/core.pyx":306
 *             result = event_del(&self.ev)
 *             if result < 0:
 *                 return result             # <<<<<<<<<<<<<<
 *             self._delref()
 *             return result
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = PyInt_FromLong(__pyx_v_result); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/denis/work/gevent/gevent/core.pyx":307
 *             if result < 0:
 *                 return result
 *             self._delref()             # <<<<<<<<<<<<<<
 *             return result
 * 
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_4core_event *)((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->__pyx_vtab)->_delref(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/denis/work/gevent/gevent/core.pyx":308
 *                 return result
 *             self._delref()
 *             return result             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyInt_FromLong(__pyx_v_result); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.event.cancel");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":310
 *             return result
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         if self.pending:
 *             pending = ' pending'
 */

static PyObject *__pyx_pf_6gevent_4core_5event___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_pending;
  PyObject *__pyx_v_events_str;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__repr__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_pending = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_events_str = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/core.pyx":311
 * 
 *     def __repr__(self):
 *         if self.pending:             # <<<<<<<<<<<<<<
 *             pending = ' pending'
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pending); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "/home/denis/work/gevent/gevent/core.pyx":312
 *     def __repr__(self):
 *         if self.pending:
 *             pending = ' pending'             # <<<<<<<<<<<<<<
 *         else:
 *             pending = ''
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
    __Pyx_DECREF(__pyx_v_pending);
    __pyx_v_pending = ((PyObject *)__pyx_kp_s_5);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/core.pyx":314
 *             pending = ' pending'
 *         else:
 *             pending = ''             # <<<<<<<<<<<<<<
 *         if self.events_str:
 *             events_str = ' %s' % self.events_str
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
    __Pyx_DECREF(__pyx_v_pending);
    __pyx_v_pending = ((PyObject *)__pyx_kp_s_6);
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/core.pyx":315
 *         else:
 *             pending = ''
 *         if self.events_str:             # <<<<<<<<<<<<<<
 *             events_str = ' %s' % self.events_str
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__events_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "/home/denis/work/gevent/gevent/core.pyx":316
 *             pending = ''
 *         if self.events_str:
 *             events_str = ' %s' % self.events_str             # <<<<<<<<<<<<<<
 *         else:
 *             events_str = ''
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__events_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_events_str);
    __pyx_v_events_str = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/core.pyx":318
 *             events_str = ' %s' % self.events_str
 *         else:
 *             events_str = ''             # <<<<<<<<<<<<<<
 *         return '<%s at %s%s fd=%s%s flags=%s cb=%s arg=%s>' % \
 *                (type(self).__name__, hex(id(self)), pending, self.fd, events_str, self.flags_str, self._callback, self._arg)
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
    __Pyx_DECREF(__pyx_v_events_str);
    __pyx_v_events_str = ((PyObject *)__pyx_kp_s_6);
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/core.pyx":319
 *         else:
 *             events_str = ''
 *         return '<%s at %s%s fd=%s%s flags=%s cb=%s arg=%s>' % \             # <<<<<<<<<<<<<<
 *                (type(self).__name__, hex(id(self)), pending, self.fd, events_str, self.flags_str, self._callback, self._arg)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "/home/denis/work/gevent/gevent/core.pyx":320
 *             events_str = ''
 *         return '<%s at %s%s fd=%s%s flags=%s cb=%s arg=%s>' % \
 *                (type(self).__name__, hex(id(self)), pending, self.fd, events_str, self.flags_str, self._callback, self._arg)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)Py_TYPE(__pyx_v_self)), __pyx_n_s____name__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __pyx_t_4 = PyObject_Call(__pyx_builtin_id, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_builtin_hex, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__fd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flags_str); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_pending);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_pending);
  __Pyx_GIVEREF(__pyx_v_pending);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_events_str);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_events_str);
  __Pyx_GIVEREF(__pyx_v_events_str);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  PyTuple_SET_ITEM(__pyx_t_6, 6, ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  __Pyx_GIVEREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  PyTuple_SET_ITEM(__pyx_t_6, 7, ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  __Pyx_GIVEREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_1 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("gevent.core.event.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_pending);
  __Pyx_DECREF(__pyx_v_events_str);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":322
 *                (type(self).__name__, hex(id(self)), pending, self.fd, events_str, self.flags_str, self._callback, self._arg)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         if self.pending:
 *             pending = ' pending'
 */

static PyObject *__pyx_pf_6gevent_4core_5event___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event___str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_pending;
  PyObject *__pyx_v_events_str;
  PyObject *__pyx_v_cb;
  PyObject *__pyx_v_arg;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__str__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_pending = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_events_str = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_cb = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_arg = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/core.pyx":323
 * 
 *     def __str__(self):
 *         if self.pending:             # <<<<<<<<<<<<<<
 *             pending = ' pending'
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pending); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "/home/denis/work/gevent/gevent/core.pyx":324
 *     def __str__(self):
 *         if self.pending:
 *             pending = ' pending'             # <<<<<<<<<<<<<<
 *         else:
 *             pending = ''
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
    __Pyx_DECREF(__pyx_v_pending);
    __pyx_v_pending = ((PyObject *)__pyx_kp_s_5);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/core.pyx":326
 *             pending = ' pending'
 *         else:
 *             pending = ''             # <<<<<<<<<<<<<<
 *         if self.events_str:
 *             events_str = ' %s' % self.events_str
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
    __Pyx_DECREF(__pyx_v_pending);
    __pyx_v_pending = ((PyObject *)__pyx_kp_s_6);
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/core.pyx":327
 *         else:
 *             pending = ''
 *         if self.events_str:             # <<<<<<<<<<<<<<
 *             events_str = ' %s' % self.events_str
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__events_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "/home/denis/work/gevent/gevent/core.pyx":328
 *             pending = ''
 *         if self.events_str:
 *             events_str = ' %s' % self.events_str             # <<<<<<<<<<<<<<
 *         else:
 *             events_str = ''
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__events_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_events_str);
    __pyx_v_events_str = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/core.pyx":330
 *             events_str = ' %s' % self.events_str
 *         else:
 *             events_str = ''             # <<<<<<<<<<<<<<
 *         cb = str(self._callback).replace('\n', '\n' + ' ' * 8)
 *         arg = pformat(self._arg, indent=2).replace('\n', '\n' + ' ' * 8)
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
    __Pyx_DECREF(__pyx_v_events_str);
    __pyx_v_events_str = ((PyObject *)__pyx_kp_s_6);
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/core.pyx":331
 *         else:
 *             events_str = ''
 *         cb = str(self._callback).replace('\n', '\n' + ' ' * 8)             # <<<<<<<<<<<<<<
 *         arg = pformat(self._arg, indent=2).replace('\n', '\n' + ' ' * 8)
 *         return '%s%s fd=%s%s flags=%s\n  cb  = %s\n  arg = %s' % \
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  __Pyx_GIVEREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__replace); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_kp_s_10), __pyx_int_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_kp_s_9), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_9));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_9));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_9));
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_v_cb);
  __pyx_v_cb = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":332
 *             events_str = ''
 *         cb = str(self._callback).replace('\n', '\n' + ' ' * 8)
 *         arg = pformat(self._arg, indent=2).replace('\n', '\n' + ' ' * 8)             # <<<<<<<<<<<<<<
 *         return '%s%s fd=%s%s flags=%s\n  cb  = %s\n  arg = %s' % \
 *                (type(self).__name__, pending, self.fd, events_str, self.flags_str, cb, arg)
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__pformat); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  __Pyx_GIVEREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__indent), __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_4, __pyx_t_1, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__replace); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Multiply(((PyObject *)__pyx_kp_s_10), __pyx_int_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_s_9), __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_9));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_9));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_9));
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_v_arg);
  __pyx_v_arg = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":333
 *         cb = str(self._callback).replace('\n', '\n' + ' ' * 8)
 *         arg = pformat(self._arg, indent=2).replace('\n', '\n' + ' ' * 8)
 *         return '%s%s fd=%s%s flags=%s\n  cb  = %s\n  arg = %s' % \             # <<<<<<<<<<<<<<
 *                (type(self).__name__, pending, self.fd, events_str, self.flags_str, cb, arg)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "/home/denis/work/gevent/gevent/core.pyx":334
 *         arg = pformat(self._arg, indent=2).replace('\n', '\n' + ' ' * 8)
 *         return '%s%s fd=%s%s flags=%s\n  cb  = %s\n  arg = %s' % \
 *                (type(self).__name__, pending, self.fd, events_str, self.flags_str, cb, arg)             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)Py_TYPE(__pyx_v_self)), __pyx_n_s____name__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__fd); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flags_str); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_pending);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_pending);
  __Pyx_GIVEREF(__pyx_v_pending);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_events_str);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_events_str);
  __Pyx_GIVEREF(__pyx_v_events_str);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_cb);
  PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_v_cb);
  __Pyx_GIVEREF(__pyx_v_cb);
  __Pyx_INCREF(__pyx_v_arg);
  PyTuple_SET_ITEM(__pyx_t_4, 6, __pyx_v_arg);
  __Pyx_GIVEREF(__pyx_v_arg);
  __pyx_t_1 = 0;
  __pyx_t_5 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.event.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_pending);
  __Pyx_DECREF(__pyx_v_events_str);
  __Pyx_DECREF(__pyx_v_cb);
  __Pyx_DECREF(__pyx_v_arg);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":336
 *                (type(self).__name__, pending, self.fd, events_str, self.flags_str, cb, arg)
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_5event___enter__(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event___enter__(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__enter__");

  /* "/home/denis/work/gevent/gevent/core.pyx":337
 * 
 *     def __enter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __exit__(self, *exit_args):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

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

/* "/home/denis/work/gevent/gevent/core.pyx":339
 *         return self
 * 
 *     def __exit__(self, *exit_args):             # <<<<<<<<<<<<<<
 *         self.cancel()
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_5event___exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_5event___exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_exit_args = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__exit__");
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__exit__", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_exit_args = __pyx_args;

  /* "/home/denis/work/gevent/gevent/core.pyx":340
 * 
 *     def __exit__(self, *exit_args):
 *         self.cancel()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__cancel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __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 = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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_AddTraceback("gevent.core.event.__exit__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_exit_args);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":346
 *     """Create a new scheduled event with evtype=EV_READ"""
 * 
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):             # <<<<<<<<<<<<<<
 *         cdef short evtype = EV_READ
 *         if persist:
 */

static int __pyx_pf_6gevent_4core_10read_event___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6gevent_4core_10read_event___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_handle;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_timeout = 0;
  PyObject *__pyx_v_arg = 0;
  PyObject *__pyx_v_persist = 0;
  short __pyx_v_evtype;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__handle,&__pyx_n_s__callback,&__pyx_n_s__timeout,&__pyx_n_s__arg,&__pyx_n_s__persist,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = __pyx_k_12;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__handle);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timeout);
        if (unlikely(value)) { values[2] = value; kw_args--; }
      }
      case  3:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__arg);
        if (unlikely(value)) { values[3] = value; kw_args--; }
      }
      case  4:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__persist);
        if (unlikely(value)) { values[4] = 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 = 346; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_handle = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_handle == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[1];
    __pyx_v_timeout = values[2];
    __pyx_v_arg = values[3];
    __pyx_v_persist = values[4];
  } else {
    __pyx_v_timeout = ((PyObject *)Py_None);
    __pyx_v_arg = ((PyObject *)Py_None);
    __pyx_v_persist = __pyx_k_12;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5:
      __pyx_v_persist = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4:
      __pyx_v_arg = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3:
      __pyx_v_timeout = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2:
      __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_handle = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_handle == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.read_event.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_timeout);
  __Pyx_INCREF(__pyx_v_arg);
  __Pyx_INCREF(__pyx_v_persist);

  /* "/home/denis/work/gevent/gevent/core.pyx":347
 * 
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):
 *         cdef short evtype = EV_READ             # <<<<<<<<<<<<<<
 *         if persist:
 *             evtype = evtype | EV_PERSIST
 */
  __pyx_v_evtype = EV_READ;

  /* "/home/denis/work/gevent/gevent/core.pyx":348
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):
 *         cdef short evtype = EV_READ
 *         if persist:             # <<<<<<<<<<<<<<
 *             evtype = evtype | EV_PERSIST
 *         event.__init__(self, evtype, handle, callback, arg)
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_persist); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":349
 *         cdef short evtype = EV_READ
 *         if persist:
 *             evtype = evtype | EV_PERSIST             # <<<<<<<<<<<<<<
 *         event.__init__(self, evtype, handle, callback, arg)
 *         self.add(timeout)
 */
    __pyx_v_evtype = (__pyx_v_evtype | EV_PERSIST);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/core.pyx":350
 *         if persist:
 *             evtype = evtype | EV_PERSIST
 *         event.__init__(self, evtype, handle, callback, arg)             # <<<<<<<<<<<<<<
 *         self.add(timeout)
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_event)), __pyx_n_s____init__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_evtype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyInt_FromLong(__pyx_v_handle); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_arg);
  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_arg);
  __Pyx_GIVEREF(__pyx_v_arg);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":351
 *             evtype = evtype | EV_PERSIST
 *         event.__init__(self, evtype, handle, callback, arg)
 *         self.add(timeout)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__add); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_timeout);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_timeout);
  __Pyx_GIVEREF(__pyx_v_timeout);
  __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.read_event.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_callback);
  __Pyx_DECREF(__pyx_v_timeout);
  __Pyx_DECREF(__pyx_v_arg);
  __Pyx_DECREF(__pyx_v_persist);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":357
 *     """Create a new scheduled event with evtype=EV_WRITE"""
 * 
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):             # <<<<<<<<<<<<<<
 *         cdef short evtype = EV_WRITE
 *         if persist:
 */

static int __pyx_pf_6gevent_4core_11write_event___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6gevent_4core_11write_event___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_handle;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_timeout = 0;
  PyObject *__pyx_v_arg = 0;
  PyObject *__pyx_v_persist = 0;
  short __pyx_v_evtype;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__handle,&__pyx_n_s__callback,&__pyx_n_s__timeout,&__pyx_n_s__arg,&__pyx_n_s__persist,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = __pyx_k_13;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__handle);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timeout);
        if (unlikely(value)) { values[2] = value; kw_args--; }
      }
      case  3:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__arg);
        if (unlikely(value)) { values[3] = value; kw_args--; }
      }
      case  4:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__persist);
        if (unlikely(value)) { values[4] = 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 = 357; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_handle = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_handle == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[1];
    __pyx_v_timeout = values[2];
    __pyx_v_arg = values[3];
    __pyx_v_persist = values[4];
  } else {
    __pyx_v_timeout = ((PyObject *)Py_None);
    __pyx_v_arg = ((PyObject *)Py_None);
    __pyx_v_persist = __pyx_k_13;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5:
      __pyx_v_persist = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4:
      __pyx_v_arg = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3:
      __pyx_v_timeout = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2:
      __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_handle = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_handle == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.write_event.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_timeout);
  __Pyx_INCREF(__pyx_v_arg);
  __Pyx_INCREF(__pyx_v_persist);

  /* "/home/denis/work/gevent/gevent/core.pyx":358
 * 
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):
 *         cdef short evtype = EV_WRITE             # <<<<<<<<<<<<<<
 *         if persist:
 *             evtype = evtype | EV_PERSIST
 */
  __pyx_v_evtype = EV_WRITE;

  /* "/home/denis/work/gevent/gevent/core.pyx":359
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):
 *         cdef short evtype = EV_WRITE
 *         if persist:             # <<<<<<<<<<<<<<
 *             evtype = evtype | EV_PERSIST
 *         event.__init__(self, evtype, handle, callback, arg)
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_persist); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":360
 *         cdef short evtype = EV_WRITE
 *         if persist:
 *             evtype = evtype | EV_PERSIST             # <<<<<<<<<<<<<<
 *         event.__init__(self, evtype, handle, callback, arg)
 *         self.add(timeout)
 */
    __pyx_v_evtype = (__pyx_v_evtype | EV_PERSIST);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/core.pyx":361
 *         if persist:
 *             evtype = evtype | EV_PERSIST
 *         event.__init__(self, evtype, handle, callback, arg)             # <<<<<<<<<<<<<<
 *         self.add(timeout)
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_event)), __pyx_n_s____init__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_evtype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyInt_FromLong(__pyx_v_handle); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_arg);
  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_arg);
  __Pyx_GIVEREF(__pyx_v_arg);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":362
 *             evtype = evtype | EV_PERSIST
 *         event.__init__(self, evtype, handle, callback, arg)
 *         self.add(timeout)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__add); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_timeout);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_timeout);
  __Pyx_GIVEREF(__pyx_v_timeout);
  __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.write_event.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_callback);
  __Pyx_DECREF(__pyx_v_timeout);
  __Pyx_DECREF(__pyx_v_arg);
  __Pyx_DECREF(__pyx_v_persist);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":368
 *     """Create a new scheduled event with evtype=EV_READ|EV_WRITE"""
 * 
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):             # <<<<<<<<<<<<<<
 *         cdef short evtype = EV_READ|EV_WRITE
 *         if persist:
 */

static PyObject *__pyx_pf_6gevent_4core_15readwrite_event___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6gevent_4core_15readwrite_event___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_6gevent_4core_15readwrite_event___init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_6gevent_4core_15readwrite_event___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  int __pyx_v_handle;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_timeout = 0;
  PyObject *__pyx_v_arg = 0;
  PyObject *__pyx_v_persist = 0;
  short __pyx_v_evtype;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__handle,&__pyx_n_s__callback,&__pyx_n_s__timeout,&__pyx_n_s__arg,&__pyx_n_s__persist,0};
  __Pyx_RefNannySetupContext("__init__");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[6] = {0,0,0,0,0,0};
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_None);
    values[5] = __pyx_k_14;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__handle);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timeout);
        if (unlikely(value)) { values[3] = value; kw_args--; }
      }
      case  4:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__arg);
        if (unlikely(value)) { values[4] = value; kw_args--; }
      }
      case  5:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__persist);
        if (unlikely(value)) { values[5] = 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 = 368; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_handle = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_handle == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[2];
    __pyx_v_timeout = values[3];
    __pyx_v_arg = values[4];
    __pyx_v_persist = values[5];
  } else {
    __pyx_v_timeout = ((PyObject *)Py_None);
    __pyx_v_arg = ((PyObject *)Py_None);
    __pyx_v_persist = __pyx_k_14;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  6:
      __pyx_v_persist = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5:
      __pyx_v_arg = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4:
      __pyx_v_timeout = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3:
      __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 2);
      __pyx_v_handle = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_handle == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.readwrite_event.__init__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_timeout);
  __Pyx_INCREF(__pyx_v_arg);
  __Pyx_INCREF(__pyx_v_persist);

  /* "/home/denis/work/gevent/gevent/core.pyx":369
 * 
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):
 *         cdef short evtype = EV_READ|EV_WRITE             # <<<<<<<<<<<<<<
 *         if persist:
 *             evtype = evtype | EV_PERSIST
 */
  __pyx_v_evtype = (EV_READ | EV_WRITE);

  /* "/home/denis/work/gevent/gevent/core.pyx":370
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):
 *         cdef short evtype = EV_READ|EV_WRITE
 *         if persist:             # <<<<<<<<<<<<<<
 *             evtype = evtype | EV_PERSIST
 *         event.__init__(self, evtype, handle, callback, arg)
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_persist); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":371
 *         cdef short evtype = EV_READ|EV_WRITE
 *         if persist:
 *             evtype = evtype | EV_PERSIST             # <<<<<<<<<<<<<<
 *         event.__init__(self, evtype, handle, callback, arg)
 *         self.add(timeout)
 */
    __pyx_v_evtype = (__pyx_v_evtype | EV_PERSIST);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/core.pyx":372
 *         if persist:
 *             evtype = evtype | EV_PERSIST
 *         event.__init__(self, evtype, handle, callback, arg)             # <<<<<<<<<<<<<<
 *         self.add(timeout)
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_event)), __pyx_n_s____init__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_evtype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyInt_FromLong(__pyx_v_handle); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_arg);
  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_arg);
  __Pyx_GIVEREF(__pyx_v_arg);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":373
 *             evtype = evtype | EV_PERSIST
 *         event.__init__(self, evtype, handle, callback, arg)
 *         self.add(timeout)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__add); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_timeout);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_timeout);
  __Pyx_GIVEREF(__pyx_v_timeout);
  __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.readwrite_event.__init__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_self);
  __Pyx_DECREF(__pyx_v_callback);
  __Pyx_DECREF(__pyx_v_timeout);
  __Pyx_DECREF(__pyx_v_arg);
  __Pyx_DECREF(__pyx_v_persist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":376
 * 
 * 
 * cdef void __simple_handler(int fd, short evtype, void *arg) with gil:             # <<<<<<<<<<<<<<
 *     cdef event self = <event>arg
 *     try:
 */

static  void __pyx_f_6gevent_4core___simple_handler(int __pyx_v_fd, short __pyx_v_evtype, void *__pyx_v_arg) {
  struct __pyx_obj_6gevent_4core_event *__pyx_v_self = 0;
  PyObject *__pyx_v_args;
  PyObject *__pyx_v_kwargs;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyGILState_STATE _save = PyGILState_Ensure();
  __Pyx_RefNannySetupContext("__simple_handler");
  __pyx_v_args = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_kwargs = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/core.pyx":377
 * 
 * cdef void __simple_handler(int fd, short evtype, void *arg) with gil:
 *     cdef event self = <event>arg             # <<<<<<<<<<<<<<
 *     try:
 *         args, kwargs = self._arg
 */
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6gevent_4core_event *)__pyx_v_arg)));
  __pyx_v_self = ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_arg);

  /* "/home/denis/work/gevent/gevent/core.pyx":378
 * cdef void __simple_handler(int fd, short evtype, void *arg) with gil:
 *     cdef event self = <event>arg
 *     try:             # <<<<<<<<<<<<<<
 *         args, kwargs = self._arg
 *         self._callback(*args, **kwargs)
 */
  /*try:*/ {
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      __Pyx_XGOTREF(__pyx_save_exc_type);
      __Pyx_XGOTREF(__pyx_save_exc_value);
      __Pyx_XGOTREF(__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/denis/work/gevent/gevent/core.pyx":379
 *     cdef event self = <event>arg
 *     try:
 *         args, kwargs = self._arg             # <<<<<<<<<<<<<<
 *         self._callback(*args, **kwargs)
 *     except:
 */
        if (PyTuple_CheckExact(__pyx_v_self->_arg) && likely(PyTuple_GET_SIZE(__pyx_v_self->_arg) == 2)) {
          PyObject* tuple = __pyx_v_self->_arg;
          __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
          __pyx_t_2 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_v_args);
          __pyx_v_args = __pyx_t_1;
          __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_v_kwargs);
          __pyx_v_kwargs = __pyx_t_2;
          __pyx_t_2 = 0;
        } else {
          __pyx_t_3 = PyObject_GetIter(__pyx_v_self->_arg); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_3, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_3, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_2);
          if (__Pyx_EndUnpack(__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_v_args);
          __pyx_v_args = __pyx_t_1;
          __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_v_kwargs);
          __pyx_v_kwargs = __pyx_t_2;
          __pyx_t_2 = 0;
        }

        /* "/home/denis/work/gevent/gevent/core.pyx":380
 *     try:
 *         args, kwargs = self._arg
 *         self._callback(*args, **kwargs)             # <<<<<<<<<<<<<<
 *     except:
 *         traceback.print_exc()
 */
        __pyx_t_2 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __pyx_t_1 = __Pyx_PyEval_CallObjectWithKeywords(__pyx_v_self->_callback, ((PyObject *)__pyx_t_2), __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "/home/denis/work/gevent/gevent/core.pyx":381
 *         args, kwargs = self._arg
 *         self._callback(*args, **kwargs)
 *     except:             # <<<<<<<<<<<<<<
 *         traceback.print_exc()
 *         try:
 */
      /*except:*/ {
        __Pyx_AddTraceback("gevent.core.__simple_handler");
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_3);

        /* "/home/denis/work/gevent/gevent/core.pyx":382
 *         self._callback(*args, **kwargs)
 *     except:
 *         traceback.print_exc()             # <<<<<<<<<<<<<<
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (self, ))
 */
        __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__traceback); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__print_exc); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "/home/denis/work/gevent/gevent/core.pyx":383
 *     except:
 *         traceback.print_exc()
 *         try:             # <<<<<<<<<<<<<<
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (self, ))
 *         except:
 */
        {
          PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
          __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
          __Pyx_XGOTREF(__pyx_save_exc_type);
          __Pyx_XGOTREF(__pyx_save_exc_value);
          __Pyx_XGOTREF(__pyx_save_exc_tb);
          /*try:*/ {

            /* "/home/denis/work/gevent/gevent/core.pyx":384
 *         traceback.print_exc()
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (self, ))             # <<<<<<<<<<<<<<
 *         except:
 *             traceback.print_exc()
 */
            __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__stderr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_INCREF(((PyObject *)__pyx_v_self));
            PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
            __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_6);
            __pyx_t_6 = 0;
            __pyx_t_6 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          }
          __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
          __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
          __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
          goto __pyx_L23_try_end;
          __pyx_L16_error:;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "/home/denis/work/gevent/gevent/core.pyx":385
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (self, ))
 *         except:             # <<<<<<<<<<<<<<
 *             traceback.print_exc()
 *         sys.exc_clear()
 */
          /*except:*/ {
            __Pyx_AddTraceback("gevent.core.__simple_handler");
            if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L18_except_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_GOTREF(__pyx_t_4);

            /* "/home/denis/work/gevent/gevent/core.pyx":386
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (self, ))
 *         except:
 *             traceback.print_exc()             # <<<<<<<<<<<<<<
 *         sys.exc_clear()
 *     finally:
 */
            __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__traceback); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L18_except_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_8 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__print_exc); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L18_except_error;}
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L18_except_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L17_exception_handled;
          }
          __pyx_L18_except_error:;
          __Pyx_XGIVEREF(__pyx_save_exc_type);
          __Pyx_XGIVEREF(__pyx_save_exc_value);
          __Pyx_XGIVEREF(__pyx_save_exc_tb);
          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
          goto __pyx_L8_except_error;
          __pyx_L17_exception_handled:;
          __Pyx_XGIVEREF(__pyx_save_exc_type);
          __Pyx_XGIVEREF(__pyx_save_exc_value);
          __Pyx_XGIVEREF(__pyx_save_exc_tb);
          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
          __pyx_L23_try_end:;
        }

        /* "/home/denis/work/gevent/gevent/core.pyx":387
 *         except:
 *             traceback.print_exc()
 *         sys.exc_clear()             # <<<<<<<<<<<<<<
 *     finally:
 *         if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):
 */
        __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__exc_clear); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L7_exception_handled;
      }
      __pyx_L8_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L4;
      __pyx_L7_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L13_try_end:;
    }
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/denis/work/gevent/gevent/core.pyx":389
 *         sys.exc_clear()
 *     finally:
 *         if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):             # <<<<<<<<<<<<<<
 *             self._delref()
 * 
 */
    __pyx_t_9 = (!event_pending((&__pyx_v_self->ev), (((EV_READ | EV_WRITE) | EV_SIGNAL) | EV_TIMEOUT), NULL));
    if (__pyx_t_9) {

      /* "/home/denis/work/gevent/gevent/core.pyx":390
 *     finally:
 *         if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):
 *             self._delref()             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_4core_event *)__pyx_v_self->__pyx_vtab)->_delref(__pyx_v_self); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L26_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L27;
    }
    __pyx_L27:;
    goto __pyx_L28;
    __pyx_L26_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L28:;
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("gevent.core.__simple_handler");
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  PyGILState_Release(_save);
}

/* "/home/denis/work/gevent/gevent/core.pyx":396
 *     """Create a new scheduled timer"""
 * 
 *     def __init__(self, float seconds, callback, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self._callback = callback
 *         self._arg = (args, kwargs)
 */

static int __pyx_pf_6gevent_4core_5timer___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6gevent_4core_5timer___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_seconds;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__seconds,&__pyx_n_s__callback,0};
  __Pyx_RefNannySetupContext("__init__");
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 2) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);

    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs);
      return -1;
    }
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seconds);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 2) ? PyTuple_GET_SIZE(__pyx_args) : 2;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_seconds = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_seconds == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) < 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_seconds = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_seconds == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_AddTraceback("gevent.core.timer.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/core.pyx":397
 * 
 *     def __init__(self, float seconds, callback, *args, **kwargs):
 *         self._callback = callback             # <<<<<<<<<<<<<<
 *         self._arg = (args, kwargs)
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 */
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_timer *)__pyx_v_self)->__pyx_base._callback);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_timer *)__pyx_v_self)->__pyx_base._callback);
  ((struct __pyx_obj_6gevent_4core_timer *)__pyx_v_self)->__pyx_base._callback = __pyx_v_callback;

  /* "/home/denis/work/gevent/gevent/core.pyx":398
 *     def __init__(self, float seconds, callback, *args, **kwargs):
 *         self._callback = callback
 *         self._arg = (args, kwargs)             # <<<<<<<<<<<<<<
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 *         self.add(seconds)
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_args);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_args);
  __Pyx_GIVEREF(__pyx_v_args);
  __Pyx_INCREF(__pyx_v_kwargs);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_timer *)__pyx_v_self)->__pyx_base._arg);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_timer *)__pyx_v_self)->__pyx_base._arg);
  ((struct __pyx_obj_6gevent_4core_timer *)__pyx_v_self)->__pyx_base._arg = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":399
 *         self._callback = callback
 *         self._arg = (args, kwargs)
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)             # <<<<<<<<<<<<<<
 *         self.add(seconds)
 * 
 */
  evtimer_set((&((struct __pyx_obj_6gevent_4core_timer *)__pyx_v_self)->__pyx_base.ev), __pyx_f_6gevent_4core___simple_handler, ((void *)__pyx_v_self));

  /* "/home/denis/work/gevent/gevent/core.pyx":400
 *         self._arg = (args, kwargs)
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 *         self.add(seconds)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__add); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_seconds); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.timer.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":406
 *     """Create a new persistent signal event"""
 * 
 *     def __init__(self, int signalnum, callback, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self._callback = callback
 *         self._arg = (args, kwargs)
 */

static int __pyx_pf_6gevent_4core_6signal___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6gevent_4core_6signal___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_signalnum;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__signalnum,&__pyx_n_s__callback,0};
  __Pyx_RefNannySetupContext("__init__");
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 2) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);

    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs);
      return -1;
    }
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__signalnum);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 2) ? PyTuple_GET_SIZE(__pyx_args) : 2;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_signalnum = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_signalnum == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) < 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_signalnum = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_signalnum == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_AddTraceback("gevent.core.signal.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/core.pyx":407
 * 
 *     def __init__(self, int signalnum, callback, *args, **kwargs):
 *         self._callback = callback             # <<<<<<<<<<<<<<
 *         self._arg = (args, kwargs)
 *         event_set(&self.ev, signalnum, EV_SIGNAL|EV_PERSIST, __simple_handler, <void*>self)
 */
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_signal *)__pyx_v_self)->__pyx_base._callback);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_signal *)__pyx_v_self)->__pyx_base._callback);
  ((struct __pyx_obj_6gevent_4core_signal *)__pyx_v_self)->__pyx_base._callback = __pyx_v_callback;

  /* "/home/denis/work/gevent/gevent/core.pyx":408
 *     def __init__(self, int signalnum, callback, *args, **kwargs):
 *         self._callback = callback
 *         self._arg = (args, kwargs)             # <<<<<<<<<<<<<<
 *         event_set(&self.ev, signalnum, EV_SIGNAL|EV_PERSIST, __simple_handler, <void*>self)
 *         self.add()
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_args);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_args);
  __Pyx_GIVEREF(__pyx_v_args);
  __Pyx_INCREF(__pyx_v_kwargs);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_signal *)__pyx_v_self)->__pyx_base._arg);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_signal *)__pyx_v_self)->__pyx_base._arg);
  ((struct __pyx_obj_6gevent_4core_signal *)__pyx_v_self)->__pyx_base._arg = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":409
 *         self._callback = callback
 *         self._arg = (args, kwargs)
 *         event_set(&self.ev, signalnum, EV_SIGNAL|EV_PERSIST, __simple_handler, <void*>self)             # <<<<<<<<<<<<<<
 *         self.add()
 * 
 */
  event_set((&((struct __pyx_obj_6gevent_4core_signal *)__pyx_v_self)->__pyx_base.ev), __pyx_v_signalnum, (EV_SIGNAL | EV_PERSIST), __pyx_f_6gevent_4core___simple_handler, ((void *)__pyx_v_self));

  /* "/home/denis/work/gevent/gevent/core.pyx":410
 *         self._arg = (args, kwargs)
 *         event_set(&self.ev, signalnum, EV_SIGNAL|EV_PERSIST, __simple_handler, <void*>self)
 *         self.add()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__add); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __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 = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.signal.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":416
 *     """An event that is scheduled to run in the current loop iteration"""
 * 
 *     def __init__(self, callback, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self._callback = callback
 *         self._arg = (args, kwargs)
 */

static int __pyx_pf_6gevent_4core_12active_event___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6gevent_4core_12active_event___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__callback,0};
  __Pyx_RefNannySetupContext("__init__");
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);

    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs);
      return -1;
    }
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 1) ? PyTuple_GET_SIZE(__pyx_args) : 1;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_callback = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_AddTraceback("gevent.core.active_event.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/core.pyx":417
 * 
 *     def __init__(self, callback, *args, **kwargs):
 *         self._callback = callback             # <<<<<<<<<<<<<<
 *         self._arg = (args, kwargs)
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 */
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_active_event *)__pyx_v_self)->__pyx_base._callback);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_active_event *)__pyx_v_self)->__pyx_base._callback);
  ((struct __pyx_obj_6gevent_4core_active_event *)__pyx_v_self)->__pyx_base._callback = __pyx_v_callback;

  /* "/home/denis/work/gevent/gevent/core.pyx":418
 *     def __init__(self, callback, *args, **kwargs):
 *         self._callback = callback
 *         self._arg = (args, kwargs)             # <<<<<<<<<<<<<<
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 *         self._addref()
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_args);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_args);
  __Pyx_GIVEREF(__pyx_v_args);
  __Pyx_INCREF(__pyx_v_kwargs);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_active_event *)__pyx_v_self)->__pyx_base._arg);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_active_event *)__pyx_v_self)->__pyx_base._arg);
  ((struct __pyx_obj_6gevent_4core_active_event *)__pyx_v_self)->__pyx_base._arg = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":419
 *         self._callback = callback
 *         self._arg = (args, kwargs)
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)             # <<<<<<<<<<<<<<
 *         self._addref()
 *         event_active(&self.ev, EV_TIMEOUT, 1)
 */
  evtimer_set((&((struct __pyx_obj_6gevent_4core_active_event *)__pyx_v_self)->__pyx_base.ev), __pyx_f_6gevent_4core___simple_handler, ((void *)__pyx_v_self));

  /* "/home/denis/work/gevent/gevent/core.pyx":420
 *         self._arg = (args, kwargs)
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 *         self._addref()             # <<<<<<<<<<<<<<
 *         event_active(&self.ev, EV_TIMEOUT, 1)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_4core_active_event *)((struct __pyx_obj_6gevent_4core_active_event *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._addref(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":421
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 *         self._addref()
 *         event_active(&self.ev, EV_TIMEOUT, 1)             # <<<<<<<<<<<<<<
 * 
 *     def add(self, timeout=None):
 */
  event_active((&((struct __pyx_obj_6gevent_4core_active_event *)__pyx_v_self)->__pyx_base.ev), EV_TIMEOUT, 1);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("gevent.core.active_event.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":423
 *         event_active(&self.ev, EV_TIMEOUT, 1)
 * 
 *     def add(self, timeout=None):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_12active_event_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12active_event_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_timeout = 0;
  PyObject *__pyx_r = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__timeout,0};
  __Pyx_RefNannySetupContext("add");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timeout);
        if (unlikely(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), "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_timeout = values[0];
  } else {
    __pyx_v_timeout = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_timeout = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.active_event.add");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/core.pyx":424
 * 
 *     def add(self, timeout=None):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("gevent.core.active_event.add");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":427
 * 
 * 
 * def init():             # <<<<<<<<<<<<<<
 *     """Initialize event queue."""
 *     event_init()
 */

static PyObject *__pyx_pf_6gevent_4core_init(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_6gevent_4core_init[] = "Initialize event queue.";
static PyObject *__pyx_pf_6gevent_4core_init(PyObject *__pyx_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("init");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/core.pyx":429
 * def init():
 *     """Initialize event queue."""
 *     event_init()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  event_init();

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

/* "/home/denis/work/gevent/gevent/core.pyx":432
 * 
 * 
 * def dispatch():             # <<<<<<<<<<<<<<
 *     """Dispatch all events on the event queue.
 *     Returns 0 on success, and 1 if no events are registered.
 */

static PyObject *__pyx_pf_6gevent_4core_dispatch(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_6gevent_4core_dispatch[] = "Dispatch all events on the event queue.\n    Returns 0 on success, and 1 if no events are registered.\n    May raise IOError.\n    ";
static PyObject *__pyx_pf_6gevent_4core_dispatch(PyObject *__pyx_self, PyObject *unused) {
  int __pyx_v_ret;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("dispatch");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/core.pyx":438
 *     """
 *     cdef int ret
 *     with nogil:             # <<<<<<<<<<<<<<
 *         ret = event_dispatch()
 *     if ret < 0:
 */
  { PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/denis/work/gevent/gevent/core.pyx":439
 *     cdef int ret
 *     with nogil:
 *         ret = event_dispatch()             # <<<<<<<<<<<<<<
 *     if ret < 0:
 *         raise IOError(errno, strerror(errno))
 */
      __pyx_v_ret = event_dispatch();
    }
    /*finally:*/ {

      /* "/home/denis/work/gevent/gevent/core.pyx":438
 *     """
 *     cdef int ret
 *     with nogil:             # <<<<<<<<<<<<<<
 *         ret = event_dispatch()
 *     if ret < 0:
 */
      Py_BLOCK_THREADS
    }
  }

  /* "/home/denis/work/gevent/gevent/core.pyx":440
 *     with nogil:
 *         ret = event_dispatch()
 *     if ret < 0:             # <<<<<<<<<<<<<<
 *         raise IOError(errno, strerror(errno))
 *     return ret
 */
  __pyx_t_1 = (__pyx_v_ret < 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":441
 *         ret = event_dispatch()
 *     if ret < 0:
 *         raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_2 = PyInt_FromLong(errno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/denis/work/gevent/gevent/core.pyx":442
 *     if ret < 0:
 *         raise IOError(errno, strerror(errno))
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_ret); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.dispatch");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":445
 * 
 * 
 * def loop(nonblock=False):             # <<<<<<<<<<<<<<
 *     """Dispatch all pending events on queue in a single pass.
 *     Returns 0 on success, and 1 if no events are registered.
 */

static PyObject *__pyx_pf_6gevent_4core_loop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6gevent_4core_loop[] = "Dispatch all pending events on queue in a single pass.\n    Returns 0 on success, and 1 if no events are registered.\n    May raise IOError.\n    ";
static PyObject *__pyx_pf_6gevent_4core_loop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_nonblock = 0;
  int __pyx_v_flags;
  int __pyx_v_ret;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__nonblock,0};
  __Pyx_RefNannySetupContext("loop");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    values[0] = __pyx_k_15;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nonblock);
        if (unlikely(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), "loop") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_nonblock = values[0];
  } else {
    __pyx_v_nonblock = __pyx_k_15;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_nonblock = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("loop", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.loop");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_nonblock);

  /* "/home/denis/work/gevent/gevent/core.pyx":451
 *     """
 *     cdef int flags, ret
 *     flags = EVLOOP_ONCE             # <<<<<<<<<<<<<<
 *     if nonblock:
 *         flags = EVLOOP_ONCE|EVLOOP_NONBLOCK
 */
  __pyx_v_flags = EVLOOP_ONCE;

  /* "/home/denis/work/gevent/gevent/core.pyx":452
 *     cdef int flags, ret
 *     flags = EVLOOP_ONCE
 *     if nonblock:             # <<<<<<<<<<<<<<
 *         flags = EVLOOP_ONCE|EVLOOP_NONBLOCK
 *     with nogil:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_nonblock); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":453
 *     flags = EVLOOP_ONCE
 *     if nonblock:
 *         flags = EVLOOP_ONCE|EVLOOP_NONBLOCK             # <<<<<<<<<<<<<<
 *     with nogil:
 *         ret = event_loop(flags)
 */
    __pyx_v_flags = (EVLOOP_ONCE | EVLOOP_NONBLOCK);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/core.pyx":454
 *     if nonblock:
 *         flags = EVLOOP_ONCE|EVLOOP_NONBLOCK
 *     with nogil:             # <<<<<<<<<<<<<<
 *         ret = event_loop(flags)
 *     if ret < 0:
 */
  { PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/denis/work/gevent/gevent/core.pyx":455
 *         flags = EVLOOP_ONCE|EVLOOP_NONBLOCK
 *     with nogil:
 *         ret = event_loop(flags)             # <<<<<<<<<<<<<<
 *     if ret < 0:
 *         raise IOError(errno, strerror(errno))
 */
      __pyx_v_ret = event_loop(__pyx_v_flags);
    }
    /*finally:*/ {

      /* "/home/denis/work/gevent/gevent/core.pyx":454
 *     if nonblock:
 *         flags = EVLOOP_ONCE|EVLOOP_NONBLOCK
 *     with nogil:             # <<<<<<<<<<<<<<
 *         ret = event_loop(flags)
 *     if ret < 0:
 */
      Py_BLOCK_THREADS
    }
  }

  /* "/home/denis/work/gevent/gevent/core.pyx":456
 *     with nogil:
 *         ret = event_loop(flags)
 *     if ret < 0:             # <<<<<<<<<<<<<<
 *         raise IOError(errno, strerror(errno))
 *     return ret
 */
  __pyx_t_1 = (__pyx_v_ret < 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":457
 *         ret = event_loop(flags)
 *     if ret < 0:
 *         raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_2 = PyInt_FromLong(errno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/denis/work/gevent/gevent/core.pyx":458
 *     if ret < 0:
 *         raise IOError(errno, strerror(errno))
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_ret); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.loop");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_nonblock);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":461
 * 
 * 
 * def get_version():             # <<<<<<<<<<<<<<
 *     """Wrapper for :meth:`event_get_version`"""
 *     return event_get_version()
 */

static PyObject *__pyx_pf_6gevent_4core_get_version(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_6gevent_4core_get_version[] = "Wrapper for :meth:`event_get_version`";
static PyObject *__pyx_pf_6gevent_4core_get_version(PyObject *__pyx_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_version");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/core.pyx":463
 * def get_version():
 *     """Wrapper for :meth:`event_get_version`"""
 *     return event_get_version()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBytes_FromString(event_get_version()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("gevent.core.get_version");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":466
 * 
 * 
 * def get_method():             # <<<<<<<<<<<<<<
 *     """Wrapper for :meth:`event_get_method`"""
 *     return event_get_method()
 */

static PyObject *__pyx_pf_6gevent_4core_get_method(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_6gevent_4core_get_method[] = "Wrapper for :meth:`event_get_method`";
static PyObject *__pyx_pf_6gevent_4core_get_method(PyObject *__pyx_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_method");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/core.pyx":468
 * def get_method():
 *     """Wrapper for :meth:`event_get_method`"""
 *     return event_get_method()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBytes_FromString(event_get_method()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("gevent.core.get_method");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":479
 * # _EVENT_VERSION is available since libevent 1.4.0-beta
 * 
 * def get_header_version():             # <<<<<<<<<<<<<<
 *     """Return _EVENT_VERSION"""
 *     emit_ifdef()
 */

static PyObject *__pyx_pf_6gevent_4core_get_header_version(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_6gevent_4core_get_header_version[] = "Return _EVENT_VERSION";
static PyObject *__pyx_pf_6gevent_4core_get_header_version(PyObject *__pyx_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_header_version");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/core.pyx":481
 * def get_header_version():
 *     """Return _EVENT_VERSION"""
 *     emit_ifdef()             # <<<<<<<<<<<<<<
 *     return _EVENT_VERSION
 *     emit_endif()
 */
  #if defined(_EVENT_VERSION) //();

  /* "/home/denis/work/gevent/gevent/core.pyx":482
 *     """Return _EVENT_VERSION"""
 *     emit_ifdef()
 *     return _EVENT_VERSION             # <<<<<<<<<<<<<<
 *     emit_endif()
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBytes_FromString(_EVENT_VERSION); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "/home/denis/work/gevent/gevent/core.pyx":483
 *     emit_ifdef()
 *     return _EVENT_VERSION
 *     emit_endif()             # <<<<<<<<<<<<<<
 * 
 * # event_reinit is available since libevent 1.4.1-beta,
 */
  #endif //();

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("gevent.core.get_header_version");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":490
 * # which will work in every version other than 1.4.0-beta
 * 
 * def reinit():             # <<<<<<<<<<<<<<
 *     """Wrapper for :meth:`event_reinit`."""
 *     emit_ifdef()
 */

static PyObject *__pyx_pf_6gevent_4core_reinit(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_6gevent_4core_reinit[] = "Wrapper for :meth:`event_reinit`.";
static PyObject *__pyx_pf_6gevent_4core_reinit(PyObject *__pyx_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("reinit");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/core.pyx":492
 * def reinit():
 *     """Wrapper for :meth:`event_reinit`."""
 *     emit_ifdef()             # <<<<<<<<<<<<<<
 *     return event_reinit(current_base)
 *     emit_endif()
 */
  #if defined(_EVENT_VERSION) //();

  /* "/home/denis/work/gevent/gevent/core.pyx":493
 *     """Wrapper for :meth:`event_reinit`."""
 *     emit_ifdef()
 *     return event_reinit(current_base)             # <<<<<<<<<<<<<<
 *     emit_endif()
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(event_reinit(current_base)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "/home/denis/work/gevent/gevent/core.pyx":494
 *     emit_ifdef()
 *     return event_reinit(current_base)
 *     emit_endif()             # <<<<<<<<<<<<<<
 * 
 * include "evdns.pxi"
 */
  #endif //();

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("gevent.core.reinit");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":40
 * 
 * 
 * def dns_init():             # <<<<<<<<<<<<<<
 *     """Initialize async DNS resolver."""
 *     evdns_init()
 */

static PyObject *__pyx_pf_6gevent_4core_dns_init(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_6gevent_4core_dns_init[] = "Initialize async DNS resolver.";
static PyObject *__pyx_pf_6gevent_4core_dns_init(PyObject *__pyx_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("dns_init");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":42
 * def dns_init():
 *     """Initialize async DNS resolver."""
 *     evdns_init()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  evdns_init();

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

/* "/home/denis/work/gevent/gevent/evdns.pxi":45
 * 
 * 
 * def dns_shutdown(int fail_requests=0):             # <<<<<<<<<<<<<<
 *     """Shutdown the async DNS resolver and terminate all active requests."""
 *     evdns_shutdown(fail_requests)
 */

static PyObject *__pyx_pf_6gevent_4core_dns_shutdown(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6gevent_4core_dns_shutdown[] = "Shutdown the async DNS resolver and terminate all active requests.";
static PyObject *__pyx_pf_6gevent_4core_dns_shutdown(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_fail_requests;
  PyObject *__pyx_r = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fail_requests,0};
  __Pyx_RefNannySetupContext("dns_shutdown");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fail_requests);
        if (unlikely(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), "dns_shutdown") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_fail_requests = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_fail_requests == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_fail_requests = ((int)0);
    }
  } else {
    __pyx_v_fail_requests = ((int)0);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_fail_requests = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_fail_requests == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dns_shutdown", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.dns_shutdown");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":47
 * def dns_shutdown(int fail_requests=0):
 *     """Shutdown the async DNS resolver and terminate all active requests."""
 *     evdns_shutdown(fail_requests)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  evdns_shutdown(__pyx_v_fail_requests);

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

/* "/home/denis/work/gevent/gevent/evdns.pxi":50
 * 
 * 
 * def dns_err_to_string(int err):             # <<<<<<<<<<<<<<
 *     cdef const_char_ptr result = evdns_err_to_string(err)
 *     if result:
 */

static PyObject *__pyx_pf_6gevent_4core_dns_err_to_string(PyObject *__pyx_self, PyObject *__pyx_arg_err); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_dns_err_to_string(PyObject *__pyx_self, PyObject *__pyx_arg_err) {
  int __pyx_v_err;
  const char* __pyx_v_result;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("dns_err_to_string");
  __pyx_self = __pyx_self;
  assert(__pyx_arg_err); {
    __pyx_v_err = __Pyx_PyInt_AsInt(__pyx_arg_err); if (unlikely((__pyx_v_err == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.dns_err_to_string");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":51
 * 
 * def dns_err_to_string(int err):
 *     cdef const_char_ptr result = evdns_err_to_string(err)             # <<<<<<<<<<<<<<
 *     if result:
 *         return result
 */
  __pyx_v_result = evdns_err_to_string(__pyx_v_err);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":52
 * def dns_err_to_string(int err):
 *     cdef const_char_ptr result = evdns_err_to_string(err)
 *     if result:             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  __pyx_t_1 = (__pyx_v_result != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":53
 *     cdef const_char_ptr result = evdns_err_to_string(err)
 *     if result:
 *         return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_result); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_r = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.dns_err_to_string");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":56
 * 
 * 
 * cdef void __evdns_callback(int code, char type, int count, int ttl, void *addrs, void *arg) with gil:             # <<<<<<<<<<<<<<
 *     cdef int i
 *     cdef object callback = <object>arg
 */

static  void __pyx_f_6gevent_4core___evdns_callback(int __pyx_v_code, char __pyx_v_type, int __pyx_v_count, int __pyx_v_ttl, void *__pyx_v_addrs, void *__pyx_v_arg) {
  int __pyx_v_i;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_addr;
  PyObject *__pyx_v_result;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyGILState_STATE _save = PyGILState_Ensure();
  __Pyx_RefNannySetupContext("__evdns_callback");
  __pyx_v_addr = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":58
 * cdef void __evdns_callback(int code, char type, int count, int ttl, void *addrs, void *arg) with gil:
 *     cdef int i
 *     cdef object callback = <object>arg             # <<<<<<<<<<<<<<
 *     Py_DECREF(callback)
 *     cdef object addr
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_arg));
  __pyx_v_callback = ((PyObject *)__pyx_v_arg);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":59
 *     cdef int i
 *     cdef object callback = <object>arg
 *     Py_DECREF(callback)             # <<<<<<<<<<<<<<
 *     cdef object addr
 *     cdef object result
 */
  Py_DECREF(__pyx_v_callback);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":63
 *     cdef object result
 * 
 *     if type == DNS_IPv4_A:             # <<<<<<<<<<<<<<
 *         result = []
 *         for i from 0 <= i < count:
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__DNS_IPv4_A); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":64
 * 
 *     if type == DNS_IPv4_A:
 *         result = []             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < count:
 *             addr = PyString_FromStringAndSize(&(<char *>addrs)[i*4], 4)
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(__pyx_v_result);
    __pyx_v_result = ((PyObject *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "/home/denis/work/gevent/gevent/evdns.pxi":65
 *     if type == DNS_IPv4_A:
 *         result = []
 *         for i from 0 <= i < count:             # <<<<<<<<<<<<<<
 *             addr = PyString_FromStringAndSize(&(<char *>addrs)[i*4], 4)
 *             result.append(addr)
 */
    __pyx_t_5 = __pyx_v_count;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {

      /* "/home/denis/work/gevent/gevent/evdns.pxi":66
 *         result = []
 *         for i from 0 <= i < count:
 *             addr = PyString_FromStringAndSize(&(<char *>addrs)[i*4], 4)             # <<<<<<<<<<<<<<
 *             result.append(addr)
 *     elif type == DNS_IPv6_AAAA:
 */
      __pyx_t_3 = PyString_FromStringAndSize((&(((char *)__pyx_v_addrs)[(__pyx_v_i * 4)])), 4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_v_addr);
      __pyx_v_addr = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "/home/denis/work/gevent/gevent/evdns.pxi":67
 *         for i from 0 <= i < count:
 *             addr = PyString_FromStringAndSize(&(<char *>addrs)[i*4], 4)
 *             result.append(addr)             # <<<<<<<<<<<<<<
 *     elif type == DNS_IPv6_AAAA:
 *         result = []
 */
      __pyx_t_3 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_v_addr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    goto __pyx_L3;
  }

  /* "/home/denis/work/gevent/gevent/evdns.pxi":68
 *             addr = PyString_FromStringAndSize(&(<char *>addrs)[i*4], 4)
 *             result.append(addr)
 *     elif type == DNS_IPv6_AAAA:             # <<<<<<<<<<<<<<
 *         result = []
 *         for i from 0 <= i < count:
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_type); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__DNS_IPv6_AAAA); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":69
 *             result.append(addr)
 *     elif type == DNS_IPv6_AAAA:
 *         result = []             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < count:
 *             addr = PyString_FromStringAndSize(&(<char *>addrs)[i*16], 16)
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(__pyx_v_result);
    __pyx_v_result = ((PyObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "/home/denis/work/gevent/gevent/evdns.pxi":70
 *     elif type == DNS_IPv6_AAAA:
 *         result = []
 *         for i from 0 <= i < count:             # <<<<<<<<<<<<<<
 *             addr = PyString_FromStringAndSize(&(<char *>addrs)[i*16], 16)
 *             result.append(addr)
 */
    __pyx_t_5 = __pyx_v_count;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {

      /* "/home/denis/work/gevent/gevent/evdns.pxi":71
 *         result = []
 *         for i from 0 <= i < count:
 *             addr = PyString_FromStringAndSize(&(<char *>addrs)[i*16], 16)             # <<<<<<<<<<<<<<
 *             result.append(addr)
 *     elif type == DNS_PTR and count == 1: # only 1 PTR possible
 */
      __pyx_t_1 = PyString_FromStringAndSize((&(((char *)__pyx_v_addrs)[(__pyx_v_i * 16)])), 16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_v_addr);
      __pyx_v_addr = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "/home/denis/work/gevent/gevent/evdns.pxi":72
 *         for i from 0 <= i < count:
 *             addr = PyString_FromStringAndSize(&(<char *>addrs)[i*16], 16)
 *             result.append(addr)             # <<<<<<<<<<<<<<
 *     elif type == DNS_PTR and count == 1: # only 1 PTR possible
 *         result = PyString_FromString((<char **>addrs)[0])
 */
      __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_v_addr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    goto __pyx_L3;
  }

  /* "/home/denis/work/gevent/gevent/evdns.pxi":73
 *             addr = PyString_FromStringAndSize(&(<char *>addrs)[i*16], 16)
 *             result.append(addr)
 *     elif type == DNS_PTR and count == 1: # only 1 PTR possible             # <<<<<<<<<<<<<<
 *         result = PyString_FromString((<char **>addrs)[0])
 *     else:
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__DNS_PTR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {
    __pyx_t_6 = (__pyx_v_count == 1);
    __pyx_t_7 = __pyx_t_6;
  } else {
    __pyx_t_7 = __pyx_t_4;
  }
  if (__pyx_t_7) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":74
 *             result.append(addr)
 *     elif type == DNS_PTR and count == 1: # only 1 PTR possible
 *         result = PyString_FromString((<char **>addrs)[0])             # <<<<<<<<<<<<<<
 *     else:
 *         result = None
 */
    __pyx_t_3 = PyString_FromString((((char **)__pyx_v_addrs)[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":76
 *         result = PyString_FromString((<char **>addrs)[0])
 *     else:
 *         result = None             # <<<<<<<<<<<<<<
 *     try:
 *         callback(code, type, ttl, result)
 */
    __Pyx_INCREF(Py_None);
    __Pyx_DECREF(__pyx_v_result);
    __pyx_v_result = Py_None;
  }
  __pyx_L3:;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":77
 *     else:
 *         result = None
 *     try:             # <<<<<<<<<<<<<<
 *         callback(code, type, ttl, result)
 *     except:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/denis/work/gevent/gevent/evdns.pxi":78
 *         result = None
 *     try:
 *         callback(code, type, ttl, result)             # <<<<<<<<<<<<<<
 *     except:
 *         traceback.print_exc()
 */
      __pyx_t_3 = PyInt_FromLong(__pyx_v_code); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyInt_FromLong(__pyx_v_type); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyInt_FromLong(__pyx_v_ttl); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_result);
      PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_v_result);
      __Pyx_GIVEREF(__pyx_v_result);
      __pyx_t_3 = 0;
      __pyx_t_2 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_v_callback, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L15_try_end;
    __pyx_L8_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/denis/work/gevent/gevent/evdns.pxi":79
 *     try:
 *         callback(code, type, ttl, result)
 *     except:             # <<<<<<<<<<<<<<
 *         traceback.print_exc()
 *         sys.exc_clear()
 */
    /*except:*/ {
      __Pyx_AddTraceback("gevent.core.__evdns_callback");
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_8, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_2);

      /* "/home/denis/work/gevent/gevent/evdns.pxi":80
 *         callback(code, type, ttl, result)
 *     except:
 *         traceback.print_exc()             # <<<<<<<<<<<<<<
 *         sys.exc_clear()
 * 
 */
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__traceback); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__print_exc); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "/home/denis/work/gevent/gevent/evdns.pxi":81
 *     except:
 *         traceback.print_exc()
 *         sys.exc_clear()             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exc_clear); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L9_exception_handled;
    }
    __pyx_L10_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L9_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L15_try_end:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("gevent.core.__evdns_callback");
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_DECREF(__pyx_v_addr);
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_RefNannyFinishContext();
  PyGILState_Release(_save);
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":84
 * 
 * 
 * def dns_resolve_ipv4(char *name, int flags, object callback):             # <<<<<<<<<<<<<<
 *     """Lookup an A record for a given name.
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_dns_resolve_ipv4(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6gevent_4core_dns_resolve_ipv4[] = "Lookup an A record for a given name.\n\n    - *name*     -- DNS hostname\n    - *flags*    -- either 0 or DNS_QUERY_NO_SEARCH\n    - *callback* -- callback with ``(result, type, ttl, addrs)`` prototype\n    ";
static PyObject *__pyx_pf_6gevent_4core_dns_resolve_ipv4(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_name;
  int __pyx_v_flags;
  PyObject *__pyx_v_callback = 0;
  int __pyx_v_result;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,&__pyx_n_s__flags,&__pyx_n_s__callback,0};
  __Pyx_RefNannySetupContext("dns_resolve_ipv4");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_ipv4", 1, 3, 3, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_ipv4", 1, 3, 3, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "dns_resolve_ipv4") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_name = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_name = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_flags = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dns_resolve_ipv4", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.dns_resolve_ipv4");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_callback);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":91
 *     - *callback* -- callback with ``(result, type, ttl, addrs)`` prototype
 *     """
 *     cdef int result = evdns_resolve_ipv4(name, flags, __evdns_callback, <void *>callback)             # <<<<<<<<<<<<<<
 *     if result:
 *         raise IOError('evdns_resolve_ipv4(%r, %r) returned %s' % (name, flags, result, ))
 */
  __pyx_v_result = evdns_resolve_ipv4(__pyx_v_name, __pyx_v_flags, __pyx_f_6gevent_4core___evdns_callback, ((void *)__pyx_v_callback));

  /* "/home/denis/work/gevent/gevent/evdns.pxi":92
 *     """
 *     cdef int result = evdns_resolve_ipv4(name, flags, __evdns_callback, <void *>callback)
 *     if result:             # <<<<<<<<<<<<<<
 *         raise IOError('evdns_resolve_ipv4(%r, %r) returned %s' % (name, flags, result, ))
 *     Py_INCREF(callback)
 */
  __pyx_t_1 = __pyx_v_result;
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":93
 *     cdef int result = evdns_resolve_ipv4(name, flags, __evdns_callback, <void *>callback)
 *     if result:
 *         raise IOError('evdns_resolve_ipv4(%r, %r) returned %s' % (name, flags, result, ))             # <<<<<<<<<<<<<<
 *     Py_INCREF(callback)
 * 
 */
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyInt_FromLong(__pyx_v_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_16), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":94
 *     if result:
 *         raise IOError('evdns_resolve_ipv4(%r, %r) returned %s' % (name, flags, result, ))
 *     Py_INCREF(callback)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(__pyx_v_callback);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.dns_resolve_ipv4");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_callback);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":97
 * 
 * 
 * def dns_resolve_ipv6(char *name, int flags, object callback):             # <<<<<<<<<<<<<<
 *     """Lookup an AAAA record for a given name.
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_dns_resolve_ipv6(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6gevent_4core_dns_resolve_ipv6[] = "Lookup an AAAA record for a given name.\n\n    - *name*     -- DNS hostname\n    - *flags*    -- either 0 or DNS_QUERY_NO_SEARCH\n    - *callback* -- callback with ``(result, type, ttl, addrs)`` prototype\n    ";
static PyObject *__pyx_pf_6gevent_4core_dns_resolve_ipv6(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_name;
  int __pyx_v_flags;
  PyObject *__pyx_v_callback = 0;
  int __pyx_v_result;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,&__pyx_n_s__flags,&__pyx_n_s__callback,0};
  __Pyx_RefNannySetupContext("dns_resolve_ipv6");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_ipv6", 1, 3, 3, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_ipv6", 1, 3, 3, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "dns_resolve_ipv6") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_name = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_name = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_flags = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dns_resolve_ipv6", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.dns_resolve_ipv6");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_callback);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":104
 *     - *callback* -- callback with ``(result, type, ttl, addrs)`` prototype
 *     """
 *     cdef int result = evdns_resolve_ipv6(name, flags, __evdns_callback, <void *>callback)             # <<<<<<<<<<<<<<
 *     if result:
 *         raise IOError('evdns_resolve_ip6(%r, %r) returned %s' % (name, flags, result, ))
 */
  __pyx_v_result = evdns_resolve_ipv6(__pyx_v_name, __pyx_v_flags, __pyx_f_6gevent_4core___evdns_callback, ((void *)__pyx_v_callback));

  /* "/home/denis/work/gevent/gevent/evdns.pxi":105
 *     """
 *     cdef int result = evdns_resolve_ipv6(name, flags, __evdns_callback, <void *>callback)
 *     if result:             # <<<<<<<<<<<<<<
 *         raise IOError('evdns_resolve_ip6(%r, %r) returned %s' % (name, flags, result, ))
 *     Py_INCREF(callback)
 */
  __pyx_t_1 = __pyx_v_result;
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":106
 *     cdef int result = evdns_resolve_ipv6(name, flags, __evdns_callback, <void *>callback)
 *     if result:
 *         raise IOError('evdns_resolve_ip6(%r, %r) returned %s' % (name, flags, result, ))             # <<<<<<<<<<<<<<
 *     Py_INCREF(callback)
 * 
 */
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyInt_FromLong(__pyx_v_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":107
 *     if result:
 *         raise IOError('evdns_resolve_ip6(%r, %r) returned %s' % (name, flags, result, ))
 *     Py_INCREF(callback)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(__pyx_v_callback);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.dns_resolve_ipv6");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_callback);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":110
 * 
 * 
 * def dns_resolve_reverse(char* packed_ip, int flags, object callback):             # <<<<<<<<<<<<<<
 *     """Lookup a PTR record for a given IPv4 address.
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_dns_resolve_reverse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6gevent_4core_dns_resolve_reverse[] = "Lookup a PTR record for a given IPv4 address.\n\n    - *packed_ip* -- IPv4 address (as 4-byte binary string)\n    - *flags*     -- either 0 or DNS_QUERY_NO_SEARCH\n    - *callback*  -- callback with ``(result, type, ttl, addrs)`` prototype\n    ";
static PyObject *__pyx_pf_6gevent_4core_dns_resolve_reverse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_packed_ip;
  int __pyx_v_flags;
  PyObject *__pyx_v_callback = 0;
  int __pyx_v_result;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__packed_ip,&__pyx_n_s__flags,&__pyx_n_s__callback,0};
  __Pyx_RefNannySetupContext("dns_resolve_reverse");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__packed_ip);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_reverse", 1, 3, 3, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_reverse", 1, 3, 3, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "dns_resolve_reverse") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_packed_ip = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_packed_ip) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_packed_ip = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_packed_ip) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_flags = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dns_resolve_reverse", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.dns_resolve_reverse");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_callback);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":117
 *     - *callback*  -- callback with ``(result, type, ttl, addrs)`` prototype
 *     """
 *     cdef int result = evdns_resolve_reverse(<void *>packed_ip, flags, __evdns_callback, <void *>callback)             # <<<<<<<<<<<<<<
 *     if result:
 *         raise IOError('evdns_resolve_reverse(%r, %r) returned %s' % (packed_ip, flags, result, ))
 */
  __pyx_v_result = evdns_resolve_reverse(((void *)__pyx_v_packed_ip), __pyx_v_flags, __pyx_f_6gevent_4core___evdns_callback, ((void *)__pyx_v_callback));

  /* "/home/denis/work/gevent/gevent/evdns.pxi":118
 *     """
 *     cdef int result = evdns_resolve_reverse(<void *>packed_ip, flags, __evdns_callback, <void *>callback)
 *     if result:             # <<<<<<<<<<<<<<
 *         raise IOError('evdns_resolve_reverse(%r, %r) returned %s' % (packed_ip, flags, result, ))
 *     Py_INCREF(callback)
 */
  __pyx_t_1 = __pyx_v_result;
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":119
 *     cdef int result = evdns_resolve_reverse(<void *>packed_ip, flags, __evdns_callback, <void *>callback)
 *     if result:
 *         raise IOError('evdns_resolve_reverse(%r, %r) returned %s' % (packed_ip, flags, result, ))             # <<<<<<<<<<<<<<
 *     Py_INCREF(callback)
 * 
 */
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_packed_ip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyInt_FromLong(__pyx_v_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":120
 *     if result:
 *         raise IOError('evdns_resolve_reverse(%r, %r) returned %s' % (packed_ip, flags, result, ))
 *     Py_INCREF(callback)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(__pyx_v_callback);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.dns_resolve_reverse");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_callback);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":123
 * 
 * 
 * def dns_resolve_reverse_ipv6(char* packed_ip, int flags, object callback):             # <<<<<<<<<<<<<<
 *     """Lookup a PTR record for a given IPv6 address.
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_dns_resolve_reverse_ipv6(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6gevent_4core_dns_resolve_reverse_ipv6[] = "Lookup a PTR record for a given IPv6 address.\n\n    - *packed_ip* -- IPv6 address (as 16-byte binary string)\n    - *flags*     -- either 0 or DNS_QUERY_NO_SEARCH\n    - *callback*  -- callback with ``(result, type, ttl, addrs)`` prototype\n    ";
static PyObject *__pyx_pf_6gevent_4core_dns_resolve_reverse_ipv6(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_packed_ip;
  int __pyx_v_flags;
  PyObject *__pyx_v_callback = 0;
  int __pyx_v_result;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__packed_ip,&__pyx_n_s__flags,&__pyx_n_s__callback,0};
  __Pyx_RefNannySetupContext("dns_resolve_reverse_ipv6");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__packed_ip);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_reverse_ipv6", 1, 3, 3, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_reverse_ipv6", 1, 3, 3, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "dns_resolve_reverse_ipv6") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_packed_ip = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_packed_ip) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_packed_ip = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_packed_ip) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_flags = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dns_resolve_reverse_ipv6", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.dns_resolve_reverse_ipv6");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_callback);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":130
 *     - *callback*  -- callback with ``(result, type, ttl, addrs)`` prototype
 *     """
 *     cdef int result = evdns_resolve_reverse_ipv6(<void *>packed_ip, flags, __evdns_callback, <void *>callback)             # <<<<<<<<<<<<<<
 *     if result:
 *         raise IOError('evdns_resolve_reverse_ipv6(%r, %r) returned %s' % (packed_ip, flags, result, ))
 */
  __pyx_v_result = evdns_resolve_reverse_ipv6(((void *)__pyx_v_packed_ip), __pyx_v_flags, __pyx_f_6gevent_4core___evdns_callback, ((void *)__pyx_v_callback));

  /* "/home/denis/work/gevent/gevent/evdns.pxi":131
 *     """
 *     cdef int result = evdns_resolve_reverse_ipv6(<void *>packed_ip, flags, __evdns_callback, <void *>callback)
 *     if result:             # <<<<<<<<<<<<<<
 *         raise IOError('evdns_resolve_reverse_ipv6(%r, %r) returned %s' % (packed_ip, flags, result, ))
 *     Py_INCREF(callback)
 */
  __pyx_t_1 = __pyx_v_result;
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":132
 *     cdef int result = evdns_resolve_reverse_ipv6(<void *>packed_ip, flags, __evdns_callback, <void *>callback)
 *     if result:
 *         raise IOError('evdns_resolve_reverse_ipv6(%r, %r) returned %s' % (packed_ip, flags, result, ))             # <<<<<<<<<<<<<<
 *     Py_INCREF(callback)
 * 
 */
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_packed_ip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyInt_FromLong(__pyx_v_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":133
 *     if result:
 *         raise IOError('evdns_resolve_reverse_ipv6(%r, %r) returned %s' % (packed_ip, flags, result, ))
 *     Py_INCREF(callback)             # <<<<<<<<<<<<<<
 * 
 */
  Py_INCREF(__pyx_v_callback);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.dns_resolve_reverse_ipv6");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_callback);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":27
 *     cdef evbuffer* __obj
 * 
 *     def __init__(self, size_t _obj):             # <<<<<<<<<<<<<<
 *         self.__obj = <evbuffer*>_obj
 * 
 */

static int __pyx_pf_6gevent_4core_6buffer___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6gevent_4core_6buffer___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v__obj;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s___obj,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s___obj);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__obj = __Pyx_PyInt_AsSize_t(values[0]); if (unlikely((__pyx_v__obj == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__obj = __Pyx_PyInt_AsSize_t(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v__obj == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.buffer.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":28
 * 
 *     def __init__(self, size_t _obj):
 *         self.__obj = <evbuffer*>_obj             # <<<<<<<<<<<<<<
 * 
 *     property _obj:
 */
  ((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj = ((struct evbuffer *)__pyx_v__obj);

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

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":32
 *     property _obj:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return <size_t>(self.__obj)
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_6buffer_4_obj___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_6buffer_4_obj___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":33
 * 
 *         def __get__(self):
 *             return <size_t>(self.__obj)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __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("gevent.core.buffer._obj.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":35
 *             return <size_t>(self.__obj)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj:
 *             return evbuffer_get_length(self.__obj)
 */

static Py_ssize_t __pyx_pf_6gevent_4core_6buffer___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pf_6gevent_4core_6buffer___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__len__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":36
 * 
 *     def __len__(self):
 *         if self.__obj:             # <<<<<<<<<<<<<<
 *             return evbuffer_get_length(self.__obj)
 *         else:
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":37
 *     def __len__(self):
 *         if self.__obj:
 *             return evbuffer_get_length(self.__obj)             # <<<<<<<<<<<<<<
 *         else:
 *             return 0
 */
    __pyx_r = evbuffer_get_length(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":39
 *             return evbuffer_get_length(self.__obj)
 *         else:
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":41
 *             return 0
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj:
 *             return evbuffer_get_length(self.__obj)
 */

static int __pyx_pf_6gevent_4core_6buffer___nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_6gevent_4core_6buffer___nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__nonzero__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":42
 * 
 *     def __nonzero__(self):
 *         if self.__obj:             # <<<<<<<<<<<<<<
 *             return evbuffer_get_length(self.__obj)
 * 
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":43
 *     def __nonzero__(self):
 *         if self.__obj:
 *             return evbuffer_get_length(self.__obj)             # <<<<<<<<<<<<<<
 * 
 *     def detach(self):
 */
    __pyx_r = evbuffer_get_length(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":45
 *             return evbuffer_get_length(self.__obj)
 * 
 *     def detach(self):             # <<<<<<<<<<<<<<
 *         self.__obj = NULL
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_6buffer_detach(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_6buffer_detach(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("detach");

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":46
 * 
 *     def detach(self):
 *         self.__obj = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  ((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj = NULL;

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

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":48
 *         self.__obj = NULL
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_6buffer___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_6buffer___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__iter__");

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":49
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

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

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":51
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         line = self.readline()
 *         if not line:
 */

static PyObject *__pyx_pf_6gevent_4core_6buffer___next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_6buffer___next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_line;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("__next__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_line = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":52
 * 
 *     def __next__(self):
 *         line = self.readline()             # <<<<<<<<<<<<<<
 *         if not line:
 *             raise StopIteration
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__readline); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_v_line);
  __pyx_v_line = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":53
 *     def __next__(self):
 *         line = self.readline()
 *         if not line:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         return line
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_line); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (!__pyx_t_3);
  if (__pyx_t_4) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":54
 *         line = self.readline()
 *         if not line:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         return line
 * 
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":55
 *         if not line:
 *             raise StopIteration
 *         return line             # <<<<<<<<<<<<<<
 * 
 *     def read(self, long size=-1):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_line);
  __pyx_r = __pyx_v_line;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.buffer.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_line);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":57
 *         return line
 * 
 *     def read(self, long size=-1):             # <<<<<<<<<<<<<<
 *         """Drain the first *size* bytes from the buffer (or what's left if there are less than *size* bytes).
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_6buffer_read(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6gevent_4core_6buffer_read[] = "Drain the first *size* bytes from the buffer (or what's left if there are less than *size* bytes).\n\n        If *size* is negative, drain the whole buffer.\n        ";
static PyObject *__pyx_pf_6gevent_4core_6buffer_read(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  long __pyx_v_size;
  long __pyx_v_length;
  char *__pyx_v_data;
  PyObject *__pyx_v_result = 0;
  int __pyx_v_res;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  long __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__size,0};
  __Pyx_RefNannySetupContext("read");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size);
        if (unlikely(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), "read") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_size = __Pyx_PyInt_AsLong(values[0]); if (unlikely((__pyx_v_size == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_size = ((long)-1);
    }
  } else {
    __pyx_v_size = ((long)-1);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_size = __Pyx_PyInt_AsLong(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_size == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("read", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.buffer.read");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":62
 *         If *size* is negative, drain the whole buffer.
 *         """
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             return ''
 *         cdef long length = evbuffer_get_length(self.__obj)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":63
 *         """
 *         if not self.__obj:
 *             return ''             # <<<<<<<<<<<<<<
 *         cdef long length = evbuffer_get_length(self.__obj)
 *         if size < 0:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
    __pyx_r = ((PyObject *)__pyx_kp_s_6);
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":64
 *         if not self.__obj:
 *             return ''
 *         cdef long length = evbuffer_get_length(self.__obj)             # <<<<<<<<<<<<<<
 *         if size < 0:
 *             size = length
 */
  __pyx_v_length = evbuffer_get_length(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj);

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":65
 *             return ''
 *         cdef long length = evbuffer_get_length(self.__obj)
 *         if size < 0:             # <<<<<<<<<<<<<<
 *             size = length
 *         else:
 */
  __pyx_t_1 = (__pyx_v_size < 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":66
 *         cdef long length = evbuffer_get_length(self.__obj)
 *         if size < 0:
 *             size = length             # <<<<<<<<<<<<<<
 *         else:
 *             size = min(size, length)
 */
    __pyx_v_size = __pyx_v_length;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":68
 *             size = length
 *         else:
 *             size = min(size, length)             # <<<<<<<<<<<<<<
 *         if size <= 0:
 *             return ''
 */
    __pyx_t_2 = PyInt_FromLong(__pyx_v_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyInt_FromLong(__pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_min, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyInt_AsLong(__pyx_t_3); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_size = __pyx_t_5;
  }
  __pyx_L7:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":69
 *         else:
 *             size = min(size, length)
 *         if size <= 0:             # <<<<<<<<<<<<<<
 *             return ''
 *         cdef char* data = <char*>EVBUFFER_PULLUP(self.__obj, size)
 */
  __pyx_t_1 = (__pyx_v_size <= 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":70
 *             size = min(size, length)
 *         if size <= 0:
 *             return ''             # <<<<<<<<<<<<<<
 *         cdef char* data = <char*>EVBUFFER_PULLUP(self.__obj, size)
 *         if not data:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
    __pyx_r = ((PyObject *)__pyx_kp_s_6);
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":71
 *         if size <= 0:
 *             return ''
 *         cdef char* data = <char*>EVBUFFER_PULLUP(self.__obj, size)             # <<<<<<<<<<<<<<
 *         if not data:
 *             return ''
 */
  __pyx_v_data = ((char *)EVBUFFER_PULLUP(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj, __pyx_v_size));

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":72
 *             return ''
 *         cdef char* data = <char*>EVBUFFER_PULLUP(self.__obj, size)
 *         if not data:             # <<<<<<<<<<<<<<
 *             return ''
 *         cdef object result = PyString_FromStringAndSize(data, size)
 */
  __pyx_t_1 = (!(__pyx_v_data != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":73
 *         cdef char* data = <char*>EVBUFFER_PULLUP(self.__obj, size)
 *         if not data:
 *             return ''             # <<<<<<<<<<<<<<
 *         cdef object result = PyString_FromStringAndSize(data, size)
 *         cdef int res = EVBUFFER_DRAIN(self.__obj, size)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
    __pyx_r = ((PyObject *)__pyx_kp_s_6);
    goto __pyx_L0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":74
 *         if not data:
 *             return ''
 *         cdef object result = PyString_FromStringAndSize(data, size)             # <<<<<<<<<<<<<<
 *         cdef int res = EVBUFFER_DRAIN(self.__obj, size)
 *         if res:
 */
  __pyx_t_3 = PyString_FromStringAndSize(__pyx_v_data, __pyx_v_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":75
 *             return ''
 *         cdef object result = PyString_FromStringAndSize(data, size)
 *         cdef int res = EVBUFFER_DRAIN(self.__obj, size)             # <<<<<<<<<<<<<<
 *         if res:
 *             try:
 */
  __pyx_v_res = EVBUFFER_DRAIN(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj, __pyx_v_size);

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":76
 *         cdef object result = PyString_FromStringAndSize(data, size)
 *         cdef int res = EVBUFFER_DRAIN(self.__obj, size)
 *         if res:             # <<<<<<<<<<<<<<
 *             try:
 *                 sys.stderr.write('evbuffer_drain(0x%x, %s) returned %s\n' % (self._obj, size, res))
 */
  __pyx_t_6 = __pyx_v_res;
  if (__pyx_t_6) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":77
 *         cdef int res = EVBUFFER_DRAIN(self.__obj, size)
 *         if res:
 *             try:             # <<<<<<<<<<<<<<
 *                 sys.stderr.write('evbuffer_drain(0x%x, %s) returned %s\n' % (self._obj, size, res))
 *             except:
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      __Pyx_XGOTREF(__pyx_save_exc_type);
      __Pyx_XGOTREF(__pyx_save_exc_value);
      __Pyx_XGOTREF(__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/denis/work/gevent/gevent/evbuffer.pxi":78
 *         if res:
 *             try:
 *                 sys.stderr.write('evbuffer_drain(0x%x, %s) returned %s\n' % (self._obj, size, res))             # <<<<<<<<<<<<<<
 *             except:
 *                 traceback.print_exc()
 */
        __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stderr); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__write); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___obj); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = PyInt_FromLong(__pyx_v_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_7 = PyInt_FromLong(__pyx_v_res); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
        __Pyx_GOTREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_t_4 = 0;
        __pyx_t_2 = 0;
        __pyx_t_7 = 0;
        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_20), __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
        __Pyx_GOTREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L18_try_end;
      __pyx_L11_error:;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "/home/denis/work/gevent/gevent/evbuffer.pxi":79
 *             try:
 *                 sys.stderr.write('evbuffer_drain(0x%x, %s) returned %s\n' % (self._obj, size, res))
 *             except:             # <<<<<<<<<<<<<<
 *                 traceback.print_exc()
 *         return result
 */
      /*except:*/ {
        __Pyx_AddTraceback("gevent.core.buffer.read");
        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_3);

        /* "/home/denis/work/gevent/gevent/evbuffer.pxi":80
 *                 sys.stderr.write('evbuffer_drain(0x%x, %s) returned %s\n' % (self._obj, size, res))
 *             except:
 *                 traceback.print_exc()             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
        __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__traceback); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__print_exc); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L12_exception_handled;
      }
      __pyx_L13_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L12_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L18_try_end:;
    }
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":81
 *             except:
 *                 traceback.print_exc()
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def readline(self, size=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("gevent.core.buffer.read");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":83
 *         return result
 * 
 *     def readline(self, size=None):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             return ''
 */

static PyObject *__pyx_pf_6gevent_4core_6buffer_readline(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_6buffer_readline(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_size = 0;
  char *__pyx_v_data;
  long __pyx_v_length;
  char *__pyx_v_nl;
  PyObject *__pyx_v_result = 0;
  int __pyx_v_res;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__size,0};
  __Pyx_RefNannySetupContext("readline");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size);
        if (unlikely(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), "readline") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_size = values[0];
  } else {
    __pyx_v_size = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_size = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("readline", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.buffer.readline");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_size);

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":84
 * 
 *     def readline(self, size=None):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             return ''
 *         cdef char* data = <char*>EVBUFFER_PULLUP(self.__obj, -1)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":85
 *     def readline(self, size=None):
 *         if not self.__obj:
 *             return ''             # <<<<<<<<<<<<<<
 *         cdef char* data = <char*>EVBUFFER_PULLUP(self.__obj, -1)
 *         if not data:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
    __pyx_r = ((PyObject *)__pyx_kp_s_6);
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":86
 *         if not self.__obj:
 *             return ''
 *         cdef char* data = <char*>EVBUFFER_PULLUP(self.__obj, -1)             # <<<<<<<<<<<<<<
 *         if not data:
 *             return ''
 */
  __pyx_v_data = ((char *)EVBUFFER_PULLUP(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj, -1));

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":87
 *             return ''
 *         cdef char* data = <char*>EVBUFFER_PULLUP(self.__obj, -1)
 *         if not data:             # <<<<<<<<<<<<<<
 *             return ''
 * 
 */
  __pyx_t_1 = (!(__pyx_v_data != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":88
 *         cdef char* data = <char*>EVBUFFER_PULLUP(self.__obj, -1)
 *         if not data:
 *             return ''             # <<<<<<<<<<<<<<
 * 
 *         cdef long length = evbuffer_get_length(self.__obj)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
    __pyx_r = ((PyObject *)__pyx_kp_s_6);
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":90
 *             return ''
 * 
 *         cdef long length = evbuffer_get_length(self.__obj)             # <<<<<<<<<<<<<<
 *         cdef char *nl = <char*> memchr(<void*>data, 10, length) # search for "\n"
 * 
 */
  __pyx_v_length = evbuffer_get_length(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj);

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":91
 * 
 *         cdef long length = evbuffer_get_length(self.__obj)
 *         cdef char *nl = <char*> memchr(<void*>data, 10, length) # search for "\n"             # <<<<<<<<<<<<<<
 * 
 *         if nl:
 */
  __pyx_v_nl = ((char *)memchr(((void *)__pyx_v_data), 10, __pyx_v_length));

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":93
 *         cdef char *nl = <char*> memchr(<void*>data, 10, length) # search for "\n"
 * 
 *         if nl:             # <<<<<<<<<<<<<<
 *             length = nl - data + 1
 * 
 */
  __pyx_t_1 = (__pyx_v_nl != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":94
 * 
 *         if nl:
 *             length = nl - data + 1             # <<<<<<<<<<<<<<
 * 
 *         cdef object result = PyString_FromStringAndSize(data, length)
 */
    __pyx_v_length = ((__pyx_v_nl - __pyx_v_data) + 1);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":96
 *             length = nl - data + 1
 * 
 *         cdef object result = PyString_FromStringAndSize(data, length)             # <<<<<<<<<<<<<<
 *         cdef int res = EVBUFFER_DRAIN(self.__obj, length)
 *         if res:
 */
  __pyx_t_2 = PyString_FromStringAndSize(__pyx_v_data, __pyx_v_length); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_result = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":97
 * 
 *         cdef object result = PyString_FromStringAndSize(data, length)
 *         cdef int res = EVBUFFER_DRAIN(self.__obj, length)             # <<<<<<<<<<<<<<
 *         if res:
 *             try:
 */
  __pyx_v_res = EVBUFFER_DRAIN(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj, __pyx_v_length);

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":98
 *         cdef object result = PyString_FromStringAndSize(data, length)
 *         cdef int res = EVBUFFER_DRAIN(self.__obj, length)
 *         if res:             # <<<<<<<<<<<<<<
 *             try:
 *                 sys.stderr.write('evbuffer_drain(0x%x, %s) returned %s\n' % (self._obj, length, res))
 */
  __pyx_t_3 = __pyx_v_res;
  if (__pyx_t_3) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":99
 *         cdef int res = EVBUFFER_DRAIN(self.__obj, length)
 *         if res:
 *             try:             # <<<<<<<<<<<<<<
 *                 sys.stderr.write('evbuffer_drain(0x%x, %s) returned %s\n' % (self._obj, length, res))
 *             except:
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      __Pyx_XGOTREF(__pyx_save_exc_type);
      __Pyx_XGOTREF(__pyx_save_exc_value);
      __Pyx_XGOTREF(__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/denis/work/gevent/gevent/evbuffer.pxi":100
 *         if res:
 *             try:
 *                 sys.stderr.write('evbuffer_drain(0x%x, %s) returned %s\n' % (self._obj, length, res))             # <<<<<<<<<<<<<<
 *             except:
 *                 traceback.print_exc()
 */
        __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__stderr); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___obj); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyInt_FromLong(__pyx_v_length); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = PyInt_FromLong(__pyx_v_res); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __pyx_t_4 = 0;
        __pyx_t_5 = 0;
        __pyx_t_6 = 0;
        __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_20), __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_6 = PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L17_try_end;
      __pyx_L10_error:;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "/home/denis/work/gevent/gevent/evbuffer.pxi":101
 *             try:
 *                 sys.stderr.write('evbuffer_drain(0x%x, %s) returned %s\n' % (self._obj, length, res))
 *             except:             # <<<<<<<<<<<<<<
 *                 traceback.print_exc()
 *         return result
 */
      /*except:*/ {
        __Pyx_AddTraceback("gevent.core.buffer.readline");
        if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_2);

        /* "/home/denis/work/gevent/gevent/evbuffer.pxi":102
 *                 sys.stderr.write('evbuffer_drain(0x%x, %s) returned %s\n' % (self._obj, length, res))
 *             except:
 *                 traceback.print_exc()             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
        __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__traceback); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__print_exc); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L11_exception_handled;
      }
      __pyx_L12_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L11_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L17_try_end:;
    }
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":103
 *             except:
 *                 traceback.print_exc()
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def readlines(self, hint=-1):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("gevent.core.buffer.readline");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_size);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":105
 *         return result
 * 
 *     def readlines(self, hint=-1):             # <<<<<<<<<<<<<<
 *         return list(self)
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_6buffer_readlines(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_6buffer_readlines(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_hint = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__hint,0};
  __Pyx_RefNannySetupContext("readlines");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_neg_1);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__hint);
        if (unlikely(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), "readlines") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_hint = values[0];
  } else {
    __pyx_v_hint = ((PyObject *)__pyx_int_neg_1);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_hint = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("readlines", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.buffer.readlines");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":106
 * 
 *     def readlines(self, hint=-1):
 *         return list(self)             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyList_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.buffer.readlines");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":118
 *     cdef public object default_response_headers
 * 
 *     def __init__(self, size_t _obj, object default_response_headers):             # <<<<<<<<<<<<<<
 *         self.__obj = <evhttp_request*>_obj
 *         self.default_response_headers = default_response_headers
 */

static int __pyx_pf_6gevent_4core_12http_request___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6gevent_4core_12http_request___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v__obj;
  PyObject *__pyx_v_default_response_headers = 0;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s___obj,&__pyx_n_s_21,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s___obj);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_21);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__obj = __Pyx_PyInt_AsSize_t(values[0]); if (unlikely((__pyx_v__obj == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_default_response_headers = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__obj = __Pyx_PyInt_AsSize_t(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v__obj == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_default_response_headers = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_request.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":119
 * 
 *     def __init__(self, size_t _obj, object default_response_headers):
 *         self.__obj = <evhttp_request*>_obj             # <<<<<<<<<<<<<<
 *         self.default_response_headers = default_response_headers
 * 
 */
  ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj = ((struct evhttp_request *)__pyx_v__obj);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":120
 *     def __init__(self, size_t _obj, object default_response_headers):
 *         self.__obj = <evhttp_request*>_obj
 *         self.default_response_headers = default_response_headers             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __Pyx_INCREF(__pyx_v_default_response_headers);
  __Pyx_GIVEREF(__pyx_v_default_response_headers);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->default_response_headers);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->default_response_headers);
  ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->default_response_headers = __pyx_v_default_response_headers;

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

/* "/home/denis/work/gevent/gevent/evhttp.pxi":122
 *         self.default_response_headers = default_response_headers
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         cdef evhttp_request* obj = self.__obj
 *         if obj != NULL:
 */

static void __pyx_pf_6gevent_4core_12http_request___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_6gevent_4core_12http_request___dealloc__(PyObject *__pyx_v_self) {
  struct evhttp_request *__pyx_v_obj;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":123
 * 
 *     def __dealloc__(self):
 *         cdef evhttp_request* obj = self.__obj             # <<<<<<<<<<<<<<
 *         if obj != NULL:
 *             self.__obj = NULL
 */
  __pyx_v_obj = ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":124
 *     def __dealloc__(self):
 *         cdef evhttp_request* obj = self.__obj
 *         if obj != NULL:             # <<<<<<<<<<<<<<
 *             self.__obj = NULL
 *             report_internal_error(obj)
 */
  __pyx_t_1 = (__pyx_v_obj != NULL);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":125
 *         cdef evhttp_request* obj = self.__obj
 *         if obj != NULL:
 *             self.__obj = NULL             # <<<<<<<<<<<<<<
 *             report_internal_error(obj)
 * 
 */
    ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj = NULL;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":126
 *         if obj != NULL:
 *             self.__obj = NULL
 *             report_internal_error(obj)             # <<<<<<<<<<<<<<
 * 
 *     property _obj:
 */
    __pyx_f_6gevent_4core_report_internal_error(__pyx_v_obj);
    goto __pyx_L5;
  }
  __pyx_L5:;

  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":130
 *     property _obj:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return <size_t>(self.__obj)
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_4_obj___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_4_obj___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":131
 * 
 *         def __get__(self):
 *             return <size_t>(self.__obj)             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 131; __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("gevent.core.http_request._obj.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":133
 *             return <size_t>(self.__obj)
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj:
 *             return True
 */

static int __pyx_pf_6gevent_4core_12http_request___nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_6gevent_4core_12http_request___nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__nonzero__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":134
 * 
 *     def __nonzero__(self):
 *         if self.__obj:             # <<<<<<<<<<<<<<
 *             return True
 *         else:
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":135
 *     def __nonzero__(self):
 *         if self.__obj:
 *             return True             # <<<<<<<<<<<<<<
 *         else:
 *             return False
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":137
 *             return True
 *         else:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     def detach(self):
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":139
 *             return False
 * 
 *     def detach(self):             # <<<<<<<<<<<<<<
 *         self.__obj = NULL
 *         if self._input_buffer is not None:
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_detach(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_detach(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("detach");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":140
 * 
 *     def detach(self):
 *         self.__obj = NULL             # <<<<<<<<<<<<<<
 *         if self._input_buffer is not None:
 *             self._input_buffer.detach()
 */
  ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj = NULL;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":141
 *     def detach(self):
 *         self.__obj = NULL
 *         if self._input_buffer is not None:             # <<<<<<<<<<<<<<
 *             self._input_buffer.detach()
 *         if self._output_buffer is not None:
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_input_buffer != Py_None);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":142
 *         self.__obj = NULL
 *         if self._input_buffer is not None:
 *             self._input_buffer.detach()             # <<<<<<<<<<<<<<
 *         if self._output_buffer is not None:
 *             self._output_buffer.detach()
 */
    __pyx_t_2 = PyObject_GetAttr(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_input_buffer, __pyx_n_s__detach); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":143
 *         if self._input_buffer is not None:
 *             self._input_buffer.detach()
 *         if self._output_buffer is not None:             # <<<<<<<<<<<<<<
 *             self._output_buffer.detach()
 * 
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_output_buffer != Py_None);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":144
 *             self._input_buffer.detach()
 *         if self._output_buffer is not None:
 *             self._output_buffer.detach()             # <<<<<<<<<<<<<<
 * 
 *     def _format(self):
 */
    __pyx_t_3 = PyObject_GetAttr(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_output_buffer, __pyx_n_s__detach); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.detach");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":146
 *             self._output_buffer.detach()
 * 
 *     def _format(self):             # <<<<<<<<<<<<<<
 *         args = (self.typestr, self.uri, self.major, self.minor,
 *                 self.remote_host, self.remote_port)
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request__format(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request__format(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_v_args;
  PyObject *__pyx_v_res;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  __Pyx_RefNannySetupContext("_format");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_args = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_res = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":147
 * 
 *     def _format(self):
 *         args = (self.typestr, self.uri, self.major, self.minor,             # <<<<<<<<<<<<<<
 *                 self.remote_host, self.remote_port)
 *         res = '"%s %s HTTP/%s.%s" %s:%s' % args
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__typestr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__uri); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__major); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__minor); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":148
 *     def _format(self):
 *         args = (self.typestr, self.uri, self.major, self.minor,
 *                 self.remote_host, self.remote_port)             # <<<<<<<<<<<<<<
 *         res = '"%s %s HTTP/%s.%s" %s:%s' % args
 *         if self.response_code:
 */
  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__remote_host); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__remote_port); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyTuple_New(6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 5, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_v_args);
  __pyx_v_args = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":149
 *         args = (self.typestr, self.uri, self.major, self.minor,
 *                 self.remote_host, self.remote_port)
 *         res = '"%s %s HTTP/%s.%s" %s:%s' % args             # <<<<<<<<<<<<<<
 *         if self.response_code:
 *             res += ' response=%s' % self.response_code
 */
  __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_22), __pyx_v_args); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_v_res);
  __pyx_v_res = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":150
 *                 self.remote_host, self.remote_port)
 *         res = '"%s %s HTTP/%s.%s" %s:%s' % args
 *         if self.response_code:             # <<<<<<<<<<<<<<
 *             res += ' response=%s' % self.response_code
 *         if self.input_buffer:
 */
  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__response_code); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_8) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":151
 *         res = '"%s %s HTTP/%s.%s" %s:%s' % args
 *         if self.response_code:
 *             res += ' response=%s' % self.response_code             # <<<<<<<<<<<<<<
 *         if self.input_buffer:
 *             res += ' input=%s' % len(self.input_buffer)
 */
    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__response_code); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_res, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_v_res);
    __pyx_v_res = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":152
 *         if self.response_code:
 *             res += ' response=%s' % self.response_code
 *         if self.input_buffer:             # <<<<<<<<<<<<<<
 *             res += ' input=%s' % len(self.input_buffer)
 *         if self.output_buffer:
 */
  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__input_buffer); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_8) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":153
 *             res += ' response=%s' % self.response_code
 *         if self.input_buffer:
 *             res += ' input=%s' % len(self.input_buffer)             # <<<<<<<<<<<<<<
 *         if self.output_buffer:
 *             res += ' output=%s' % len(self.output_buffer)
 */
    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__input_buffer); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = PyObject_Length(__pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_24), __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_res, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_v_res);
    __pyx_v_res = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":154
 *         if self.input_buffer:
 *             res += ' input=%s' % len(self.input_buffer)
 *         if self.output_buffer:             # <<<<<<<<<<<<<<
 *             res += ' output=%s' % len(self.output_buffer)
 *         return res
 */
  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__output_buffer); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_8) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":155
 *             res += ' input=%s' % len(self.input_buffer)
 *         if self.output_buffer:
 *             res += ' output=%s' % len(self.output_buffer)             # <<<<<<<<<<<<<<
 *         return res
 * 
 */
    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__output_buffer); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = PyObject_Length(__pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_25), __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_res, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_v_res);
    __pyx_v_res = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":156
 *         if self.output_buffer:
 *             res += ' output=%s' % len(self.output_buffer)
 *         return res             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_res);
  __pyx_r = __pyx_v_res;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("gevent.core.http_request._format");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_res);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":158
 *         return res
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         try:
 *             info = self._format()
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request___str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_info;
  PyObject *__pyx_v_ex;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__str__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_info = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_ex = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":159
 * 
 *     def __str__(self):
 *         try:             # <<<<<<<<<<<<<<
 *             info = self._format()
 *         except HttpRequestDeleted:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":160
 *     def __str__(self):
 *         try:
 *             info = self._format()             # <<<<<<<<<<<<<<
 *         except HttpRequestDeleted:
 *             info = 'deleted'
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_info);
      __pyx_v_info = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L12_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":161
 *         try:
 *             info = self._format()
 *         except HttpRequestDeleted:             # <<<<<<<<<<<<<<
 *             info = 'deleted'
 *         except Exception, ex:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_3) {
      __Pyx_AddTraceback("gevent.core.http_request.__str__");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":162
 *             info = self._format()
 *         except HttpRequestDeleted:
 *             info = 'deleted'             # <<<<<<<<<<<<<<
 *         except Exception, ex:
 *             info = str(ex) or repr(ex) or '<Error>'
 */
      __Pyx_INCREF(((PyObject *)__pyx_n_s__deleted));
      __Pyx_DECREF(__pyx_v_info);
      __pyx_v_info = ((PyObject *)__pyx_n_s__deleted);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_exception_handled;
    }

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":163
 *         except HttpRequestDeleted:
 *             info = 'deleted'
 *         except Exception, ex:             # <<<<<<<<<<<<<<
 *             info = str(ex) or repr(ex) or '<Error>'
 *         return '<%s %s>' % (self.__class__.__name__, info)
 */
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
    if (__pyx_t_3) {
      __Pyx_AddTraceback("gevent.core.http_request.__str__");
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_v_ex);
      __pyx_v_ex = __pyx_t_1;

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":164
 *             info = 'deleted'
 *         except Exception, ex:
 *             info = str(ex) or repr(ex) or '<Error>'             # <<<<<<<<<<<<<<
 *         return '<%s %s>' % (self.__class__.__name__, info)
 * 
 */
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      if (!__pyx_t_7) {
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_5 = PyObject_Repr(__pyx_v_ex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        if (!__pyx_t_7) {
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_INCREF(((PyObject *)__pyx_kp_s_26));
          __pyx_t_8 = __pyx_kp_s_26;
        } else {
          __pyx_t_8 = __pyx_t_5;
          __pyx_t_5 = 0;
        }
        __pyx_t_5 = __pyx_t_8;
        __pyx_t_8 = 0;
      } else {
        __pyx_t_5 = __pyx_t_6;
        __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_v_info);
      __pyx_v_info = __pyx_t_5;
      __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L12_try_end:;
  }

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":165
 *         except Exception, ex:
 *             info = str(ex) or repr(ex) or '<Error>'
 *         return '<%s %s>' % (self.__class__.__name__, info)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____class__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____name__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_info);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_info);
  __Pyx_GIVEREF(__pyx_v_info);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("gevent.core.http_request.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_info);
  __Pyx_DECREF(__pyx_v_ex);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":167
 *         return '<%s %s>' % (self.__class__.__name__, info)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         try:
 *             info = ' ' + self._format()
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_info;
  PyObject *__pyx_v_ex;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__repr__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_info = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_ex = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":168
 * 
 *     def __repr__(self):
 *         try:             # <<<<<<<<<<<<<<
 *             info = ' ' + self._format()
 *         except HttpRequestDeleted:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":169
 *     def __repr__(self):
 *         try:
 *             info = ' ' + self._format()             # <<<<<<<<<<<<<<
 *         except HttpRequestDeleted:
 *             info = ''
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_s_10), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_v_info);
      __pyx_v_info = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L12_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":170
 *         try:
 *             info = ' ' + self._format()
 *         except HttpRequestDeleted:             # <<<<<<<<<<<<<<
 *             info = ''
 *         except Exception, ex:
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {
      __Pyx_AddTraceback("gevent.core.http_request.__repr__");
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":171
 *             info = ' ' + self._format()
 *         except HttpRequestDeleted:
 *             info = ''             # <<<<<<<<<<<<<<
 *         except Exception, ex:
 *             info = ' ' + (str(ex) or repr(ex) or '<Error>')
 */
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
      __Pyx_DECREF(__pyx_v_info);
      __pyx_v_info = ((PyObject *)__pyx_kp_s_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_exception_handled;
    }

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":172
 *         except HttpRequestDeleted:
 *             info = ''
 *         except Exception, ex:             # <<<<<<<<<<<<<<
 *             info = ' ' + (str(ex) or repr(ex) or '<Error>')
 *         return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, info)
 */
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
    if (__pyx_t_3) {
      __Pyx_AddTraceback("gevent.core.http_request.__repr__");
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_v_ex);
      __pyx_v_ex = __pyx_t_2;

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":173
 *             info = ''
 *         except Exception, ex:
 *             info = ' ' + (str(ex) or repr(ex) or '<Error>')             # <<<<<<<<<<<<<<
 *         return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, info)
 * 
 */
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      if (!__pyx_t_7) {
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_5 = PyObject_Repr(__pyx_v_ex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        if (!__pyx_t_7) {
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_INCREF(((PyObject *)__pyx_kp_s_26));
          __pyx_t_8 = __pyx_kp_s_26;
        } else {
          __pyx_t_8 = __pyx_t_5;
          __pyx_t_5 = 0;
        }
        __pyx_t_5 = __pyx_t_8;
        __pyx_t_8 = 0;
      } else {
        __pyx_t_5 = __pyx_t_6;
        __pyx_t_6 = 0;
      }
      __pyx_t_6 = PyNumber_Add(((PyObject *)__pyx_kp_s_10), __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_v_info);
      __pyx_v_info = __pyx_t_6;
      __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L12_try_end:;
  }

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":174
 *         except Exception, ex:
 *             info = ' ' + (str(ex) or repr(ex) or '<Error>')
 *         return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, info)             # <<<<<<<<<<<<<<
 * 
 *     def get_input_headers(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____name__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___obj); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_info);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_info);
  __Pyx_GIVEREF(__pyx_v_info);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("gevent.core.http_request.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_info);
  __Pyx_DECREF(__pyx_v_ex);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":176
 *         return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, info)
 * 
 *     def get_input_headers(self):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_get_input_headers(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_get_input_headers(PyObject *__pyx_v_self, PyObject *unused) {
  struct evkeyvalq *__pyx_v_headers;
  struct evkeyval *__pyx_v_p;
  char *__pyx_v_key;
  char *__pyx_v_value;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("get_input_headers");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":177
 * 
 *     def get_input_headers(self):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         cdef evkeyvalq* headers = self.__obj.input_headers
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":178
 *     def get_input_headers(self):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         cdef evkeyvalq* headers = self.__obj.input_headers
 *         cdef evkeyval* p = TAILQ_FIRST(headers)
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":179
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         cdef evkeyvalq* headers = self.__obj.input_headers             # <<<<<<<<<<<<<<
 *         cdef evkeyval* p = TAILQ_FIRST(headers)
 *         cdef char *key, *value
 */
  __pyx_v_headers = ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->input_headers;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":180
 *             raise HttpRequestDeleted
 *         cdef evkeyvalq* headers = self.__obj.input_headers
 *         cdef evkeyval* p = TAILQ_FIRST(headers)             # <<<<<<<<<<<<<<
 *         cdef char *key, *value
 *         result = []
 */
  __pyx_v_p = TAILQ_FIRST(__pyx_v_headers);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":182
 *         cdef evkeyval* p = TAILQ_FIRST(headers)
 *         cdef char *key, *value
 *         result = []             # <<<<<<<<<<<<<<
 *         while p:
 *             key = p.key
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(__pyx_v_result);
  __pyx_v_result = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":183
 *         cdef char *key, *value
 *         result = []
 *         while p:             # <<<<<<<<<<<<<<
 *             key = p.key
 *             value = p.value
 */
  while (1) {
    __pyx_t_1 = (__pyx_v_p != 0);
    if (!__pyx_t_1) break;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":184
 *         result = []
 *         while p:
 *             key = p.key             # <<<<<<<<<<<<<<
 *             value = p.value
 *             result.append((key if key else None, value if value else None))
 */
    __pyx_v_key = __pyx_v_p->key;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":185
 *         while p:
 *             key = p.key
 *             value = p.value             # <<<<<<<<<<<<<<
 *             result.append((key if key else None, value if value else None))
 *             p = TAILQ_GET_NEXT(p)
 */
    __pyx_v_value = __pyx_v_p->value;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":186
 *             key = p.key
 *             value = p.value
 *             result.append((key if key else None, value if value else None))             # <<<<<<<<<<<<<<
 *             p = TAILQ_GET_NEXT(p)
 *         return result
 */
    if ((__pyx_v_key != 0)) {
      __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __pyx_t_2 = __pyx_t_3;
      __pyx_t_3 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_2 = Py_None;
    }
    if ((__pyx_v_value != 0)) {
      __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_value); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      __pyx_t_3 = __pyx_t_4;
      __pyx_t_4 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_3 = Py_None;
    }
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":187
 *             value = p.value
 *             result.append((key if key else None, value if value else None))
 *             p = TAILQ_GET_NEXT(p)             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_p = TAILQ_GET_NEXT(__pyx_v_p);
  }

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":188
 *             result.append((key if key else None, value if value else None))
 *             p = TAILQ_GET_NEXT(p)
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     property connection:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_request.get_input_headers");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":192
 *     property connection:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_10connection___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_10connection___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":193
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return http_connection(<size_t>self.__obj.evcon)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":194
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return http_connection(<size_t>self.__obj.evcon)
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":195
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return http_connection(<size_t>self.__obj.evcon)             # <<<<<<<<<<<<<<
 * 
 *     property remote_host:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(((size_t)((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->evcon)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 195; __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[1]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_http_connection)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.connection.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":199
 *     property remote_host:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_11remote_host___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_11remote_host___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":200
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             if self.__obj.remote_host:
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":201
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             if self.__obj.remote_host:
 *                 return self.__obj.remote_host
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":202
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             if self.__obj.remote_host:             # <<<<<<<<<<<<<<
 *                 return self.__obj.remote_host
 * 
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->remote_host != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":203
 *                 raise HttpRequestDeleted
 *             if self.__obj.remote_host:
 *                 return self.__obj.remote_host             # <<<<<<<<<<<<<<
 * 
 *     property remote_port:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromString(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->remote_host); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_r = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.remote_host.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":207
 *     property remote_port:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_11remote_port___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_11remote_port___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":208
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return self.__obj.remote_port
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":209
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.remote_port
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":210
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return self.__obj.remote_port             # <<<<<<<<<<<<<<
 * 
 *     property remote:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->remote_port); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 210; __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("gevent.core.http_request.remote_port.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":214
 *     property remote:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return (self.remote_host, self.remote_port)
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_6remote___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_6remote___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":215
 * 
 *         def __get__(self):
 *             return (self.remote_host, self.remote_port)             # <<<<<<<<<<<<<<
 * 
 *     property kind:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__remote_host); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__remote_port); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.remote.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":219
 *     property kind:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_4kind___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_4kind___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":220
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return self.__obj.kind
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":221
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.kind
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":222
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return self.__obj.kind             # <<<<<<<<<<<<<<
 * 
 *     property type:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->kind); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __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("gevent.core.http_request.kind.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":226
 *     property type:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_4type___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_4type___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":227
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return self.__obj.type
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":228
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.type
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":229
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return self.__obj.type             # <<<<<<<<<<<<<<
 * 
 *     property typestr:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->type); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 229; __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("gevent.core.http_request.type.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":233
 *     property typestr:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

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

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":234
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return HTTP_method2name.get(self.__obj.type) or str(self.__obj.type)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":235
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return HTTP_method2name.get(self.__obj.type) or str(self.__obj.type)
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":236
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return HTTP_method2name.get(self.__obj.type) or str(self.__obj.type)             # <<<<<<<<<<<<<<
 * 
 *     property uri:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HTTP_method2name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__get); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->type); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_1) {
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->type); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_request.typestr.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":240
 *     property uri:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_3uri___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_3uri___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":241
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             if self.__obj.uri:
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":242
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             if self.__obj.uri:
 *                 return self.__obj.uri
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":243
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             if self.__obj.uri:             # <<<<<<<<<<<<<<
 *                 return self.__obj.uri
 * 
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->uri != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":244
 *                 raise HttpRequestDeleted
 *             if self.__obj.uri:
 *                 return self.__obj.uri             # <<<<<<<<<<<<<<
 * 
 *     property major:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromString(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->uri); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_r = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.uri.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":248
 *     property major:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_5major___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_5major___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":249
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return self.__obj.major
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":250
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.major
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":251
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return self.__obj.major             # <<<<<<<<<<<<<<
 * 
 *     property minor:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->major); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 251; __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("gevent.core.http_request.major.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":255
 *     property minor:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_5minor___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_5minor___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":256
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return self.__obj.minor
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":257
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.minor
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":258
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return self.__obj.minor             # <<<<<<<<<<<<<<
 * 
 *     property version:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->minor); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 258; __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("gevent.core.http_request.minor.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":262
 *     property version:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

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

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":263
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return (self.__obj.major, self.__obj.minor)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":264
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return (self.__obj.major, self.__obj.minor)
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":265
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return (self.__obj.major, self.__obj.minor)             # <<<<<<<<<<<<<<
 * 
 *     property response_code:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->major); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->minor); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_request.version.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":269
 *     property response_code:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_13response_code___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_13response_code___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":270
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return self.__obj.response_code
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":271
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.response_code
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":272
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return self.__obj.response_code             # <<<<<<<<<<<<<<
 * 
 *     property response_code_line:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->response_code); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __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("gevent.core.http_request.response_code.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":276
 *     property response_code_line:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_18response_code_line___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_18response_code_line___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":277
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             if self.__obj.response_code_line:
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":278
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             if self.__obj.response_code_line:
 *                 return self.__obj.response_code_line
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":279
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             if self.__obj.response_code_line:             # <<<<<<<<<<<<<<
 *                 return self.__obj.response_code_line
 * 
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->response_code_line != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":280
 *                 raise HttpRequestDeleted
 *             if self.__obj.response_code_line:
 *                 return self.__obj.response_code_line             # <<<<<<<<<<<<<<
 * 
 *     property response:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromString(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->response_code_line); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_r = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.response_code_line.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":284
 *     property response:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return (self.response_code, self.response_code_line)
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_8response___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_8response___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":285
 * 
 *         def __get__(self):
 *             return (self.response_code, self.response_code_line)             # <<<<<<<<<<<<<<
 * 
 *     property chunked:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__response_code); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__response_code_line); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.response.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":289
 *     property chunked:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_7chunked___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_7chunked___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":290
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return self.__obj.chunked
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":291
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.chunked
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":292
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return self.__obj.chunked             # <<<<<<<<<<<<<<
 * 
 *     property input_buffer:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->chunked); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 292; __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("gevent.core.http_request.chunked.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":296
 *     property input_buffer:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._input_buffer is not None:
 *                 return self._input_buffer
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_12input_buffer___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_12input_buffer___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":297
 * 
 *         def __get__(self):
 *             if self._input_buffer is not None:             # <<<<<<<<<<<<<<
 *                 return self._input_buffer
 *             if not self.__obj:
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_input_buffer != Py_None);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":298
 *         def __get__(self):
 *             if self._input_buffer is not None:
 *                 return self._input_buffer             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_input_buffer);
    __pyx_r = ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_input_buffer;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":299
 *             if self._input_buffer is not None:
 *                 return self._input_buffer
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             self._input_buffer = buffer(<size_t>self.__obj.input_buffer)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":300
 *                 return self._input_buffer
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             self._input_buffer = buffer(<size_t>self.__obj.input_buffer)
 *             return self._input_buffer
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":301
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             self._input_buffer = buffer(<size_t>self.__obj.input_buffer)             # <<<<<<<<<<<<<<
 *             return self._input_buffer
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(((size_t)((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->input_buffer)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 301; __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[1]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_buffer)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_input_buffer);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_input_buffer);
  ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_input_buffer = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":302
 *                 raise HttpRequestDeleted
 *             self._input_buffer = buffer(<size_t>self.__obj.input_buffer)
 *             return self._input_buffer             # <<<<<<<<<<<<<<
 * 
 *     property output_buffer:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_input_buffer);
  __pyx_r = ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_input_buffer;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.input_buffer.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":306
 *     property output_buffer:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._output_buffer is not None:
 *                 return self._output_buffer
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_13output_buffer___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_13output_buffer___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":307
 * 
 *         def __get__(self):
 *             if self._output_buffer is not None:             # <<<<<<<<<<<<<<
 *                 return self._output_buffer
 *             if not self.__obj:
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_output_buffer != Py_None);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":308
 *         def __get__(self):
 *             if self._output_buffer is not None:
 *                 return self._output_buffer             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_output_buffer);
    __pyx_r = ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_output_buffer;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":309
 *             if self._output_buffer is not None:
 *                 return self._output_buffer
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             self._output_buffer = buffer(<size_t>self.__obj.output_buffer)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":310
 *                 return self._output_buffer
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             self._output_buffer = buffer(<size_t>self.__obj.output_buffer)
 *             return self._output_buffer
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":311
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             self._output_buffer = buffer(<size_t>self.__obj.output_buffer)             # <<<<<<<<<<<<<<
 *             return self._output_buffer
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(((size_t)((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->output_buffer)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 311; __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[1]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_buffer)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_output_buffer);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_output_buffer);
  ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_output_buffer = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":312
 *                 raise HttpRequestDeleted
 *             self._output_buffer = buffer(<size_t>self.__obj.output_buffer)
 *             return self._output_buffer             # <<<<<<<<<<<<<<
 * 
 *     def _add_default_response_headers(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_output_buffer);
  __pyx_r = ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->_output_buffer;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.output_buffer.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":314
 *             return self._output_buffer
 * 
 *     def _add_default_response_headers(self):             # <<<<<<<<<<<<<<
 *         for key, value in self.default_response_headers:
 *             if not self.find_output_header(key):
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request__add_default_response_headers(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request__add_default_response_headers(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("_add_default_response_headers");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":315
 * 
 *     def _add_default_response_headers(self):
 *         for key, value in self.default_response_headers:             # <<<<<<<<<<<<<<
 *             if not self.find_output_header(key):
 *                 self.add_output_header(key, value)
 */
  if (PyList_CheckExact(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->default_response_headers) || PyTuple_CheckExact(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->default_response_headers)) {
    __pyx_t_1 = 0; __pyx_t_2 = ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->default_response_headers; __Pyx_INCREF(__pyx_t_2);
  } else {
    __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->default_response_headers); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_t_2))) {
      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
      if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
    } else {
      __pyx_t_3 = PyIter_Next(__pyx_t_2);
      if (!__pyx_t_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if (PyTuple_CheckExact(__pyx_t_3) && likely(PyTuple_GET_SIZE(__pyx_t_3) == 2)) {
      PyObject* tuple = __pyx_t_3;
      __pyx_t_4 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_key);
      __pyx_v_key = __pyx_t_4;
      __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_t_5;
      __pyx_t_5 = 0;
    } else {
      __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_EndUnpack(__pyx_t_6) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_v_key);
      __pyx_v_key = __pyx_t_4;
      __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_t_5;
      __pyx_t_5 = 0;
    }

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":316
 *     def _add_default_response_headers(self):
 *         for key, value in self.default_response_headers:
 *             if not self.find_output_header(key):             # <<<<<<<<<<<<<<
 *                 self.add_output_header(key, value)
 * 
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__find_output_header); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_key);
    __Pyx_GIVEREF(__pyx_v_key);
    __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = (!__pyx_t_7);
    if (__pyx_t_8) {

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":317
 *         for key, value in self.default_response_headers:
 *             if not self.find_output_header(key):
 *                 self.add_output_header(key, value)             # <<<<<<<<<<<<<<
 * 
 *     def send_reply(self, int code, char *reason, object buf):
 */
      __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__add_output_header); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      __Pyx_INCREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      __pyx_t_3 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("gevent.core.http_request._add_default_response_headers");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_key);
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":319
 *                 self.add_output_header(key, value)
 * 
 *     def send_reply(self, int code, char *reason, object buf):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_send_reply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_send_reply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_code;
  char *__pyx_v_reason;
  PyObject *__pyx_v_buf = 0;
  struct evbuffer *__pyx_v_c_buf;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  Py_ssize_t __pyx_t_5;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__code,&__pyx_n_s__reason,&__pyx_n_s__buf,0};
  __Pyx_RefNannySetupContext("send_reply");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__code);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reason);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("send_reply", 1, 3, 3, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buf);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("send_reply", 1, 3, 3, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_reply") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_code = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_code == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_reason = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_reason) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_buf = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_code = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_code == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_reason = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_reason) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_buf = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send_reply", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_request.send_reply");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_buf);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":320
 * 
 *     def send_reply(self, int code, char *reason, object buf):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         cdef evbuffer* c_buf
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":321
 *     def send_reply(self, int code, char *reason, object buf):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         cdef evbuffer* c_buf
 *         if isinstance(buf, buffer):
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":323
 *             raise HttpRequestDeleted
 *         cdef evbuffer* c_buf
 *         if isinstance(buf, buffer):             # <<<<<<<<<<<<<<
 *             self._add_default_response_headers()
 *             evhttp_send_reply(self.__obj, code, reason, (<buffer>buf).__obj)
 */
  __pyx_t_1 = PyObject_TypeCheck(__pyx_v_buf, ((PyTypeObject *)((PyObject*)__pyx_ptype_6gevent_4core_buffer))); 
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":324
 *         cdef evbuffer* c_buf
 *         if isinstance(buf, buffer):
 *             self._add_default_response_headers()             # <<<<<<<<<<<<<<
 *             evhttp_send_reply(self.__obj, code, reason, (<buffer>buf).__obj)
 *         elif isinstance(buf, str):
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_29); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":325
 *         if isinstance(buf, buffer):
 *             self._add_default_response_headers()
 *             evhttp_send_reply(self.__obj, code, reason, (<buffer>buf).__obj)             # <<<<<<<<<<<<<<
 *         elif isinstance(buf, str):
 *             self._add_default_response_headers()
 */
    evhttp_send_reply(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj, __pyx_v_code, __pyx_v_reason, ((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_buf)->__pyx___obj);
    goto __pyx_L7;
  }

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":326
 *             self._add_default_response_headers()
 *             evhttp_send_reply(self.__obj, code, reason, (<buffer>buf).__obj)
 *         elif isinstance(buf, str):             # <<<<<<<<<<<<<<
 *             self._add_default_response_headers()
 *             c_buf = evbuffer_new()
 */
  __pyx_t_1 = PyObject_TypeCheck(__pyx_v_buf, ((PyTypeObject *)((PyObject*)&PyString_Type))); 
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":327
 *             evhttp_send_reply(self.__obj, code, reason, (<buffer>buf).__obj)
 *         elif isinstance(buf, str):
 *             self._add_default_response_headers()             # <<<<<<<<<<<<<<
 *             c_buf = evbuffer_new()
 *             evbuffer_add(c_buf, <char *>buf, len(buf))
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_29); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":328
 *         elif isinstance(buf, str):
 *             self._add_default_response_headers()
 *             c_buf = evbuffer_new()             # <<<<<<<<<<<<<<
 *             evbuffer_add(c_buf, <char *>buf, len(buf))
 *             evhttp_send_reply(self.__obj, code, reason, c_buf)
 */
    __pyx_v_c_buf = evbuffer_new();

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":329
 *             self._add_default_response_headers()
 *             c_buf = evbuffer_new()
 *             evbuffer_add(c_buf, <char *>buf, len(buf))             # <<<<<<<<<<<<<<
 *             evhttp_send_reply(self.__obj, code, reason, c_buf)
 *             evbuffer_free(c_buf)
 */
    __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_v_buf); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    evbuffer_add(__pyx_v_c_buf, ((char *)__pyx_t_4), __pyx_t_5);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":330
 *             c_buf = evbuffer_new()
 *             evbuffer_add(c_buf, <char *>buf, len(buf))
 *             evhttp_send_reply(self.__obj, code, reason, c_buf)             # <<<<<<<<<<<<<<
 *             evbuffer_free(c_buf)
 *         else:
 */
    evhttp_send_reply(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj, __pyx_v_code, __pyx_v_reason, __pyx_v_c_buf);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":331
 *             evbuffer_add(c_buf, <char *>buf, len(buf))
 *             evhttp_send_reply(self.__obj, code, reason, c_buf)
 *             evbuffer_free(c_buf)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('Expected str or buffer: %r' % (buf, ))
 */
    evbuffer_free(__pyx_v_c_buf);
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":333
 *             evbuffer_free(c_buf)
 *         else:
 *             raise TypeError('Expected str or buffer: %r' % (buf, ))             # <<<<<<<<<<<<<<
 * 
 *     def send_reply_start(self, int code, char *reason):
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_buf);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_buf);
    __Pyx_GIVEREF(__pyx_v_buf);
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L7:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.send_reply");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":335
 *             raise TypeError('Expected str or buffer: %r' % (buf, ))
 * 
 *     def send_reply_start(self, int code, char *reason):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_send_reply_start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_send_reply_start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_code;
  char *__pyx_v_reason;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__code,&__pyx_n_s__reason,0};
  __Pyx_RefNannySetupContext("send_reply_start");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__code);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reason);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("send_reply_start", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_reply_start") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_code = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_code == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_reason = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_reason) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_code = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_code == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_reason = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_reason) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send_reply_start", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_request.send_reply_start");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":336
 * 
 *     def send_reply_start(self, int code, char *reason):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         self._add_default_response_headers()
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":337
 *     def send_reply_start(self, int code, char *reason):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         self._add_default_response_headers()
 *         evhttp_send_reply_start(self.__obj, code, reason)
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":338
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         self._add_default_response_headers()             # <<<<<<<<<<<<<<
 *         evhttp_send_reply_start(self.__obj, code, reason)
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_29); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":339
 *             raise HttpRequestDeleted
 *         self._add_default_response_headers()
 *         evhttp_send_reply_start(self.__obj, code, reason)             # <<<<<<<<<<<<<<
 * 
 *     def send_reply_chunk(self, object buf):
 */
  evhttp_send_reply_start(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj, __pyx_v_code, __pyx_v_reason);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.send_reply_start");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":341
 *         evhttp_send_reply_start(self.__obj, code, reason)
 * 
 *     def send_reply_chunk(self, object buf):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_send_reply_chunk(PyObject *__pyx_v_self, PyObject *__pyx_v_buf); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_send_reply_chunk(PyObject *__pyx_v_self, PyObject *__pyx_v_buf) {
  struct evbuffer *__pyx_v_c_buf;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("send_reply_chunk");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_buf);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":342
 * 
 *     def send_reply_chunk(self, object buf):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         cdef evbuffer* c_buf
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":343
 *     def send_reply_chunk(self, object buf):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         cdef evbuffer* c_buf
 *         if isinstance(buf, buffer):
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":345
 *             raise HttpRequestDeleted
 *         cdef evbuffer* c_buf
 *         if isinstance(buf, buffer):             # <<<<<<<<<<<<<<
 *             evhttp_send_reply_chunk(self.__obj, (<buffer>buf).__obj)
 *         elif isinstance(buf, str):
 */
  __pyx_t_1 = PyObject_TypeCheck(__pyx_v_buf, ((PyTypeObject *)((PyObject*)__pyx_ptype_6gevent_4core_buffer))); 
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":346
 *         cdef evbuffer* c_buf
 *         if isinstance(buf, buffer):
 *             evhttp_send_reply_chunk(self.__obj, (<buffer>buf).__obj)             # <<<<<<<<<<<<<<
 *         elif isinstance(buf, str):
 *             c_buf = evbuffer_new()
 */
    evhttp_send_reply_chunk(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj, ((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_buf)->__pyx___obj);
    goto __pyx_L6;
  }

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":347
 *         if isinstance(buf, buffer):
 *             evhttp_send_reply_chunk(self.__obj, (<buffer>buf).__obj)
 *         elif isinstance(buf, str):             # <<<<<<<<<<<<<<
 *             c_buf = evbuffer_new()
 *             evbuffer_add(c_buf, <char *>buf, len(buf))
 */
  __pyx_t_1 = PyObject_TypeCheck(__pyx_v_buf, ((PyTypeObject *)((PyObject*)&PyString_Type))); 
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":348
 *             evhttp_send_reply_chunk(self.__obj, (<buffer>buf).__obj)
 *         elif isinstance(buf, str):
 *             c_buf = evbuffer_new()             # <<<<<<<<<<<<<<
 *             evbuffer_add(c_buf, <char *>buf, len(buf))
 *             evhttp_send_reply_chunk(self.__obj, c_buf)
 */
    __pyx_v_c_buf = evbuffer_new();

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":349
 *         elif isinstance(buf, str):
 *             c_buf = evbuffer_new()
 *             evbuffer_add(c_buf, <char *>buf, len(buf))             # <<<<<<<<<<<<<<
 *             evhttp_send_reply_chunk(self.__obj, c_buf)
 *             evbuffer_free(c_buf)
 */
    __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_buf); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    evbuffer_add(__pyx_v_c_buf, ((char *)__pyx_t_3), __pyx_t_4);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":350
 *             c_buf = evbuffer_new()
 *             evbuffer_add(c_buf, <char *>buf, len(buf))
 *             evhttp_send_reply_chunk(self.__obj, c_buf)             # <<<<<<<<<<<<<<
 *             evbuffer_free(c_buf)
 *         else:
 */
    evhttp_send_reply_chunk(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj, __pyx_v_c_buf);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":351
 *             evbuffer_add(c_buf, <char *>buf, len(buf))
 *             evhttp_send_reply_chunk(self.__obj, c_buf)
 *             evbuffer_free(c_buf)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('Expected str or buffer: %r' % (buf, ))
 */
    evbuffer_free(__pyx_v_c_buf);
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":353
 *             evbuffer_free(c_buf)
 *         else:
 *             raise TypeError('Expected str or buffer: %r' % (buf, ))             # <<<<<<<<<<<<<<
 * 
 *     def send_reply_end(self):
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_buf);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_buf);
    __Pyx_GIVEREF(__pyx_v_buf);
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.http_request.send_reply_chunk");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":355
 *             raise TypeError('Expected str or buffer: %r' % (buf, ))
 * 
 *     def send_reply_end(self):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_send_reply_end(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_send_reply_end(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("send_reply_end");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":356
 * 
 *     def send_reply_end(self):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         evhttp_send_reply_end(self.__obj)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":357
 *     def send_reply_end(self):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         evhttp_send_reply_end(self.__obj)
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":358
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         evhttp_send_reply_end(self.__obj)             # <<<<<<<<<<<<<<
 * 
 *     def send_error(self, int code, char* reason):
 */
  evhttp_send_reply_end(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.send_reply_end");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":360
 *         evhttp_send_reply_end(self.__obj)
 * 
 *     def send_error(self, int code, char* reason):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_send_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_send_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_code;
  char *__pyx_v_reason;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__code,&__pyx_n_s__reason,0};
  __Pyx_RefNannySetupContext("send_error");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__code);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reason);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("send_error", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_error") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_code = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_code == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_reason = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_reason) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_code = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_code == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_reason = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_reason) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send_error", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_request.send_error");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":361
 * 
 *     def send_error(self, int code, char* reason):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         self._add_default_response_headers()
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":362
 *     def send_error(self, int code, char* reason):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         self._add_default_response_headers()
 *         evhttp_send_error(self.__obj, code, reason)
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":363
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         self._add_default_response_headers()             # <<<<<<<<<<<<<<
 *         evhttp_send_error(self.__obj, code, reason)
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_29); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":364
 *             raise HttpRequestDeleted
 *         self._add_default_response_headers()
 *         evhttp_send_error(self.__obj, code, reason)             # <<<<<<<<<<<<<<
 * 
 *     def find_input_header(self, char* key):
 */
  evhttp_send_error(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj, __pyx_v_code, __pyx_v_reason);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.send_error");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":366
 *         evhttp_send_error(self.__obj, code, reason)
 * 
 *     def find_input_header(self, char* key):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_find_input_header(PyObject *__pyx_v_self, PyObject *__pyx_arg_key); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_find_input_header(PyObject *__pyx_v_self, PyObject *__pyx_arg_key) {
  char *__pyx_v_key;
  const char* __pyx_v_val;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("find_input_header");
  assert(__pyx_arg_key); {
    __pyx_v_key = __Pyx_PyBytes_AsString(__pyx_arg_key); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_request.find_input_header");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":367
 * 
 *     def find_input_header(self, char* key):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         cdef const_char_ptr val = evhttp_find_header(self.__obj.input_headers, key)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":368
 *     def find_input_header(self, char* key):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         cdef const_char_ptr val = evhttp_find_header(self.__obj.input_headers, key)
 *         if val:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":369
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         cdef const_char_ptr val = evhttp_find_header(self.__obj.input_headers, key)             # <<<<<<<<<<<<<<
 *         if val:
 *             return val
 */
  __pyx_v_val = evhttp_find_header(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->input_headers, __pyx_v_key);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":370
 *             raise HttpRequestDeleted
 *         cdef const_char_ptr val = evhttp_find_header(self.__obj.input_headers, key)
 *         if val:             # <<<<<<<<<<<<<<
 *             return val
 * 
 */
  __pyx_t_1 = (__pyx_v_val != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":371
 *         cdef const_char_ptr val = evhttp_find_header(self.__obj.input_headers, key)
 *         if val:
 *             return val             # <<<<<<<<<<<<<<
 * 
 *     def find_output_header(self, char* key):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_val); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_r = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.find_input_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":373
 *             return val
 * 
 *     def find_output_header(self, char* key):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_find_output_header(PyObject *__pyx_v_self, PyObject *__pyx_arg_key); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_find_output_header(PyObject *__pyx_v_self, PyObject *__pyx_arg_key) {
  char *__pyx_v_key;
  const char* __pyx_v_val;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("find_output_header");
  assert(__pyx_arg_key); {
    __pyx_v_key = __Pyx_PyBytes_AsString(__pyx_arg_key); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_request.find_output_header");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":374
 * 
 *     def find_output_header(self, char* key):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         cdef const_char_ptr val = evhttp_find_header(self.__obj.output_headers, key)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":375
 *     def find_output_header(self, char* key):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         cdef const_char_ptr val = evhttp_find_header(self.__obj.output_headers, key)
 *         if val:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":376
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         cdef const_char_ptr val = evhttp_find_header(self.__obj.output_headers, key)             # <<<<<<<<<<<<<<
 *         if val:
 *             return val
 */
  __pyx_v_val = evhttp_find_header(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->output_headers, __pyx_v_key);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":377
 *             raise HttpRequestDeleted
 *         cdef const_char_ptr val = evhttp_find_header(self.__obj.output_headers, key)
 *         if val:             # <<<<<<<<<<<<<<
 *             return val
 * 
 */
  __pyx_t_1 = (__pyx_v_val != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":378
 *         cdef const_char_ptr val = evhttp_find_header(self.__obj.output_headers, key)
 *         if val:
 *             return val             # <<<<<<<<<<<<<<
 * 
 *     def add_input_header(self, char* key, char* value):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_val); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_r = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.find_output_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":380
 *             return val
 * 
 *     def add_input_header(self, char* key, char* value):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_add_input_header(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_add_input_header(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_key;
  char *__pyx_v_value;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__value,0};
  __Pyx_RefNannySetupContext("add_input_header");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_input_header", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "add_input_header") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_value = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_key = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_value = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_input_header", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_request.add_input_header");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":381
 * 
 *     def add_input_header(self, char* key, char* value):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         if evhttp_add_header(self.__obj.input_headers, key, value):
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":382
 *     def add_input_header(self, char* key, char* value):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         if evhttp_add_header(self.__obj.input_headers, key, value):
 *             raise RuntimeError('Internal error in evhttp_add_header')
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":383
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         if evhttp_add_header(self.__obj.input_headers, key, value):             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Internal error in evhttp_add_header')
 * 
 */
  __pyx_t_3 = evhttp_add_header(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->input_headers, __pyx_v_key, __pyx_v_value);
  if (__pyx_t_3) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":384
 *             raise HttpRequestDeleted
 *         if evhttp_add_header(self.__obj.input_headers, key, value):
 *             raise RuntimeError('Internal error in evhttp_add_header')             # <<<<<<<<<<<<<<
 * 
 *     def add_output_header(self, char* key, char* value):
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_31));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
    __pyx_t_4 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_request.add_input_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":386
 *             raise RuntimeError('Internal error in evhttp_add_header')
 * 
 *     def add_output_header(self, char* key, char* value):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_add_output_header(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_add_output_header(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_key;
  char *__pyx_v_value;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__value,0};
  __Pyx_RefNannySetupContext("add_output_header");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_output_header", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "add_output_header") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_value = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_key = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_value = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_output_header", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_request.add_output_header");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":387
 * 
 *     def add_output_header(self, char* key, char* value):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         if evhttp_add_header(self.__obj.output_headers, key, value):
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":388
 *     def add_output_header(self, char* key, char* value):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         if evhttp_add_header(self.__obj.output_headers, key, value):
 *             raise RuntimeError('Internal error in evhttp_add_header')
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":389
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         if evhttp_add_header(self.__obj.output_headers, key, value):             # <<<<<<<<<<<<<<
 *             raise RuntimeError('Internal error in evhttp_add_header')
 * 
 */
  __pyx_t_3 = evhttp_add_header(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->output_headers, __pyx_v_key, __pyx_v_value);
  if (__pyx_t_3) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":390
 *             raise HttpRequestDeleted
 *         if evhttp_add_header(self.__obj.output_headers, key, value):
 *             raise RuntimeError('Internal error in evhttp_add_header')             # <<<<<<<<<<<<<<
 * 
 *     def remove_input_header(self, char* key):
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_31));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
    __pyx_t_4 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_request.add_output_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":392
 *             raise RuntimeError('Internal error in evhttp_add_header')
 * 
 *     def remove_input_header(self, char* key):             # <<<<<<<<<<<<<<
 *         """Return True if header was found and removed"""
 *         if not self.__obj:
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_remove_input_header(PyObject *__pyx_v_self, PyObject *__pyx_arg_key); /*proto*/
static char __pyx_doc_6gevent_4core_12http_request_remove_input_header[] = "Return True if header was found and removed";
static PyObject *__pyx_pf_6gevent_4core_12http_request_remove_input_header(PyObject *__pyx_v_self, PyObject *__pyx_arg_key) {
  char *__pyx_v_key;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("remove_input_header");
  assert(__pyx_arg_key); {
    __pyx_v_key = __Pyx_PyBytes_AsString(__pyx_arg_key); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_request.remove_input_header");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":394
 *     def remove_input_header(self, char* key):
 *         """Return True if header was found and removed"""
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         return True if 0 == evhttp_remove_header(self.__obj.input_headers, key) else False
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":395
 *         """Return True if header was found and removed"""
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         return True if 0 == evhttp_remove_header(self.__obj.input_headers, key) else False
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":396
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         return True if 0 == evhttp_remove_header(self.__obj.input_headers, key) else False             # <<<<<<<<<<<<<<
 * 
 *     def remove_output_header(self, char* key):
 */
  __Pyx_XDECREF(__pyx_r);
  if ((0 == evhttp_remove_header(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->input_headers, __pyx_v_key))) {
    __pyx_t_1 = 1;
  } else {
    __pyx_t_1 = 0;
  }
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 396; __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("gevent.core.http_request.remove_input_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":398
 *         return True if 0 == evhttp_remove_header(self.__obj.input_headers, key) else False
 * 
 *     def remove_output_header(self, char* key):             # <<<<<<<<<<<<<<
 *         """Return True if header was found and removed"""
 *         if not self.__obj:
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_remove_output_header(PyObject *__pyx_v_self, PyObject *__pyx_arg_key); /*proto*/
static char __pyx_doc_6gevent_4core_12http_request_remove_output_header[] = "Return True if header was found and removed";
static PyObject *__pyx_pf_6gevent_4core_12http_request_remove_output_header(PyObject *__pyx_v_self, PyObject *__pyx_arg_key) {
  char *__pyx_v_key;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("remove_output_header");
  assert(__pyx_arg_key); {
    __pyx_v_key = __Pyx_PyBytes_AsString(__pyx_arg_key); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_request.remove_output_header");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":400
 *     def remove_output_header(self, char* key):
 *         """Return True if header was found and removed"""
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         return True if 0 == evhttp_remove_header(self.__obj.output_headers, key) else False
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":401
 *         """Return True if header was found and removed"""
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         return True if 0 == evhttp_remove_header(self.__obj.output_headers, key) else False
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":402
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         return True if 0 == evhttp_remove_header(self.__obj.output_headers, key) else False             # <<<<<<<<<<<<<<
 * 
 *     def clear_input_headers(self):
 */
  __Pyx_XDECREF(__pyx_r);
  if ((0 == evhttp_remove_header(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->output_headers, __pyx_v_key))) {
    __pyx_t_1 = 1;
  } else {
    __pyx_t_1 = 0;
  }
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 402; __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("gevent.core.http_request.remove_output_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":404
 *         return True if 0 == evhttp_remove_header(self.__obj.output_headers, key) else False
 * 
 *     def clear_input_headers(self):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_clear_input_headers(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_clear_input_headers(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("clear_input_headers");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":405
 * 
 *     def clear_input_headers(self):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         evhttp_clear_headers(self.__obj.input_headers)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":406
 *     def clear_input_headers(self):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         evhttp_clear_headers(self.__obj.input_headers)
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":407
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         evhttp_clear_headers(self.__obj.input_headers)             # <<<<<<<<<<<<<<
 * 
 *     def clear_output_headers(self):
 */
  evhttp_clear_headers(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->input_headers);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.clear_input_headers");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":409
 *         evhttp_clear_headers(self.__obj.input_headers)
 * 
 *     def clear_output_headers(self):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_12http_request_clear_output_headers(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_12http_request_clear_output_headers(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("clear_output_headers");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":410
 * 
 *     def clear_output_headers(self):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         evhttp_clear_headers(self.__obj.output_headers)
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":411
 *     def clear_output_headers(self):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         evhttp_clear_headers(self.__obj.output_headers)
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HttpRequestDeleted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":412
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         evhttp_clear_headers(self.__obj.output_headers)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  evhttp_clear_headers(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->output_headers);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.clear_output_headers");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":419
 *     cdef evhttp_connection* __obj
 * 
 *     def __init__(self, size_t _obj):             # <<<<<<<<<<<<<<
 *         self.__obj = <evhttp_connection*>_obj
 * 
 */

static int __pyx_pf_6gevent_4core_15http_connection___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6gevent_4core_15http_connection___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v__obj;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s___obj,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s___obj);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__obj = __Pyx_PyInt_AsSize_t(values[0]); if (unlikely((__pyx_v__obj == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__obj = __Pyx_PyInt_AsSize_t(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v__obj == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http_connection.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":420
 * 
 *     def __init__(self, size_t _obj):
 *         self.__obj = <evhttp_connection*>_obj             # <<<<<<<<<<<<<<
 * 
 *     property _obj:
 */
  ((struct __pyx_obj_6gevent_4core_http_connection *)__pyx_v_self)->__pyx___obj = ((struct evhttp_connection *)__pyx_v__obj);

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

/* "/home/denis/work/gevent/gevent/evhttp.pxi":424
 *     property _obj:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return <size_t>(self.__obj)
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_15http_connection_4_obj___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_15http_connection_4_obj___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":425
 * 
 *         def __get__(self):
 *             return <size_t>(self.__obj)             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)((struct __pyx_obj_6gevent_4core_http_connection *)__pyx_v_self)->__pyx___obj)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 425; __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("gevent.core.http_connection._obj.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":427
 *             return <size_t>(self.__obj)
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj:
 *             return True
 */

static int __pyx_pf_6gevent_4core_15http_connection___nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_6gevent_4core_15http_connection___nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__nonzero__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":428
 * 
 *     def __nonzero__(self):
 *         if self.__obj:             # <<<<<<<<<<<<<<
 *             return True
 *         else:
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http_connection *)__pyx_v_self)->__pyx___obj != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":429
 *     def __nonzero__(self):
 *         if self.__obj:
 *             return True             # <<<<<<<<<<<<<<
 *         else:
 *             return False
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":431
 *             return True
 *         else:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":433
 *             return False
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         try:
 *             peer = self.peer
 */

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

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":434
 * 
 *     def __str__(self):
 *         try:             # <<<<<<<<<<<<<<
 *             peer = self.peer
 *         except HttpConnectionDeleted:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":435
 *     def __str__(self):
 *         try:
 *             peer = self.peer             # <<<<<<<<<<<<<<
 *         except HttpConnectionDeleted:
 *             peer = 'deleted'
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peer); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_v_peer);
      __pyx_v_peer = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L12_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":436
 *         try:
 *             peer = self.peer
 *         except HttpConnectionDeleted:             # <<<<<<<<<<<<<<
 *             peer = 'deleted'
 *         return '<%s %s>' % (self.__class__.__name__, peer)
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyErr_ExceptionMatches(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_2) {
      __Pyx_AddTraceback("gevent.core.http_connection.__str__");
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":437
 *             peer = self.peer
 *         except HttpConnectionDeleted:
 *             peer = 'deleted'             # <<<<<<<<<<<<<<
 *         return '<%s %s>' % (self.__class__.__name__, peer)
 * 
 */
      __Pyx_INCREF(((PyObject *)__pyx_n_s__deleted));
      __Pyx_DECREF(__pyx_v_peer);
      __pyx_v_peer = ((PyObject *)__pyx_n_s__deleted);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L12_try_end:;
  }

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":438
 *         except HttpConnectionDeleted:
 *             peer = 'deleted'
 *         return '<%s %s>' % (self.__class__.__name__, peer)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____class__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____name__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_peer);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_peer);
  __Pyx_GIVEREF(__pyx_v_peer);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_connection.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_peer);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":440
 *         return '<%s %s>' % (self.__class__.__name__, peer)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         try:
 *             peer = ' %s' % (self.peer, )
 */

static PyObject *__pyx_pf_6gevent_4core_15http_connection___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_15http_connection___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_peer;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__repr__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_peer = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":441
 * 
 *     def __repr__(self):
 *         try:             # <<<<<<<<<<<<<<
 *             peer = ' %s' % (self.peer, )
 *         except HttpConnectionDeleted:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":442
 *     def __repr__(self):
 *         try:
 *             peer = ' %s' % (self.peer, )             # <<<<<<<<<<<<<<
 *         except HttpConnectionDeleted:
 *             peer = ''
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__peer); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_v_peer);
      __pyx_v_peer = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L12_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":443
 *         try:
 *             peer = ' %s' % (self.peer, )
 *         except HttpConnectionDeleted:             # <<<<<<<<<<<<<<
 *             peer = ''
 *         return '<%s _obj=0x%x%s>' % (self.__class__.__name__, self._obj, peer)
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {
      __Pyx_AddTraceback("gevent.core.http_connection.__repr__");
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":444
 *             peer = ' %s' % (self.peer, )
 *         except HttpConnectionDeleted:
 *             peer = ''             # <<<<<<<<<<<<<<
 *         return '<%s _obj=0x%x%s>' % (self.__class__.__name__, self._obj, peer)
 * 
 */
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
      __Pyx_DECREF(__pyx_v_peer);
      __pyx_v_peer = ((PyObject *)__pyx_kp_s_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L12_try_end:;
  }

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":445
 *         except HttpConnectionDeleted:
 *             peer = ''
 *         return '<%s _obj=0x%x%s>' % (self.__class__.__name__, self._obj, peer)             # <<<<<<<<<<<<<<
 * 
 *     property peer:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____class__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____name__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___obj); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_peer);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_peer);
  __Pyx_GIVEREF(__pyx_v_peer);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_33), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_connection.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_peer);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":449
 *     property peer:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.__obj:
 *                 raise HttpConnectionDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_15http_connection_4peer___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_15http_connection_4peer___get__(PyObject *__pyx_v_self) {
  char *__pyx_v_address;
  ev_uint16_t __pyx_v_port;
  PyObject *__pyx_v_addr;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_addr = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":450
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpConnectionDeleted
 *             cdef char* address = NULL
 */
  __pyx_t_1 = (!(((struct __pyx_obj_6gevent_4core_http_connection *)__pyx_v_self)->__pyx___obj != 0));
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":451
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpConnectionDeleted             # <<<<<<<<<<<<<<
 *             cdef char* address = NULL
 *             cdef ev_uint16_t port = 0
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s_32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":452
 *             if not self.__obj:
 *                 raise HttpConnectionDeleted
 *             cdef char* address = NULL             # <<<<<<<<<<<<<<
 *             cdef ev_uint16_t port = 0
 *             evhttp_connection_get_peer(self.__obj, &address, &port)
 */
  __pyx_v_address = NULL;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":453
 *                 raise HttpConnectionDeleted
 *             cdef char* address = NULL
 *             cdef ev_uint16_t port = 0             # <<<<<<<<<<<<<<
 *             evhttp_connection_get_peer(self.__obj, &address, &port)
 *             if address:
 */
  __pyx_v_port = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":454
 *             cdef char* address = NULL
 *             cdef ev_uint16_t port = 0
 *             evhttp_connection_get_peer(self.__obj, &address, &port)             # <<<<<<<<<<<<<<
 *             if address:
 *                 addr = <str>address
 */
  evhttp_connection_get_peer(((struct __pyx_obj_6gevent_4core_http_connection *)__pyx_v_self)->__pyx___obj, (&__pyx_v_address), (&__pyx_v_port));

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":455
 *             cdef ev_uint16_t port = 0
 *             evhttp_connection_get_peer(self.__obj, &address, &port)
 *             if address:             # <<<<<<<<<<<<<<
 *                 addr = <str>address
 *             else:
 */
  __pyx_t_1 = (__pyx_v_address != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":456
 *             evhttp_connection_get_peer(self.__obj, &address, &port)
 *             if address:
 *                 addr = <str>address             # <<<<<<<<<<<<<<
 *             else:
 *                 addr = None
 */
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_address); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_v_addr);
    __pyx_v_addr = ((PyObject *)__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":458
 *                 addr = <str>address
 *             else:
 *                 addr = None             # <<<<<<<<<<<<<<
 *             return (addr, port)
 * 
 */
    __Pyx_INCREF(Py_None);
    __Pyx_DECREF(__pyx_v_addr);
    __pyx_v_addr = Py_None;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":459
 *             else:
 *                 addr = None
 *             return (addr, port)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_to_py_ev_uint16_t(__pyx_v_port); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_addr);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_addr);
  __Pyx_GIVEREF(__pyx_v_addr);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_connection.peer.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_addr);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":462
 * 
 * 
 * cdef void _http_cb_handler(evhttp_request* request, void *arg) with gil:             # <<<<<<<<<<<<<<
 *     cdef http server = <object>arg
 *     cdef http_request req = http_request(<size_t>request, server.default_response_headers)
 */

static  void __pyx_f_6gevent_4core__http_cb_handler(struct evhttp_request *__pyx_v_request, void *__pyx_v_arg) {
  struct __pyx_obj_6gevent_4core_http *__pyx_v_server = 0;
  struct __pyx_obj_6gevent_4core_http_request *__pyx_v_req = 0;
  struct evhttp_connection *__pyx_v_conn;
  PyObject *__pyx_v_requests;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  size_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyGILState_STATE _save = PyGILState_Ensure();
  __Pyx_RefNannySetupContext("_http_cb_handler");
  __pyx_v_requests = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":463
 * 
 * cdef void _http_cb_handler(evhttp_request* request, void *arg) with gil:
 *     cdef http server = <object>arg             # <<<<<<<<<<<<<<
 *     cdef http_request req = http_request(<size_t>request, server.default_response_headers)
 *     cdef evhttp_connection* conn = request.evcon
 */
  if (!(likely(((((PyObject *)__pyx_v_arg)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_arg), __pyx_ptype_6gevent_4core_http))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(((PyObject *)__pyx_v_arg));
  __pyx_v_server = ((struct __pyx_obj_6gevent_4core_http *)((PyObject *)__pyx_v_arg));

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":464
 * cdef void _http_cb_handler(evhttp_request* request, void *arg) with gil:
 *     cdef http server = <object>arg
 *     cdef http_request req = http_request(<size_t>request, server.default_response_headers)             # <<<<<<<<<<<<<<
 *     cdef evhttp_connection* conn = request.evcon
 *     cdef object requests
 */
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_request)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_server->default_response_headers);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_server->default_response_headers);
  __Pyx_GIVEREF(__pyx_v_server->default_response_headers);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_http_request)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_req = ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":465
 *     cdef http server = <object>arg
 *     cdef http_request req = http_request(<size_t>request, server.default_response_headers)
 *     cdef evhttp_connection* conn = request.evcon             # <<<<<<<<<<<<<<
 *     cdef object requests
 *     try:
 */
  __pyx_v_conn = __pyx_v_request->evcon;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":467
 *     cdef evhttp_connection* conn = request.evcon
 *     cdef object requests
 *     try:             # <<<<<<<<<<<<<<
 *         evhttp_connection_set_closecb(conn, _http_closecb_handler, arg)
 *         requests = server._requests.pop(<size_t>conn, None)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":468
 *     cdef object requests
 *     try:
 *         evhttp_connection_set_closecb(conn, _http_closecb_handler, arg)             # <<<<<<<<<<<<<<
 *         requests = server._requests.pop(<size_t>conn, None)
 *         if requests is None:
 */
      evhttp_connection_set_closecb(__pyx_v_conn, __pyx_f_6gevent_4core__http_closecb_handler, __pyx_v_arg);

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":469
 *     try:
 *         evhttp_connection_set_closecb(conn, _http_closecb_handler, arg)
 *         requests = server._requests.pop(<size_t>conn, None)             # <<<<<<<<<<<<<<
 *         if requests is None:
 *             requests = weakref.WeakKeyDictionary()
 */
      __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_server->_requests), __pyx_n_s__pop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_conn)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __Pyx_INCREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_3, 1, Py_None);
      __Pyx_GIVEREF(Py_None);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_requests);
      __pyx_v_requests = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":470
 *         evhttp_connection_set_closecb(conn, _http_closecb_handler, arg)
 *         requests = server._requests.pop(<size_t>conn, None)
 *         if requests is None:             # <<<<<<<<<<<<<<
 *             requests = weakref.WeakKeyDictionary()
 *             server._requests[<size_t>conn] = requests
 */
      __pyx_t_4 = (__pyx_v_requests == Py_None);
      if (__pyx_t_4) {

        /* "/home/denis/work/gevent/gevent/evhttp.pxi":471
 *         requests = server._requests.pop(<size_t>conn, None)
 *         if requests is None:
 *             requests = weakref.WeakKeyDictionary()             # <<<<<<<<<<<<<<
 *             server._requests[<size_t>conn] = requests
 *         requests[req] = True
 */
        __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__weakref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__WeakKeyDictionary); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_v_requests);
        __pyx_v_requests = __pyx_t_2;
        __pyx_t_2 = 0;

        /* "/home/denis/work/gevent/gevent/evhttp.pxi":472
 *         if requests is None:
 *             requests = weakref.WeakKeyDictionary()
 *             server._requests[<size_t>conn] = requests             # <<<<<<<<<<<<<<
 *         requests[req] = True
 *         server.handle(req)
 */
        __pyx_t_5 = ((size_t)__pyx_v_conn);
        if (__Pyx_SetItemInt(((PyObject *)__pyx_v_server->_requests), __pyx_t_5, __pyx_v_requests, sizeof(size_t)+1, __Pyx_PyInt_FromSize_t) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":473
 *             requests = weakref.WeakKeyDictionary()
 *             server._requests[<size_t>conn] = requests
 *         requests[req] = True             # <<<<<<<<<<<<<<
 *         server.handle(req)
 *     except:
 */
      __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_v_requests, ((PyObject *)__pyx_v_req), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":474
 *             server._requests[<size_t>conn] = requests
 *         requests[req] = True
 *         server.handle(req)             # <<<<<<<<<<<<<<
 *     except:
 *         traceback.print_exc()
 */
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_req));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_req));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_req));
      __pyx_t_3 = PyObject_Call(__pyx_v_server->handle, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":475
 *         requests[req] = True
 *         server.handle(req)
 *     except:             # <<<<<<<<<<<<<<
 *         traceback.print_exc()
 *         try:
 */
    /*except:*/ {
      __Pyx_AddTraceback("gevent.core._http_cb_handler");
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":476
 *         server.handle(req)
 *     except:
 *         traceback.print_exc()             # <<<<<<<<<<<<<<
 *         try:
 *             sys.stderr.write('%s: Failed to handle request: %s\n\n' % (server, req, ))
 */
      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__traceback); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__print_exc); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":477
 *     except:
 *         traceback.print_exc()
 *         try:             # <<<<<<<<<<<<<<
 *             sys.stderr.write('%s: Failed to handle request: %s\n\n' % (server, req, ))
 *         except:
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        __Pyx_XGOTREF(__pyx_save_exc_type);
        __Pyx_XGOTREF(__pyx_save_exc_value);
        __Pyx_XGOTREF(__pyx_save_exc_tb);
        /*try:*/ {

          /* "/home/denis/work/gevent/gevent/evhttp.pxi":478
 *         traceback.print_exc()
 *         try:
 *             sys.stderr.write('%s: Failed to handle request: %s\n\n' % (server, req, ))             # <<<<<<<<<<<<<<
 *         except:
 *             traceback.print_exc()
 */
          __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__stderr); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__write); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_INCREF(((PyObject *)__pyx_v_server));
          PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_server));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_server));
          __Pyx_INCREF(((PyObject *)__pyx_v_req));
          PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_v_req));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_req));
          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_34), __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
          __Pyx_GOTREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_8);
          __pyx_t_8 = 0;
          __pyx_t_8 = PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L21_try_end;
        __pyx_L14_error:;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "/home/denis/work/gevent/gevent/evhttp.pxi":479
 *         try:
 *             sys.stderr.write('%s: Failed to handle request: %s\n\n' % (server, req, ))
 *         except:             # <<<<<<<<<<<<<<
 *             traceback.print_exc()
 *         # without clearing exc_info a reference to the request is somehow leaked
 */
        /*except:*/ {
          __Pyx_AddTraceback("gevent.core._http_cb_handler");
          if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GOTREF(__pyx_t_6);

          /* "/home/denis/work/gevent/gevent/evhttp.pxi":480
 *             sys.stderr.write('%s: Failed to handle request: %s\n\n' % (server, req, ))
 *         except:
 *             traceback.print_exc()             # <<<<<<<<<<<<<<
 *         # without clearing exc_info a reference to the request is somehow leaked
 *         sys.exc_clear()
 */
          __pyx_t_9 = __Pyx_GetName(__pyx_m, __pyx_n_s__traceback); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__print_exc); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          goto __pyx_L15_exception_handled;
        }
        __pyx_L16_except_error:;
        __Pyx_XGIVEREF(__pyx_save_exc_type);
        __Pyx_XGIVEREF(__pyx_save_exc_value);
        __Pyx_XGIVEREF(__pyx_save_exc_tb);
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        goto __pyx_L5_except_error;
        __pyx_L15_exception_handled:;
        __Pyx_XGIVEREF(__pyx_save_exc_type);
        __Pyx_XGIVEREF(__pyx_save_exc_value);
        __Pyx_XGIVEREF(__pyx_save_exc_tb);
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L21_try_end:;
      }

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":482
 *             traceback.print_exc()
 *         # without clearing exc_info a reference to the request is somehow leaked
 *         sys.exc_clear()             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__exc_clear); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("gevent.core._http_cb_handler");
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_server);
  __Pyx_XDECREF((PyObject *)__pyx_v_req);
  __Pyx_DECREF(__pyx_v_requests);
  __Pyx_RefNannyFinishContext();
  PyGILState_Release(_save);
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":485
 * 
 * 
 * cdef void _http_closecb_handler(evhttp_connection* connection, void *arg) with gil:             # <<<<<<<<<<<<<<
 *     cdef http server = <object>arg
 *     cdef object requests
 */

static  void __pyx_f_6gevent_4core__http_closecb_handler(struct evhttp_connection *__pyx_v_connection, void *__pyx_v_arg) {
  struct __pyx_obj_6gevent_4core_http *__pyx_v_server = 0;
  PyObject *__pyx_v_request;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyGILState_STATE _save = PyGILState_Ensure();
  __Pyx_RefNannySetupContext("_http_closecb_handler");
  __pyx_v_request = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":486
 * 
 * cdef void _http_closecb_handler(evhttp_connection* connection, void *arg) with gil:
 *     cdef http server = <object>arg             # <<<<<<<<<<<<<<
 *     cdef object requests
 *     for request in server._requests.pop(<size_t>connection, {}).keys():
 */
  if (!(likely(((((PyObject *)__pyx_v_arg)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_arg), __pyx_ptype_6gevent_4core_http))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(((PyObject *)__pyx_v_arg));
  __pyx_v_server = ((struct __pyx_obj_6gevent_4core_http *)((PyObject *)__pyx_v_arg));

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":488
 *     cdef http server = <object>arg
 *     cdef object requests
 *     for request in server._requests.pop(<size_t>connection, {}).keys():             # <<<<<<<<<<<<<<
 *         request.detach()
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_server->_requests), __pyx_n_s__pop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_connection)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__keys); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5);
  } else {
    __pyx_t_1 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_t_5))) {
      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_5)) break;
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
      if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++;
    } else {
      __pyx_t_4 = PyIter_Next(__pyx_t_5);
      if (!__pyx_t_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_DECREF(__pyx_v_request);
    __pyx_v_request = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":489
 *     cdef object requests
 *     for request in server._requests.pop(<size_t>connection, {}).keys():
 *         request.detach()             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_request, __pyx_n_s__detach); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("gevent.core._http_closecb_handler");
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_server);
  __Pyx_DECREF(__pyx_v_request);
  __Pyx_RefNannyFinishContext();
  PyGILState_Release(_save);
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":492
 * 
 * 
 * cdef void _http_cb_reply_error(evhttp_request* request, void *arg):             # <<<<<<<<<<<<<<
 *     report_internal_error(request)
 * 
 */

static  void __pyx_f_6gevent_4core__http_cb_reply_error(struct evhttp_request *__pyx_v_request, void *__pyx_v_arg) {
  __Pyx_RefNannySetupContext("_http_cb_reply_error");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":493
 * 
 * cdef void _http_cb_reply_error(evhttp_request* request, void *arg):
 *     report_internal_error(request)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_f_6gevent_4core_report_internal_error(__pyx_v_request);

  __Pyx_RefNannyFinishContext();
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":496
 * 
 * 
 * cdef void report_internal_error(evhttp_request* request):             # <<<<<<<<<<<<<<
 *     cdef evbuffer* c_buf
 *     if request != NULL and request.response_code == 0:
 */

static  void __pyx_f_6gevent_4core_report_internal_error(struct evhttp_request *__pyx_v_request) {
  struct evbuffer *__pyx_v_c_buf;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("report_internal_error");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":498
 * cdef void report_internal_error(evhttp_request* request):
 *     cdef evbuffer* c_buf
 *     if request != NULL and request.response_code == 0:             # <<<<<<<<<<<<<<
 *         evhttp_add_header(request.output_headers, "Connection", "close")
 *         evhttp_add_header(request.output_headers, "Content-type", "text/plain")
 */
  __pyx_t_1 = (__pyx_v_request != NULL);
  if (__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_request->response_code == 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":499
 *     cdef evbuffer* c_buf
 *     if request != NULL and request.response_code == 0:
 *         evhttp_add_header(request.output_headers, "Connection", "close")             # <<<<<<<<<<<<<<
 *         evhttp_add_header(request.output_headers, "Content-type", "text/plain")
 *         c_buf = evbuffer_new()
 */
    evhttp_add_header(__pyx_v_request->output_headers, __pyx_k__Connection, __pyx_k__close);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":500
 *     if request != NULL and request.response_code == 0:
 *         evhttp_add_header(request.output_headers, "Connection", "close")
 *         evhttp_add_header(request.output_headers, "Content-type", "text/plain")             # <<<<<<<<<<<<<<
 *         c_buf = evbuffer_new()
 *         evhttp_add_header(request.output_headers, "Content-length", "21")
 */
    evhttp_add_header(__pyx_v_request->output_headers, __pyx_k_35, __pyx_k_36);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":501
 *         evhttp_add_header(request.output_headers, "Connection", "close")
 *         evhttp_add_header(request.output_headers, "Content-type", "text/plain")
 *         c_buf = evbuffer_new()             # <<<<<<<<<<<<<<
 *         evhttp_add_header(request.output_headers, "Content-length", "21")
 *         evbuffer_add(c_buf, "Internal Server Error", 21)
 */
    __pyx_v_c_buf = evbuffer_new();

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":502
 *         evhttp_add_header(request.output_headers, "Content-type", "text/plain")
 *         c_buf = evbuffer_new()
 *         evhttp_add_header(request.output_headers, "Content-length", "21")             # <<<<<<<<<<<<<<
 *         evbuffer_add(c_buf, "Internal Server Error", 21)
 *         evhttp_send_reply(request, 500, "Internal Server Error", c_buf)
 */
    evhttp_add_header(__pyx_v_request->output_headers, __pyx_k_37, __pyx_k__21);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":503
 *         c_buf = evbuffer_new()
 *         evhttp_add_header(request.output_headers, "Content-length", "21")
 *         evbuffer_add(c_buf, "Internal Server Error", 21)             # <<<<<<<<<<<<<<
 *         evhttp_send_reply(request, 500, "Internal Server Error", c_buf)
 *         evbuffer_free(c_buf)
 */
    evbuffer_add(__pyx_v_c_buf, __pyx_k_38, 21);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":504
 *         evhttp_add_header(request.output_headers, "Content-length", "21")
 *         evbuffer_add(c_buf, "Internal Server Error", 21)
 *         evhttp_send_reply(request, 500, "Internal Server Error", c_buf)             # <<<<<<<<<<<<<<
 *         evbuffer_free(c_buf)
 * 
 */
    evhttp_send_reply(__pyx_v_request, 500, __pyx_k_38, __pyx_v_c_buf);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":505
 *         evbuffer_add(c_buf, "Internal Server Error", 21)
 *         evhttp_send_reply(request, 500, "Internal Server Error", c_buf)
 *         evbuffer_free(c_buf)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    evbuffer_free(__pyx_v_c_buf);
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":514
 *     cdef dict _requests
 * 
 *     def __init__(self, object handle, object default_response_headers=None):             # <<<<<<<<<<<<<<
 *         self.handle = handle
 *         if default_response_headers is None:
 */

static int __pyx_pf_6gevent_4core_4http___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6gevent_4core_4http___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_handle = 0;
  PyObject *__pyx_v_default_response_headers = 0;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__handle,&__pyx_n_s_21,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__handle);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_21);
        if (unlikely(value)) { values[1] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_handle = values[0];
    __pyx_v_default_response_headers = values[1];
  } else {
    __pyx_v_default_response_headers = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_default_response_headers = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_handle = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_handle);
  __Pyx_INCREF(__pyx_v_default_response_headers);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":515
 * 
 *     def __init__(self, object handle, object default_response_headers=None):
 *         self.handle = handle             # <<<<<<<<<<<<<<
 *         if default_response_headers is None:
 *             self.default_response_headers = []
 */
  __Pyx_INCREF(__pyx_v_handle);
  __Pyx_GIVEREF(__pyx_v_handle);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->handle);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->handle);
  ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->handle = __pyx_v_handle;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":516
 *     def __init__(self, object handle, object default_response_headers=None):
 *         self.handle = handle
 *         if default_response_headers is None:             # <<<<<<<<<<<<<<
 *             self.default_response_headers = []
 *         else:
 */
  __pyx_t_1 = (__pyx_v_default_response_headers == Py_None);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":517
 *         self.handle = handle
 *         if default_response_headers is None:
 *             self.default_response_headers = []             # <<<<<<<<<<<<<<
 *         else:
 *             self.default_response_headers = default_response_headers
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->default_response_headers);
    __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->default_response_headers);
    ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->default_response_headers = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":519
 *             self.default_response_headers = []
 *         else:
 *             self.default_response_headers = default_response_headers             # <<<<<<<<<<<<<<
 *         self._requests = {} # maps connection id to WeakKeyDictionary which holds requests
 *         self.__obj = evhttp_new(current_base)
 */
    __Pyx_INCREF(__pyx_v_default_response_headers);
    __Pyx_GIVEREF(__pyx_v_default_response_headers);
    __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->default_response_headers);
    __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->default_response_headers);
    ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->default_response_headers = __pyx_v_default_response_headers;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":520
 *         else:
 *             self.default_response_headers = default_response_headers
 *         self._requests = {} # maps connection id to WeakKeyDictionary which holds requests             # <<<<<<<<<<<<<<
 *         self.__obj = evhttp_new(current_base)
 *         evhttp_set_gencb(self.__obj, _http_cb_handler, <void *>self)
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_requests);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_requests));
  ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_requests = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":521
 *             self.default_response_headers = default_response_headers
 *         self._requests = {} # maps connection id to WeakKeyDictionary which holds requests
 *         self.__obj = evhttp_new(current_base)             # <<<<<<<<<<<<<<
 *         evhttp_set_gencb(self.__obj, _http_cb_handler, <void *>self)
 * 
 */
  ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj = evhttp_new(current_base);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":522
 *         self._requests = {} # maps connection id to WeakKeyDictionary which holds requests
 *         self.__obj = evhttp_new(current_base)
 *         evhttp_set_gencb(self.__obj, _http_cb_handler, <void *>self)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  evhttp_set_gencb(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj, __pyx_f_6gevent_4core__http_cb_handler, ((void *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_handle);
  __Pyx_DECREF(__pyx_v_default_response_headers);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":524
 *         evhttp_set_gencb(self.__obj, _http_cb_handler, <void *>self)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj != NULL:
 *             evhttp_set_gencb(self.__obj, _http_cb_reply_error, NULL)
 */

static void __pyx_pf_6gevent_4core_4http___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_6gevent_4core_4http___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":525
 * 
 *     def __dealloc__(self):
 *         if self.__obj != NULL:             # <<<<<<<<<<<<<<
 *             evhttp_set_gencb(self.__obj, _http_cb_reply_error, NULL)
 *             evhttp_free(self.__obj)
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj != NULL);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":526
 *     def __dealloc__(self):
 *         if self.__obj != NULL:
 *             evhttp_set_gencb(self.__obj, _http_cb_reply_error, NULL)             # <<<<<<<<<<<<<<
 *             evhttp_free(self.__obj)
 *         self.__obj = NULL
 */
    evhttp_set_gencb(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj, __pyx_f_6gevent_4core__http_cb_reply_error, NULL);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":527
 *         if self.__obj != NULL:
 *             evhttp_set_gencb(self.__obj, _http_cb_reply_error, NULL)
 *             evhttp_free(self.__obj)             # <<<<<<<<<<<<<<
 *         self.__obj = NULL
 * 
 */
    evhttp_free(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":528
 *             evhttp_set_gencb(self.__obj, _http_cb_reply_error, NULL)
 *             evhttp_free(self.__obj)
 *         self.__obj = NULL             # <<<<<<<<<<<<<<
 * 
 *     property _obj:
 */
  ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj = NULL;

  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":532
 *     property _obj:
 * 
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return <size_t>(self.__obj)
 * 
 */

static PyObject *__pyx_pf_6gevent_4core_4http_4_obj___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_4http_4_obj___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":533
 * 
 *         def __get__(self):
 *             return <size_t>(self.__obj)             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 533; __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("gevent.core.http._obj.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":535
 *             return <size_t>(self.__obj)
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj:
 *             return True
 */

static int __pyx_pf_6gevent_4core_4http___nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_6gevent_4core_4http___nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__nonzero__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":536
 * 
 *     def __nonzero__(self):
 *         if self.__obj:             # <<<<<<<<<<<<<<
 *             return True
 *         else:
 */
  __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":537
 *     def __nonzero__(self):
 *         if self.__obj:
 *             return True             # <<<<<<<<<<<<<<
 *         else:
 *             return False
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":539
 *             return True
 *         else:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     def bind(self, char* address='127.0.0.1', int port=80):
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":541
 *             return False
 * 
 *     def bind(self, char* address='127.0.0.1', int port=80):             # <<<<<<<<<<<<<<
 *         cdef int res = evhttp_bind_socket(self.__obj, address, port)
 *         if res:
 */

static PyObject *__pyx_pf_6gevent_4core_4http_bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_4http_bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_address;
  int __pyx_v_port;
  int __pyx_v_res;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__address,&__pyx_n_s__port,0};
  __Pyx_RefNannySetupContext("bind");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__address);
        if (unlikely(value)) { values[0] = value; kw_args--; }
      }
      case  1:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__port);
        if (unlikely(value)) { values[1] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "bind") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_address = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_address) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_address = ((char *)__pyx_k_39);
    }
    if (values[1]) {
      __pyx_v_port = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_port = ((int)80);
    }
  } else {
    __pyx_v_address = ((char *)__pyx_k_39);
    __pyx_v_port = ((int)80);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_port = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  1: __pyx_v_address = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_address) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("bind", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http.bind");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":542
 * 
 *     def bind(self, char* address='127.0.0.1', int port=80):
 *         cdef int res = evhttp_bind_socket(self.__obj, address, port)             # <<<<<<<<<<<<<<
 *         if res:
 *             raise RuntimeError('evhttp_bind_socket(%r, %r) returned %r' % (address, port, res))
 */
  __pyx_v_res = evhttp_bind_socket(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj, __pyx_v_address, __pyx_v_port);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":543
 *     def bind(self, char* address='127.0.0.1', int port=80):
 *         cdef int res = evhttp_bind_socket(self.__obj, address, port)
 *         if res:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('evhttp_bind_socket(%r, %r) returned %r' % (address, port, res))
 * 
 */
  __pyx_t_1 = __pyx_v_res;
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":544
 *         cdef int res = evhttp_bind_socket(self.__obj, address, port)
 *         if res:
 *             raise RuntimeError('evhttp_bind_socket(%r, %r) returned %r' % (address, port, res))             # <<<<<<<<<<<<<<
 * 
 *     def accept(self, int fd):
 */
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_address); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyInt_FromLong(__pyx_v_port); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyInt_FromLong(__pyx_v_res); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_40), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.http.bind");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":546
 *             raise RuntimeError('evhttp_bind_socket(%r, %r) returned %r' % (address, port, res))
 * 
 *     def accept(self, int fd):             # <<<<<<<<<<<<<<
 *         cdef res = evhttp_accept_socket(self.__obj, fd)
 *         if res:
 */

static PyObject *__pyx_pf_6gevent_4core_4http_accept(PyObject *__pyx_v_self, PyObject *__pyx_arg_fd); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_4http_accept(PyObject *__pyx_v_self, PyObject *__pyx_arg_fd) {
  int __pyx_v_fd;
  PyObject *__pyx_v_res = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("accept");
  assert(__pyx_arg_fd); {
    __pyx_v_fd = __Pyx_PyInt_AsInt(__pyx_arg_fd); if (unlikely((__pyx_v_fd == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http.accept");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":547
 * 
 *     def accept(self, int fd):
 *         cdef res = evhttp_accept_socket(self.__obj, fd)             # <<<<<<<<<<<<<<
 *         if res:
 *             raise RuntimeError("evhttp_accept_socket(%r) returned %r" % (fd, res))
 */
  __pyx_t_1 = PyInt_FromLong(evhttp_accept_socket(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj, __pyx_v_fd)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_res = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":548
 *     def accept(self, int fd):
 *         cdef res = evhttp_accept_socket(self.__obj, fd)
 *         if res:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("evhttp_accept_socket(%r) returned %r" % (fd, res))
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_res); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":549
 *         cdef res = evhttp_accept_socket(self.__obj, fd)
 *         if res:
 *             raise RuntimeError("evhttp_accept_socket(%r) returned %r" % (fd, res))             # <<<<<<<<<<<<<<
 * 
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_fd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_res);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_res);
    __Pyx_GIVEREF(__pyx_v_res);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_41), __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http.accept");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":509
 * include "evhttp.pxi"
 * 
 * def set_exc_info(object typ, object value, object tb):             # <<<<<<<<<<<<<<
 *     cdef PyThreadState* tstate = PyThreadState_GET()
 *     if tstate.exc_type != NULL:
 */

static PyObject *__pyx_pf_6gevent_4core_set_exc_info(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_set_exc_info(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_typ = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_tb = 0;
  PyThreadState *__pyx_v_tstate;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__typ,&__pyx_n_s__value,&__pyx_n_s__tb,0};
  __Pyx_RefNannySetupContext("set_exc_info");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__typ);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("set_exc_info", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tb);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("set_exc_info", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_exc_info") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_typ = values[0];
    __pyx_v_value = values[1];
    __pyx_v_tb = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_typ = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_tb = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_exc_info", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.set_exc_info");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_typ);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_INCREF(__pyx_v_tb);

  /* "/home/denis/work/gevent/gevent/core.pyx":510
 * 
 * def set_exc_info(object typ, object value, object tb):
 *     cdef PyThreadState* tstate = PyThreadState_GET()             # <<<<<<<<<<<<<<
 *     if tstate.exc_type != NULL:
 *         Py_DECREF(<object>tstate.exc_type)
 */
  __pyx_v_tstate = PyThreadState_GET();

  /* "/home/denis/work/gevent/gevent/core.pyx":511
 * def set_exc_info(object typ, object value, object tb):
 *     cdef PyThreadState* tstate = PyThreadState_GET()
 *     if tstate.exc_type != NULL:             # <<<<<<<<<<<<<<
 *         Py_DECREF(<object>tstate.exc_type)
 *     if tstate.exc_value != NULL:
 */
  __pyx_t_1 = (__pyx_v_tstate->exc_type != NULL);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":512
 *     cdef PyThreadState* tstate = PyThreadState_GET()
 *     if tstate.exc_type != NULL:
 *         Py_DECREF(<object>tstate.exc_type)             # <<<<<<<<<<<<<<
 *     if tstate.exc_value != NULL:
 *         Py_DECREF(<object>tstate.exc_value)
 */
    Py_DECREF(((PyObject *)__pyx_v_tstate->exc_type));
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/core.pyx":513
 *     if tstate.exc_type != NULL:
 *         Py_DECREF(<object>tstate.exc_type)
 *     if tstate.exc_value != NULL:             # <<<<<<<<<<<<<<
 *         Py_DECREF(<object>tstate.exc_value)
 *     if tstate.exc_traceback != NULL:
 */
  __pyx_t_1 = (__pyx_v_tstate->exc_value != NULL);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":514
 *         Py_DECREF(<object>tstate.exc_type)
 *     if tstate.exc_value != NULL:
 *         Py_DECREF(<object>tstate.exc_value)             # <<<<<<<<<<<<<<
 *     if tstate.exc_traceback != NULL:
 *         Py_DECREF(<object>tstate.exc_traceback)
 */
    Py_DECREF(((PyObject *)__pyx_v_tstate->exc_value));
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/denis/work/gevent/gevent/core.pyx":515
 *     if tstate.exc_value != NULL:
 *         Py_DECREF(<object>tstate.exc_value)
 *     if tstate.exc_traceback != NULL:             # <<<<<<<<<<<<<<
 *         Py_DECREF(<object>tstate.exc_traceback)
 *     Py_INCREF(typ)
 */
  __pyx_t_1 = (__pyx_v_tstate->exc_traceback != NULL);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":516
 *         Py_DECREF(<object>tstate.exc_value)
 *     if tstate.exc_traceback != NULL:
 *         Py_DECREF(<object>tstate.exc_traceback)             # <<<<<<<<<<<<<<
 *     Py_INCREF(typ)
 *     Py_INCREF(value)
 */
    Py_DECREF(((PyObject *)__pyx_v_tstate->exc_traceback));
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/denis/work/gevent/gevent/core.pyx":517
 *     if tstate.exc_traceback != NULL:
 *         Py_DECREF(<object>tstate.exc_traceback)
 *     Py_INCREF(typ)             # <<<<<<<<<<<<<<
 *     Py_INCREF(value)
 *     Py_INCREF(tb)
 */
  Py_INCREF(__pyx_v_typ);

  /* "/home/denis/work/gevent/gevent/core.pyx":518
 *         Py_DECREF(<object>tstate.exc_traceback)
 *     Py_INCREF(typ)
 *     Py_INCREF(value)             # <<<<<<<<<<<<<<
 *     Py_INCREF(tb)
 *     tstate.exc_type = <void*>typ
 */
  Py_INCREF(__pyx_v_value);

  /* "/home/denis/work/gevent/gevent/core.pyx":519
 *     Py_INCREF(typ)
 *     Py_INCREF(value)
 *     Py_INCREF(tb)             # <<<<<<<<<<<<<<
 *     tstate.exc_type = <void*>typ
 *     tstate.exc_value = <void *>value
 */
  Py_INCREF(__pyx_v_tb);

  /* "/home/denis/work/gevent/gevent/core.pyx":520
 *     Py_INCREF(value)
 *     Py_INCREF(tb)
 *     tstate.exc_type = <void*>typ             # <<<<<<<<<<<<<<
 *     tstate.exc_value = <void *>value
 *     tstate.exc_traceback = <void *>tb
 */
  __pyx_v_tstate->exc_type = ((void *)__pyx_v_typ);

  /* "/home/denis/work/gevent/gevent/core.pyx":521
 *     Py_INCREF(tb)
 *     tstate.exc_type = <void*>typ
 *     tstate.exc_value = <void *>value             # <<<<<<<<<<<<<<
 *     tstate.exc_traceback = <void *>tb
 * 
 */
  __pyx_v_tstate->exc_value = ((void *)__pyx_v_value);

  /* "/home/denis/work/gevent/gevent/core.pyx":522
 *     tstate.exc_type = <void*>typ
 *     tstate.exc_value = <void *>value
 *     tstate.exc_traceback = <void *>tb             # <<<<<<<<<<<<<<
 * 
 */
  __pyx_v_tstate->exc_traceback = ((void *)__pyx_v_tb);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_DECREF(__pyx_v_typ);
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_DECREF(__pyx_v_tb);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_6gevent_4core_event __pyx_vtable_6gevent_4core_event;

static PyObject *__pyx_tp_new_6gevent_4core_event(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6gevent_4core_event *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6gevent_4core_event *)o);
  p->__pyx_vtab = __pyx_vtabptr_6gevent_4core_event;
  p->_callback = Py_None; Py_INCREF(Py_None);
  p->_arg = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6gevent_4core_event(PyObject *o) {
  struct __pyx_obj_6gevent_4core_event *p = (struct __pyx_obj_6gevent_4core_event *)o;
  Py_XDECREF(p->_callback);
  Py_XDECREF(p->_arg);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6gevent_4core_event(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6gevent_4core_event *p = (struct __pyx_obj_6gevent_4core_event *)o;
  if (p->_callback) {
    e = (*v)(p->_callback, a); if (e) return e;
  }
  if (p->_arg) {
    e = (*v)(p->_arg, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6gevent_4core_event(PyObject *o) {
  struct __pyx_obj_6gevent_4core_event *p = (struct __pyx_obj_6gevent_4core_event *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_callback);
  p->_callback = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_arg);
  p->_arg = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6gevent_4core_5event_callback(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_5event_8callback___get__(o);
}

static int __pyx_setprop_6gevent_4core_5event_callback(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_6gevent_4core_5event_8callback___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_6gevent_4core_5event_arg(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_5event_3arg___get__(o);
}

static int __pyx_setprop_6gevent_4core_5event_arg(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_6gevent_4core_5event_3arg___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_6gevent_4core_5event_pending(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_5event_7pending___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_5event_fd(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_5event_2fd___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_5event_events(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_5event_6events___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_5event_events_str(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_5event_10events_str___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_5event_flags(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_5event_5flags___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_5event_flags_str(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_5event_9flags_str___get__(o);
}

static struct PyMethodDef __pyx_methods_6gevent_4core_event[] = {
  {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pf_6gevent_4core_5event_add, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_5event_add)},
  {__Pyx_NAMESTR("cancel"), (PyCFunction)__pyx_pf_6gevent_4core_5event_cancel, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_5event_cancel)},
  {__Pyx_NAMESTR("__repr__"), (PyCFunction)__pyx_pf_6gevent_4core_5event___repr__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__str__"), (PyCFunction)__pyx_pf_6gevent_4core_5event___str__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pf_6gevent_4core_5event___enter__, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pf_6gevent_4core_5event___exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6gevent_4core_event[] = {
  {(char *)"callback", __pyx_getprop_6gevent_4core_5event_callback, __pyx_setprop_6gevent_4core_5event_callback, __Pyx_DOCSTR(__pyx_k_42), 0},
  {(char *)"arg", __pyx_getprop_6gevent_4core_5event_arg, __pyx_setprop_6gevent_4core_5event_arg, __Pyx_DOCSTR(__pyx_k_43), 0},
  {(char *)"pending", __pyx_getprop_6gevent_4core_5event_pending, 0, __Pyx_DOCSTR(__pyx_k_44), 0},
  {(char *)"fd", __pyx_getprop_6gevent_4core_5event_fd, 0, 0, 0},
  {(char *)"events", __pyx_getprop_6gevent_4core_5event_events, 0, 0, 0},
  {(char *)"events_str", __pyx_getprop_6gevent_4core_5event_events_str, 0, 0, 0},
  {(char *)"flags", __pyx_getprop_6gevent_4core_5event_flags, 0, 0, 0},
  {(char *)"flags_str", __pyx_getprop_6gevent_4core_5event_flags_str, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_event = {
  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, /*reserved*/
  #else
  0, /*nb_long*/
  #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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_event = {
  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_event = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_event = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6gevent_4core_event = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("gevent.core.event"), /*tp_name*/
  sizeof(struct __pyx_obj_6gevent_4core_event), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6gevent_4core_event, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_6gevent_4core_5event___repr__, /*tp_repr*/
  &__pyx_tp_as_number_event, /*tp_as_number*/
  &__pyx_tp_as_sequence_event, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_event, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pf_6gevent_4core_5event___str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_event, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Create a new event object with a user callback.\n\n    - *evtype*   -- bitmask of EV_READ or EV_WRITE, or EV_SIGNAL\n    - *handle*   -- a file handle, descriptor, or socket for EV_READ or EV_WRITE; a signal number for EV_SIGNAL\n    - *callback* -- user callback with ``(event, evtype)`` prototype\n    - *arg*      -- optional object, which will be made available as :attr:`arg` property.\n    "), /*tp_doc*/
  __pyx_tp_traverse_6gevent_4core_event, /*tp_traverse*/
  __pyx_tp_clear_6gevent_4core_event, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6gevent_4core_event, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6gevent_4core_event, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6gevent_4core_5event___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6gevent_4core_event, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_6gevent_4core_read_event __pyx_vtable_6gevent_4core_read_event;

static PyObject *__pyx_tp_new_6gevent_4core_read_event(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6gevent_4core_read_event *p;
  PyObject *o = __pyx_tp_new_6gevent_4core_event(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6gevent_4core_read_event *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_4core_event*)__pyx_vtabptr_6gevent_4core_read_event;
  return o;
}

static struct PyMethodDef __pyx_methods_6gevent_4core_read_event[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_read_event = {
  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, /*reserved*/
  #else
  0, /*nb_long*/
  #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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_read_event = {
  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_read_event = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_read_event = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6gevent_4core_read_event = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("gevent.core.read_event"), /*tp_name*/
  sizeof(struct __pyx_obj_6gevent_4core_read_event), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6gevent_4core_event, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_read_event, /*tp_as_number*/
  &__pyx_tp_as_sequence_read_event, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_read_event, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_read_event, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Create a new scheduled event with evtype=EV_READ"), /*tp_doc*/
  __pyx_tp_traverse_6gevent_4core_event, /*tp_traverse*/
  __pyx_tp_clear_6gevent_4core_event, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6gevent_4core_read_event, /*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_6gevent_4core_10read_event___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6gevent_4core_read_event, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_6gevent_4core_write_event __pyx_vtable_6gevent_4core_write_event;

static PyObject *__pyx_tp_new_6gevent_4core_write_event(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6gevent_4core_write_event *p;
  PyObject *o = __pyx_tp_new_6gevent_4core_event(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6gevent_4core_write_event *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_4core_event*)__pyx_vtabptr_6gevent_4core_write_event;
  return o;
}

static struct PyMethodDef __pyx_methods_6gevent_4core_write_event[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_write_event = {
  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, /*reserved*/
  #else
  0, /*nb_long*/
  #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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_write_event = {
  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_write_event = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_write_event = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6gevent_4core_write_event = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("gevent.core.write_event"), /*tp_name*/
  sizeof(struct __pyx_obj_6gevent_4core_write_event), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6gevent_4core_event, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_write_event, /*tp_as_number*/
  &__pyx_tp_as_sequence_write_event, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_write_event, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_write_event, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Create a new scheduled event with evtype=EV_WRITE"), /*tp_doc*/
  __pyx_tp_traverse_6gevent_4core_event, /*tp_traverse*/
  __pyx_tp_clear_6gevent_4core_event, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6gevent_4core_write_event, /*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_6gevent_4core_11write_event___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6gevent_4core_write_event, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_6gevent_4core_timer __pyx_vtable_6gevent_4core_timer;

static PyObject *__pyx_tp_new_6gevent_4core_timer(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6gevent_4core_timer *p;
  PyObject *o = __pyx_tp_new_6gevent_4core_event(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6gevent_4core_timer *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_4core_event*)__pyx_vtabptr_6gevent_4core_timer;
  return o;
}

static struct PyMethodDef __pyx_methods_6gevent_4core_timer[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_timer = {
  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, /*reserved*/
  #else
  0, /*nb_long*/
  #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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_timer = {
  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_timer = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_timer = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6gevent_4core_timer = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("gevent.core.timer"), /*tp_name*/
  sizeof(struct __pyx_obj_6gevent_4core_timer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6gevent_4core_event, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_timer, /*tp_as_number*/
  &__pyx_tp_as_sequence_timer, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_timer, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_timer, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Create a new scheduled timer"), /*tp_doc*/
  __pyx_tp_traverse_6gevent_4core_event, /*tp_traverse*/
  __pyx_tp_clear_6gevent_4core_event, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6gevent_4core_timer, /*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_6gevent_4core_5timer___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6gevent_4core_timer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_6gevent_4core_signal __pyx_vtable_6gevent_4core_signal;

static PyObject *__pyx_tp_new_6gevent_4core_signal(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6gevent_4core_signal *p;
  PyObject *o = __pyx_tp_new_6gevent_4core_event(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6gevent_4core_signal *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_4core_event*)__pyx_vtabptr_6gevent_4core_signal;
  return o;
}

static struct PyMethodDef __pyx_methods_6gevent_4core_signal[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_signal = {
  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, /*reserved*/
  #else
  0, /*nb_long*/
  #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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_signal = {
  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_signal = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_signal = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6gevent_4core_signal = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("gevent.core.signal"), /*tp_name*/
  sizeof(struct __pyx_obj_6gevent_4core_signal), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6gevent_4core_event, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_signal, /*tp_as_number*/
  &__pyx_tp_as_sequence_signal, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_signal, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_signal, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Create a new persistent signal event"), /*tp_doc*/
  __pyx_tp_traverse_6gevent_4core_event, /*tp_traverse*/
  __pyx_tp_clear_6gevent_4core_event, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6gevent_4core_signal, /*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_6gevent_4core_6signal___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6gevent_4core_signal, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_6gevent_4core_active_event __pyx_vtable_6gevent_4core_active_event;

static PyObject *__pyx_tp_new_6gevent_4core_active_event(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6gevent_4core_active_event *p;
  PyObject *o = __pyx_tp_new_6gevent_4core_event(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6gevent_4core_active_event *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_4core_event*)__pyx_vtabptr_6gevent_4core_active_event;
  return o;
}

static struct PyMethodDef __pyx_methods_6gevent_4core_active_event[] = {
  {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pf_6gevent_4core_12active_event_add, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_active_event = {
  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, /*reserved*/
  #else
  0, /*nb_long*/
  #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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_active_event = {
  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_active_event = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_active_event = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6gevent_4core_active_event = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("gevent.core.active_event"), /*tp_name*/
  sizeof(struct __pyx_obj_6gevent_4core_active_event), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6gevent_4core_event, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_active_event, /*tp_as_number*/
  &__pyx_tp_as_sequence_active_event, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_active_event, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_active_event, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("An event that is scheduled to run in the current loop iteration"), /*tp_doc*/
  __pyx_tp_traverse_6gevent_4core_event, /*tp_traverse*/
  __pyx_tp_clear_6gevent_4core_event, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6gevent_4core_active_event, /*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_6gevent_4core_12active_event___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6gevent_4core_active_event, /*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 PyObject *__pyx_tp_new_6gevent_4core_buffer(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_6gevent_4core_buffer(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static PyObject *__pyx_getprop_6gevent_4core_6buffer__obj(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_6buffer_4_obj___get__(o);
}

static struct PyMethodDef __pyx_methods_6gevent_4core_buffer[] = {
  {__Pyx_NAMESTR("detach"), (PyCFunction)__pyx_pf_6gevent_4core_6buffer_detach, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__iter__"), (PyCFunction)__pyx_pf_6gevent_4core_6buffer___iter__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_6gevent_4core_6buffer___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pf_6gevent_4core_6buffer_read, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_6buffer_read)},
  {__Pyx_NAMESTR("readline"), (PyCFunction)__pyx_pf_6gevent_4core_6buffer_readline, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("readlines"), (PyCFunction)__pyx_pf_6gevent_4core_6buffer_readlines, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6gevent_4core_buffer[] = {
  {(char *)"_obj", __pyx_getprop_6gevent_4core_6buffer__obj, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_buffer = {
  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*/
  __pyx_pf_6gevent_4core_6buffer___nonzero__, /*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, /*reserved*/
  #else
  0, /*nb_long*/
  #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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_buffer = {
  __pyx_pf_6gevent_4core_6buffer___len__, /*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_buffer = {
  __pyx_pf_6gevent_4core_6buffer___len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_buffer = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6gevent_4core_buffer = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("gevent.core.buffer"), /*tp_name*/
  sizeof(struct __pyx_obj_6gevent_4core_buffer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6gevent_4core_buffer, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_buffer, /*tp_as_number*/
  &__pyx_tp_as_sequence_buffer, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_buffer, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_buffer, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  __Pyx_DOCSTR("file-like wrapper for libevent's :class:`evbuffer` structure.\n\n    Note, that the wrapper does not own the structure, libevent does.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_6gevent_4core_6buffer___iter__, /*tp_iter*/
  __pyx_pf_6gevent_4core_6buffer___next__, /*tp_iternext*/
  __pyx_methods_6gevent_4core_buffer, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6gevent_4core_buffer, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6gevent_4core_6buffer___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6gevent_4core_buffer, /*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 PyObject *__pyx_tp_new_6gevent_4core_http_request(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6gevent_4core_http_request *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6gevent_4core_http_request *)o);
  p->__weakref__ = 0;
  p->_input_buffer = Py_None; Py_INCREF(Py_None);
  p->_output_buffer = Py_None; Py_INCREF(Py_None);
  p->default_response_headers = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6gevent_4core_http_request(PyObject *o) {
  struct __pyx_obj_6gevent_4core_http_request *p = (struct __pyx_obj_6gevent_4core_http_request *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_6gevent_4core_12http_request___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  if (p->__weakref__) PyObject_ClearWeakRefs(o);
  Py_XDECREF(p->_input_buffer);
  Py_XDECREF(p->_output_buffer);
  Py_XDECREF(p->default_response_headers);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6gevent_4core_http_request(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6gevent_4core_http_request *p = (struct __pyx_obj_6gevent_4core_http_request *)o;
  if (p->_input_buffer) {
    e = (*v)(p->_input_buffer, a); if (e) return e;
  }
  if (p->_output_buffer) {
    e = (*v)(p->_output_buffer, a); if (e) return e;
  }
  if (p->default_response_headers) {
    e = (*v)(p->default_response_headers, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6gevent_4core_http_request(PyObject *o) {
  struct __pyx_obj_6gevent_4core_http_request *p = (struct __pyx_obj_6gevent_4core_http_request *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_input_buffer);
  p->_input_buffer = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_output_buffer);
  p->_output_buffer = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->default_response_headers);
  p->default_response_headers = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request__obj(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_4_obj___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_connection(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_10connection___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_remote_host(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_11remote_host___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_remote_port(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_11remote_port___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_remote(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_6remote___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_kind(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_4kind___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_type(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_4type___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_typestr(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_7typestr___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_uri(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_3uri___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_major(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_5major___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_minor(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_5minor___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_version(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_7version___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_response_code(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_13response_code___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_response_code_line(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_18response_code_line___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_response(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_8response___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_chunked(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_7chunked___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_input_buffer(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_12input_buffer___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_12http_request_output_buffer(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_12http_request_13output_buffer___get__(o);
}

static struct PyMethodDef __pyx_methods_6gevent_4core_http_request[] = {
  {__Pyx_NAMESTR("detach"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_detach, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("_format"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request__format, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__str__"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request___str__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__repr__"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request___repr__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_input_headers"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_get_input_headers, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("_add_default_response_headers"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request__add_default_response_headers, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("send_reply"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_send_reply, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("send_reply_start"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_send_reply_start, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("send_reply_chunk"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_send_reply_chunk, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("send_reply_end"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_send_reply_end, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("send_error"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_send_error, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("find_input_header"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_find_input_header, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("find_output_header"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_find_output_header, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("add_input_header"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_add_input_header, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("add_output_header"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_add_output_header, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("remove_input_header"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_remove_input_header, METH_O, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_12http_request_remove_input_header)},
  {__Pyx_NAMESTR("remove_output_header"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_remove_output_header, METH_O, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_12http_request_remove_output_header)},
  {__Pyx_NAMESTR("clear_input_headers"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_clear_input_headers, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("clear_output_headers"), (PyCFunction)__pyx_pf_6gevent_4core_12http_request_clear_output_headers, METH_NOARGS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_6gevent_4core_http_request[] = {
  {(char *)"default_response_headers", T_OBJECT, offsetof(struct __pyx_obj_6gevent_4core_http_request, default_response_headers), 0, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6gevent_4core_http_request[] = {
  {(char *)"_obj", __pyx_getprop_6gevent_4core_12http_request__obj, 0, 0, 0},
  {(char *)"connection", __pyx_getprop_6gevent_4core_12http_request_connection, 0, 0, 0},
  {(char *)"remote_host", __pyx_getprop_6gevent_4core_12http_request_remote_host, 0, 0, 0},
  {(char *)"remote_port", __pyx_getprop_6gevent_4core_12http_request_remote_port, 0, 0, 0},
  {(char *)"remote", __pyx_getprop_6gevent_4core_12http_request_remote, 0, 0, 0},
  {(char *)"kind", __pyx_getprop_6gevent_4core_12http_request_kind, 0, 0, 0},
  {(char *)"type", __pyx_getprop_6gevent_4core_12http_request_type, 0, 0, 0},
  {(char *)"typestr", __pyx_getprop_6gevent_4core_12http_request_typestr, 0, 0, 0},
  {(char *)"uri", __pyx_getprop_6gevent_4core_12http_request_uri, 0, 0, 0},
  {(char *)"major", __pyx_getprop_6gevent_4core_12http_request_major, 0, 0, 0},
  {(char *)"minor", __pyx_getprop_6gevent_4core_12http_request_minor, 0, 0, 0},
  {(char *)"version", __pyx_getprop_6gevent_4core_12http_request_version, 0, 0, 0},
  {(char *)"response_code", __pyx_getprop_6gevent_4core_12http_request_response_code, 0, 0, 0},
  {(char *)"response_code_line", __pyx_getprop_6gevent_4core_12http_request_response_code_line, 0, 0, 0},
  {(char *)"response", __pyx_getprop_6gevent_4core_12http_request_response, 0, 0, 0},
  {(char *)"chunked", __pyx_getprop_6gevent_4core_12http_request_chunked, 0, 0, 0},
  {(char *)"input_buffer", __pyx_getprop_6gevent_4core_12http_request_input_buffer, 0, 0, 0},
  {(char *)"output_buffer", __pyx_getprop_6gevent_4core_12http_request_output_buffer, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_http_request = {
  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*/
  __pyx_pf_6gevent_4core_12http_request___nonzero__, /*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, /*reserved*/
  #else
  0, /*nb_long*/
  #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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_http_request = {
  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_http_request = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_http_request = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6gevent_4core_http_request = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("gevent.core.http_request"), /*tp_name*/
  sizeof(struct __pyx_obj_6gevent_4core_http_request), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6gevent_4core_http_request, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_6gevent_4core_12http_request___repr__, /*tp_repr*/
  &__pyx_tp_as_number_http_request, /*tp_as_number*/
  &__pyx_tp_as_sequence_http_request, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_http_request, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pf_6gevent_4core_12http_request___str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_http_request, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Wrapper around libevent's :class:`evhttp_request` structure."), /*tp_doc*/
  __pyx_tp_traverse_6gevent_4core_http_request, /*tp_traverse*/
  __pyx_tp_clear_6gevent_4core_http_request, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6gevent_4core_http_request, /*tp_methods*/
  __pyx_members_6gevent_4core_http_request, /*tp_members*/
  __pyx_getsets_6gevent_4core_http_request, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6gevent_4core_12http_request___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6gevent_4core_http_request, /*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 PyObject *__pyx_tp_new_6gevent_4core_http_connection(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_6gevent_4core_http_connection(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static PyObject *__pyx_getprop_6gevent_4core_15http_connection__obj(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_15http_connection_4_obj___get__(o);
}

static PyObject *__pyx_getprop_6gevent_4core_15http_connection_peer(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_15http_connection_4peer___get__(o);
}

static struct PyMethodDef __pyx_methods_6gevent_4core_http_connection[] = {
  {__Pyx_NAMESTR("__str__"), (PyCFunction)__pyx_pf_6gevent_4core_15http_connection___str__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__repr__"), (PyCFunction)__pyx_pf_6gevent_4core_15http_connection___repr__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6gevent_4core_http_connection[] = {
  {(char *)"_obj", __pyx_getprop_6gevent_4core_15http_connection__obj, 0, 0, 0},
  {(char *)"peer", __pyx_getprop_6gevent_4core_15http_connection_peer, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_http_connection = {
  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*/
  __pyx_pf_6gevent_4core_15http_connection___nonzero__, /*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, /*reserved*/
  #else
  0, /*nb_long*/
  #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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_http_connection = {
  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_http_connection = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_http_connection = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6gevent_4core_http_connection = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("gevent.core.http_connection"), /*tp_name*/
  sizeof(struct __pyx_obj_6gevent_4core_http_connection), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6gevent_4core_http_connection, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_6gevent_4core_15http_connection___repr__, /*tp_repr*/
  &__pyx_tp_as_number_http_connection, /*tp_as_number*/
  &__pyx_tp_as_sequence_http_connection, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_http_connection, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pf_6gevent_4core_15http_connection___str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_http_connection, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6gevent_4core_http_connection, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6gevent_4core_http_connection, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6gevent_4core_15http_connection___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6gevent_4core_http_connection, /*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 PyObject *__pyx_tp_new_6gevent_4core_http(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6gevent_4core_http *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6gevent_4core_http *)o);
  p->handle = Py_None; Py_INCREF(Py_None);
  p->default_response_headers = Py_None; Py_INCREF(Py_None);
  p->_requests = ((PyObject *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6gevent_4core_http(PyObject *o) {
  struct __pyx_obj_6gevent_4core_http *p = (struct __pyx_obj_6gevent_4core_http *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_6gevent_4core_4http___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->handle);
  Py_XDECREF(p->default_response_headers);
  Py_XDECREF(((PyObject *)p->_requests));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6gevent_4core_http(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6gevent_4core_http *p = (struct __pyx_obj_6gevent_4core_http *)o;
  if (p->handle) {
    e = (*v)(p->handle, a); if (e) return e;
  }
  if (p->default_response_headers) {
    e = (*v)(p->default_response_headers, a); if (e) return e;
  }
  if (p->_requests) {
    e = (*v)(p->_requests, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6gevent_4core_http(PyObject *o) {
  struct __pyx_obj_6gevent_4core_http *p = (struct __pyx_obj_6gevent_4core_http *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->handle);
  p->handle = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->default_response_headers);
  p->default_response_headers = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_requests);
  p->_requests = ((PyObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6gevent_4core_4http__obj(PyObject *o, void *x) {
  return __pyx_pf_6gevent_4core_4http_4_obj___get__(o);
}

static struct PyMethodDef __pyx_methods_6gevent_4core_http[] = {
  {__Pyx_NAMESTR("bind"), (PyCFunction)__pyx_pf_6gevent_4core_4http_bind, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("accept"), (PyCFunction)__pyx_pf_6gevent_4core_4http_accept, METH_O, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_6gevent_4core_http[] = {
  {(char *)"handle", T_OBJECT, offsetof(struct __pyx_obj_6gevent_4core_http, handle), 0, 0},
  {(char *)"default_response_headers", T_OBJECT, offsetof(struct __pyx_obj_6gevent_4core_http, default_response_headers), 0, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6gevent_4core_http[] = {
  {(char *)"_obj", __pyx_getprop_6gevent_4core_4http__obj, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_http = {
  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*/
  __pyx_pf_6gevent_4core_4http___nonzero__, /*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, /*reserved*/
  #else
  0, /*nb_long*/
  #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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_http = {
  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_http = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_http = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_6gevent_4core_http = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("gevent.core.http"), /*tp_name*/
  sizeof(struct __pyx_obj_6gevent_4core_http), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6gevent_4core_http, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_http, /*tp_as_number*/
  &__pyx_tp_as_sequence_http, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_http, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_http, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6gevent_4core_http, /*tp_traverse*/
  __pyx_tp_clear_6gevent_4core_http, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6gevent_4core_http, /*tp_methods*/
  __pyx_members_6gevent_4core_http, /*tp_members*/
  __pyx_getsets_6gevent_4core_http, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6gevent_4core_4http___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6gevent_4core_http, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static struct PyMethodDef __pyx_methods[] = {
  {__Pyx_NAMESTR("init"), (PyCFunction)__pyx_pf_6gevent_4core_init, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_init)},
  {__Pyx_NAMESTR("dispatch"), (PyCFunction)__pyx_pf_6gevent_4core_dispatch, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_dispatch)},
  {__Pyx_NAMESTR("loop"), (PyCFunction)__pyx_pf_6gevent_4core_loop, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_loop)},
  {__Pyx_NAMESTR("get_version"), (PyCFunction)__pyx_pf_6gevent_4core_get_version, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_get_version)},
  {__Pyx_NAMESTR("get_method"), (PyCFunction)__pyx_pf_6gevent_4core_get_method, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_get_method)},
  {__Pyx_NAMESTR("get_header_version"), (PyCFunction)__pyx_pf_6gevent_4core_get_header_version, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_get_header_version)},
  {__Pyx_NAMESTR("reinit"), (PyCFunction)__pyx_pf_6gevent_4core_reinit, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_reinit)},
  {__Pyx_NAMESTR("dns_init"), (PyCFunction)__pyx_pf_6gevent_4core_dns_init, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_dns_init)},
  {__Pyx_NAMESTR("dns_shutdown"), (PyCFunction)__pyx_pf_6gevent_4core_dns_shutdown, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_dns_shutdown)},
  {__Pyx_NAMESTR("dns_err_to_string"), (PyCFunction)__pyx_pf_6gevent_4core_dns_err_to_string, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("dns_resolve_ipv4"), (PyCFunction)__pyx_pf_6gevent_4core_dns_resolve_ipv4, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_dns_resolve_ipv4)},
  {__Pyx_NAMESTR("dns_resolve_ipv6"), (PyCFunction)__pyx_pf_6gevent_4core_dns_resolve_ipv6, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_dns_resolve_ipv6)},
  {__Pyx_NAMESTR("dns_resolve_reverse"), (PyCFunction)__pyx_pf_6gevent_4core_dns_resolve_reverse, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_dns_resolve_reverse)},
  {__Pyx_NAMESTR("dns_resolve_reverse_ipv6"), (PyCFunction)__pyx_pf_6gevent_4core_dns_resolve_reverse_ipv6, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_dns_resolve_reverse_ipv6)},
  {__Pyx_NAMESTR("set_exc_info"), (PyCFunction)__pyx_pf_6gevent_4core_set_exc_info, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

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

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

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
  {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
  {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
  {&__pyx_n_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 1},
  {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
  {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
  {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
  {&__pyx_kp_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
  {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
  {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
  {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
  {&__pyx_n_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 1},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
  {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
  {&__pyx_n_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 1},
  {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
  {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0},
  {&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0},
  {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0},
  {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0},
  {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0},
  {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0},
  {&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0},
  {&__pyx_kp_s_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 0},
  {&__pyx_n_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 1},
  {&__pyx_n_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 1},
  {&__pyx_kp_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 0},
  {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
  {&__pyx_kp_s_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 1, 0},
  {&__pyx_kp_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 0},
  {&__pyx_kp_u_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 1, 0, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_u_60, __pyx_k_60, sizeof(__pyx_k_60), 0, 1, 0, 0},
  {&__pyx_kp_u_61, __pyx_k_61, sizeof(__pyx_k_61), 0, 1, 0, 0},
  {&__pyx_kp_u_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 1, 0, 0},
  {&__pyx_kp_u_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 1, 0, 0},
  {&__pyx_kp_u_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 1, 0, 0},
  {&__pyx_kp_u_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 1, 0, 0},
  {&__pyx_kp_u_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 1, 0, 0},
  {&__pyx_kp_u_67, __pyx_k_67, sizeof(__pyx_k_67), 0, 1, 0, 0},
  {&__pyx_kp_u_68, __pyx_k_68, sizeof(__pyx_k_68), 0, 1, 0, 0},
  {&__pyx_kp_u_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 1, 0, 0},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_kp_u_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 1, 0, 0},
  {&__pyx_kp_u_71, __pyx_k_71, sizeof(__pyx_k_71), 0, 1, 0, 0},
  {&__pyx_kp_u_72, __pyx_k_72, sizeof(__pyx_k_72), 0, 1, 0, 0},
  {&__pyx_kp_u_73, __pyx_k_73, sizeof(__pyx_k_73), 0, 1, 0, 0},
  {&__pyx_kp_u_74, __pyx_k_74, sizeof(__pyx_k_74), 0, 1, 0, 0},
  {&__pyx_kp_u_75, __pyx_k_75, sizeof(__pyx_k_75), 0, 1, 0, 0},
  {&__pyx_kp_u_76, __pyx_k_76, sizeof(__pyx_k_76), 0, 1, 0, 0},
  {&__pyx_n_s_77, __pyx_k_77, sizeof(__pyx_k_77), 0, 0, 1, 1},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  {&__pyx_n_s__ACTIVE, __pyx_k__ACTIVE, sizeof(__pyx_k__ACTIVE), 0, 0, 1, 1},
  {&__pyx_n_s__AttributeError, __pyx_k__AttributeError, sizeof(__pyx_k__AttributeError), 0, 0, 1, 1},
  {&__pyx_n_s__BSD, __pyx_k__BSD, sizeof(__pyx_k__BSD), 0, 0, 1, 1},
  {&__pyx_n_s__DELETE, __pyx_k__DELETE, sizeof(__pyx_k__DELETE), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_ERR_FORMAT, __pyx_k__DNS_ERR_FORMAT, sizeof(__pyx_k__DNS_ERR_FORMAT), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_ERR_NONE, __pyx_k__DNS_ERR_NONE, sizeof(__pyx_k__DNS_ERR_NONE), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_ERR_NOTEXIST, __pyx_k__DNS_ERR_NOTEXIST, sizeof(__pyx_k__DNS_ERR_NOTEXIST), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_ERR_NOTIMPL, __pyx_k__DNS_ERR_NOTIMPL, sizeof(__pyx_k__DNS_ERR_NOTIMPL), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_ERR_REFUSED, __pyx_k__DNS_ERR_REFUSED, sizeof(__pyx_k__DNS_ERR_REFUSED), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_ERR_SHUTDOWN, __pyx_k__DNS_ERR_SHUTDOWN, sizeof(__pyx_k__DNS_ERR_SHUTDOWN), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_ERR_TIMEOUT, __pyx_k__DNS_ERR_TIMEOUT, sizeof(__pyx_k__DNS_ERR_TIMEOUT), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_ERR_TRUNCATED, __pyx_k__DNS_ERR_TRUNCATED, sizeof(__pyx_k__DNS_ERR_TRUNCATED), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_ERR_UNKNOWN, __pyx_k__DNS_ERR_UNKNOWN, sizeof(__pyx_k__DNS_ERR_UNKNOWN), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_IPv4_A, __pyx_k__DNS_IPv4_A, sizeof(__pyx_k__DNS_IPv4_A), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_IPv6_AAAA, __pyx_k__DNS_IPv6_AAAA, sizeof(__pyx_k__DNS_IPv6_AAAA), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_PTR, __pyx_k__DNS_PTR, sizeof(__pyx_k__DNS_PTR), 0, 0, 1, 1},
  {&__pyx_n_s__DNS_QUERY_NO_SEARCH, __pyx_k__DNS_QUERY_NO_SEARCH, sizeof(__pyx_k__DNS_QUERY_NO_SEARCH), 0, 0, 1, 1},
  {&__pyx_n_s__DeprecationWarning, __pyx_k__DeprecationWarning, sizeof(__pyx_k__DeprecationWarning), 0, 0, 1, 1},
  {&__pyx_n_s__EVHTTP_REQUEST, __pyx_k__EVHTTP_REQUEST, sizeof(__pyx_k__EVHTTP_REQUEST), 0, 0, 1, 1},
  {&__pyx_n_s__EVHTTP_REQ_DELETE, __pyx_k__EVHTTP_REQ_DELETE, sizeof(__pyx_k__EVHTTP_REQ_DELETE), 0, 0, 1, 1},
  {&__pyx_n_s__EVHTTP_REQ_GET, __pyx_k__EVHTTP_REQ_GET, sizeof(__pyx_k__EVHTTP_REQ_GET), 0, 0, 1, 1},
  {&__pyx_n_s__EVHTTP_REQ_HEAD, __pyx_k__EVHTTP_REQ_HEAD, sizeof(__pyx_k__EVHTTP_REQ_HEAD), 0, 0, 1, 1},
  {&__pyx_n_s__EVHTTP_REQ_POST, __pyx_k__EVHTTP_REQ_POST, sizeof(__pyx_k__EVHTTP_REQ_POST), 0, 0, 1, 1},
  {&__pyx_n_s__EVHTTP_REQ_PUT, __pyx_k__EVHTTP_REQ_PUT, sizeof(__pyx_k__EVHTTP_REQ_PUT), 0, 0, 1, 1},
  {&__pyx_n_s__EVHTTP_RESPONSE, __pyx_k__EVHTTP_RESPONSE, sizeof(__pyx_k__EVHTTP_RESPONSE), 0, 0, 1, 1},
  {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1},
  {&__pyx_n_s__GET, __pyx_k__GET, sizeof(__pyx_k__GET), 0, 0, 1, 1},
  {&__pyx_n_s__HEAD, __pyx_k__HEAD, sizeof(__pyx_k__HEAD), 0, 0, 1, 1},
  {&__pyx_n_s__HTTP_method2name, __pyx_k__HTTP_method2name, sizeof(__pyx_k__HTTP_method2name), 0, 0, 1, 1},
  {&__pyx_n_s__HttpRequestDeleted, __pyx_k__HttpRequestDeleted, sizeof(__pyx_k__HttpRequestDeleted), 0, 0, 1, 1},
  {&__pyx_n_s__INIT, __pyx_k__INIT, sizeof(__pyx_k__INIT), 0, 0, 1, 1},
  {&__pyx_n_s__INSERTED, __pyx_k__INSERTED, sizeof(__pyx_k__INSERTED), 0, 0, 1, 1},
  {&__pyx_n_s__INTERNAL, __pyx_k__INTERNAL, sizeof(__pyx_k__INTERNAL), 0, 0, 1, 1},
  {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
  {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
  {&__pyx_n_s__ObjectDeleted, __pyx_k__ObjectDeleted, sizeof(__pyx_k__ObjectDeleted), 0, 0, 1, 1},
  {&__pyx_n_s__PERSIST, __pyx_k__PERSIST, sizeof(__pyx_k__PERSIST), 0, 0, 1, 1},
  {&__pyx_n_s__POST, __pyx_k__POST, sizeof(__pyx_k__POST), 0, 0, 1, 1},
  {&__pyx_n_s__PUT, __pyx_k__PUT, sizeof(__pyx_k__PUT), 0, 0, 1, 1},
  {&__pyx_n_s__READ, __pyx_k__READ, sizeof(__pyx_k__READ), 0, 0, 1, 1},
  {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s__SIGNAL, __pyx_k__SIGNAL, sizeof(__pyx_k__SIGNAL), 0, 0, 1, 1},
  {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
  {&__pyx_n_s__TIMEOUT, __pyx_k__TIMEOUT, sizeof(__pyx_k__TIMEOUT), 0, 0, 1, 1},
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__UserWarning, __pyx_k__UserWarning, sizeof(__pyx_k__UserWarning), 0, 0, 1, 1},
  {&__pyx_n_s__WRITE, __pyx_k__WRITE, sizeof(__pyx_k__WRITE), 0, 0, 1, 1},
  {&__pyx_n_s__WeakKeyDictionary, __pyx_k__WeakKeyDictionary, sizeof(__pyx_k__WeakKeyDictionary), 0, 0, 1, 1},
  {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
  {&__pyx_n_s____author__, __pyx_k____author__, sizeof(__pyx_k____author__), 0, 0, 1, 1},
  {&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1},
  {&__pyx_n_s____copyright__, __pyx_k____copyright__, sizeof(__pyx_k____copyright__), 0, 0, 1, 1},
  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
  {&__pyx_n_s____license__, __pyx_k____license__, sizeof(__pyx_k____license__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____name__, __pyx_k____name__, sizeof(__pyx_k____name__), 0, 0, 1, 1},
  {&__pyx_n_s____obj, __pyx_k____obj, sizeof(__pyx_k____obj), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s____url__, __pyx_k____url__, sizeof(__pyx_k____url__), 0, 0, 1, 1},
  {&__pyx_n_s____version__, __pyx_k____version__, sizeof(__pyx_k____version__), 0, 0, 1, 1},
  {&__pyx_n_s___addref, __pyx_k___addref, sizeof(__pyx_k___addref), 0, 0, 1, 1},
  {&__pyx_n_s___arg, __pyx_k___arg, sizeof(__pyx_k___arg), 0, 0, 1, 1},
  {&__pyx_n_s___callback, __pyx_k___callback, sizeof(__pyx_k___callback), 0, 0, 1, 1},
  {&__pyx_n_s___delref, __pyx_k___delref, sizeof(__pyx_k___delref), 0, 0, 1, 1},
  {&__pyx_n_s___format, __pyx_k___format, sizeof(__pyx_k___format), 0, 0, 1, 1},
  {&__pyx_n_s___incref, __pyx_k___incref, sizeof(__pyx_k___incref), 0, 0, 1, 1},
  {&__pyx_n_s___input_buffer, __pyx_k___input_buffer, sizeof(__pyx_k___input_buffer), 0, 0, 1, 1},
  {&__pyx_n_s___obj, __pyx_k___obj, sizeof(__pyx_k___obj), 0, 0, 1, 1},
  {&__pyx_n_s___output_buffer, __pyx_k___output_buffer, sizeof(__pyx_k___output_buffer), 0, 0, 1, 1},
  {&__pyx_n_s___requests, __pyx_k___requests, sizeof(__pyx_k___requests), 0, 0, 1, 1},
  {&__pyx_n_s__active_event, __pyx_k__active_event, sizeof(__pyx_k__active_event), 0, 0, 1, 1},
  {&__pyx_n_s__add, __pyx_k__add, sizeof(__pyx_k__add), 0, 0, 1, 1},
  {&__pyx_n_s__add_output_header, __pyx_k__add_output_header, sizeof(__pyx_k__add_output_header), 0, 0, 1, 1},
  {&__pyx_n_s__address, __pyx_k__address, sizeof(__pyx_k__address), 0, 0, 1, 1},
  {&__pyx_n_s__arg, __pyx_k__arg, sizeof(__pyx_k__arg), 0, 0, 1, 1},
  {&__pyx_n_s__buf, __pyx_k__buf, sizeof(__pyx_k__buf), 0, 0, 1, 1},
  {&__pyx_n_s__buffer, __pyx_k__buffer, sizeof(__pyx_k__buffer), 0, 0, 1, 1},
  {&__pyx_n_s__callback, __pyx_k__callback, sizeof(__pyx_k__callback), 0, 0, 1, 1},
  {&__pyx_n_s__cancel, __pyx_k__cancel, sizeof(__pyx_k__cancel), 0, 0, 1, 1},
  {&__pyx_n_s__chunked, __pyx_k__chunked, sizeof(__pyx_k__chunked), 0, 0, 1, 1},
  {&__pyx_n_s__code, __pyx_k__code, sizeof(__pyx_k__code), 0, 0, 1, 1},
  {&__pyx_n_s__deleted, __pyx_k__deleted, sizeof(__pyx_k__deleted), 0, 0, 1, 1},
  {&__pyx_n_s__detach, __pyx_k__detach, sizeof(__pyx_k__detach), 0, 0, 1, 1},
  {&__pyx_n_s__dispatch, __pyx_k__dispatch, sizeof(__pyx_k__dispatch), 0, 0, 1, 1},
  {&__pyx_n_s__dns_err_to_string, __pyx_k__dns_err_to_string, sizeof(__pyx_k__dns_err_to_string), 0, 0, 1, 1},
  {&__pyx_n_s__dns_init, __pyx_k__dns_init, sizeof(__pyx_k__dns_init), 0, 0, 1, 1},
  {&__pyx_n_s__dns_resolve_ipv4, __pyx_k__dns_resolve_ipv4, sizeof(__pyx_k__dns_resolve_ipv4), 0, 0, 1, 1},
  {&__pyx_n_s__dns_resolve_ipv6, __pyx_k__dns_resolve_ipv6, sizeof(__pyx_k__dns_resolve_ipv6), 0, 0, 1, 1},
  {&__pyx_n_s__dns_resolve_reverse, __pyx_k__dns_resolve_reverse, sizeof(__pyx_k__dns_resolve_reverse), 0, 0, 1, 1},
  {&__pyx_n_s__dns_shutdown, __pyx_k__dns_shutdown, sizeof(__pyx_k__dns_shutdown), 0, 0, 1, 1},
  {&__pyx_n_s__ev, __pyx_k__ev, sizeof(__pyx_k__ev), 0, 0, 1, 1},
  {&__pyx_n_s__ev_events, __pyx_k__ev_events, sizeof(__pyx_k__ev_events), 0, 0, 1, 1},
  {&__pyx_n_s__ev_fd, __pyx_k__ev_fd, sizeof(__pyx_k__ev_fd), 0, 0, 1, 1},
  {&__pyx_n_s__ev_flags, __pyx_k__ev_flags, sizeof(__pyx_k__ev_flags), 0, 0, 1, 1},
  {&__pyx_n_s__evcon, __pyx_k__evcon, sizeof(__pyx_k__evcon), 0, 0, 1, 1},
  {&__pyx_n_s__event, __pyx_k__event, sizeof(__pyx_k__event), 0, 0, 1, 1},
  {&__pyx_n_s__events_str, __pyx_k__events_str, sizeof(__pyx_k__events_str), 0, 0, 1, 1},
  {&__pyx_n_s__evtype, __pyx_k__evtype, sizeof(__pyx_k__evtype), 0, 0, 1, 1},
  {&__pyx_n_s__exc_clear, __pyx_k__exc_clear, sizeof(__pyx_k__exc_clear), 0, 0, 1, 1},
  {&__pyx_n_s__exc_traceback, __pyx_k__exc_traceback, sizeof(__pyx_k__exc_traceback), 0, 0, 1, 1},
  {&__pyx_n_s__exc_type, __pyx_k__exc_type, sizeof(__pyx_k__exc_type), 0, 0, 1, 1},
  {&__pyx_n_s__exc_value, __pyx_k__exc_value, sizeof(__pyx_k__exc_value), 0, 0, 1, 1},
  {&__pyx_n_s__fail_requests, __pyx_k__fail_requests, sizeof(__pyx_k__fail_requests), 0, 0, 1, 1},
  {&__pyx_n_s__fd, __pyx_k__fd, sizeof(__pyx_k__fd), 0, 0, 1, 1},
  {&__pyx_n_s__find_output_header, __pyx_k__find_output_header, sizeof(__pyx_k__find_output_header), 0, 0, 1, 1},
  {&__pyx_n_s__flags, __pyx_k__flags, sizeof(__pyx_k__flags), 0, 0, 1, 1},
  {&__pyx_n_s__flags_str, __pyx_k__flags_str, sizeof(__pyx_k__flags_str), 0, 0, 1, 1},
  {&__pyx_n_s__get, __pyx_k__get, sizeof(__pyx_k__get), 0, 0, 1, 1},
  {&__pyx_n_s__get_header_version, __pyx_k__get_header_version, sizeof(__pyx_k__get_header_version), 0, 0, 1, 1},
  {&__pyx_n_s__get_method, __pyx_k__get_method, sizeof(__pyx_k__get_method), 0, 0, 1, 1},
  {&__pyx_n_s__get_version, __pyx_k__get_version, sizeof(__pyx_k__get_version), 0, 0, 1, 1},
  {&__pyx_n_s__handle, __pyx_k__handle, sizeof(__pyx_k__handle), 0, 0, 1, 1},
  {&__pyx_n_s__hex, __pyx_k__hex, sizeof(__pyx_k__hex), 0, 0, 1, 1},
  {&__pyx_n_s__hint, __pyx_k__hint, sizeof(__pyx_k__hint), 0, 0, 1, 1},
  {&__pyx_n_s__http, __pyx_k__http, sizeof(__pyx_k__http), 0, 0, 1, 1},
  {&__pyx_n_s__http_connection, __pyx_k__http_connection, sizeof(__pyx_k__http_connection), 0, 0, 1, 1},
  {&__pyx_n_s__http_request, __pyx_k__http_request, sizeof(__pyx_k__http_request), 0, 0, 1, 1},
  {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
  {&__pyx_n_s__indent, __pyx_k__indent, sizeof(__pyx_k__indent), 0, 0, 1, 1},
  {&__pyx_n_s__init, __pyx_k__init, sizeof(__pyx_k__init), 0, 0, 1, 1},
  {&__pyx_n_s__input_buffer, __pyx_k__input_buffer, sizeof(__pyx_k__input_buffer), 0, 0, 1, 1},
  {&__pyx_n_s__input_headers, __pyx_k__input_headers, sizeof(__pyx_k__input_headers), 0, 0, 1, 1},
  {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
  {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
  {&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1},
  {&__pyx_n_s__kind, __pyx_k__kind, sizeof(__pyx_k__kind), 0, 0, 1, 1},
  {&__pyx_n_s__loop, __pyx_k__loop, sizeof(__pyx_k__loop), 0, 0, 1, 1},
  {&__pyx_n_s__major, __pyx_k__major, sizeof(__pyx_k__major), 0, 0, 1, 1},
  {&__pyx_n_s__min, __pyx_k__min, sizeof(__pyx_k__min), 0, 0, 1, 1},
  {&__pyx_n_s__minor, __pyx_k__minor, sizeof(__pyx_k__minor), 0, 0, 1, 1},
  {&__pyx_n_s__msg, __pyx_k__msg, sizeof(__pyx_k__msg), 0, 0, 1, 1},
  {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
  {&__pyx_n_s__nonblock, __pyx_k__nonblock, sizeof(__pyx_k__nonblock), 0, 0, 1, 1},
  {&__pyx_n_s__output_buffer, __pyx_k__output_buffer, sizeof(__pyx_k__output_buffer), 0, 0, 1, 1},
  {&__pyx_n_s__output_headers, __pyx_k__output_headers, sizeof(__pyx_k__output_headers), 0, 0, 1, 1},
  {&__pyx_n_s__packed_ip, __pyx_k__packed_ip, sizeof(__pyx_k__packed_ip), 0, 0, 1, 1},
  {&__pyx_n_s__peer, __pyx_k__peer, sizeof(__pyx_k__peer), 0, 0, 1, 1},
  {&__pyx_n_s__pending, __pyx_k__pending, sizeof(__pyx_k__pending), 0, 0, 1, 1},
  {&__pyx_n_s__persist, __pyx_k__persist, sizeof(__pyx_k__persist), 0, 0, 1, 1},
  {&__pyx_n_s__pformat, __pyx_k__pformat, sizeof(__pyx_k__pformat), 0, 0, 1, 1},
  {&__pyx_n_s__pop, __pyx_k__pop, sizeof(__pyx_k__pop), 0, 0, 1, 1},
  {&__pyx_n_s__port, __pyx_k__port, sizeof(__pyx_k__port), 0, 0, 1, 1},
  {&__pyx_n_s__pprint, __pyx_k__pprint, sizeof(__pyx_k__pprint), 0, 0, 1, 1},
  {&__pyx_n_s__print_exc, __pyx_k__print_exc, sizeof(__pyx_k__print_exc), 0, 0, 1, 1},
  {&__pyx_n_s__read, __pyx_k__read, sizeof(__pyx_k__read), 0, 0, 1, 1},
  {&__pyx_n_s__read_event, __pyx_k__read_event, sizeof(__pyx_k__read_event), 0, 0, 1, 1},
  {&__pyx_n_s__readline, __pyx_k__readline, sizeof(__pyx_k__readline), 0, 0, 1, 1},
  {&__pyx_n_s__readwrite_event, __pyx_k__readwrite_event, sizeof(__pyx_k__readwrite_event), 0, 0, 1, 1},
  {&__pyx_n_s__reason, __pyx_k__reason, sizeof(__pyx_k__reason), 0, 0, 1, 1},
  {&__pyx_n_s__reinit, __pyx_k__reinit, sizeof(__pyx_k__reinit), 0, 0, 1, 1},
  {&__pyx_n_s__remote_host, __pyx_k__remote_host, sizeof(__pyx_k__remote_host), 0, 0, 1, 1},
  {&__pyx_n_s__remote_port, __pyx_k__remote_port, sizeof(__pyx_k__remote_port), 0, 0, 1, 1},
  {&__pyx_n_s__remove_input_header, __pyx_k__remove_input_header, sizeof(__pyx_k__remove_input_header), 0, 0, 1, 1},
  {&__pyx_n_s__replace, __pyx_k__replace, sizeof(__pyx_k__replace), 0, 0, 1, 1},
  {&__pyx_n_s__response_code, __pyx_k__response_code, sizeof(__pyx_k__response_code), 0, 0, 1, 1},
  {&__pyx_n_s__response_code_line, __pyx_k__response_code_line, sizeof(__pyx_k__response_code_line), 0, 0, 1, 1},
  {&__pyx_n_s__seconds, __pyx_k__seconds, sizeof(__pyx_k__seconds), 0, 0, 1, 1},
  {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
  {&__pyx_n_s__signal, __pyx_k__signal, sizeof(__pyx_k__signal), 0, 0, 1, 1},
  {&__pyx_n_s__signalnum, __pyx_k__signalnum, sizeof(__pyx_k__signalnum), 0, 0, 1, 1},
  {&__pyx_n_s__size, __pyx_k__size, sizeof(__pyx_k__size), 0, 0, 1, 1},
  {&__pyx_n_s__stacklevel, __pyx_k__stacklevel, sizeof(__pyx_k__stacklevel), 0, 0, 1, 1},
  {&__pyx_n_s__stderr, __pyx_k__stderr, sizeof(__pyx_k__stderr), 0, 0, 1, 1},
  {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
  {&__pyx_n_s__tb, __pyx_k__tb, sizeof(__pyx_k__tb), 0, 0, 1, 1},
  {&__pyx_n_s__timeout, __pyx_k__timeout, sizeof(__pyx_k__timeout), 0, 0, 1, 1},
  {&__pyx_n_s__timer, __pyx_k__timer, sizeof(__pyx_k__timer), 0, 0, 1, 1},
  {&__pyx_n_s__traceback, __pyx_k__traceback, sizeof(__pyx_k__traceback), 0, 0, 1, 1},
  {&__pyx_n_s__tv_sec, __pyx_k__tv_sec, sizeof(__pyx_k__tv_sec), 0, 0, 1, 1},
  {&__pyx_n_s__tv_usec, __pyx_k__tv_usec, sizeof(__pyx_k__tv_usec), 0, 0, 1, 1},
  {&__pyx_n_s__typ, __pyx_k__typ, sizeof(__pyx_k__typ), 0, 0, 1, 1},
  {&__pyx_n_s__type, __pyx_k__type, sizeof(__pyx_k__type), 0, 0, 1, 1},
  {&__pyx_n_s__typestr, __pyx_k__typestr, sizeof(__pyx_k__typestr), 0, 0, 1, 1},
  {&__pyx_n_s__uri, __pyx_k__uri, sizeof(__pyx_k__uri), 0, 0, 1, 1},
  {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
  {&__pyx_n_s__warn, __pyx_k__warn, sizeof(__pyx_k__warn), 0, 0, 1, 1},
  {&__pyx_n_s__warnings, __pyx_k__warnings, sizeof(__pyx_k__warnings), 0, 0, 1, 1},
  {&__pyx_n_s__weakref, __pyx_k__weakref, sizeof(__pyx_k__weakref), 0, 0, 1, 1},
  {&__pyx_n_s__write, __pyx_k__write, sizeof(__pyx_k__write), 0, 0, 1, 1},
  {&__pyx_n_s__write_event, __pyx_k__write_event, sizeof(__pyx_k__write_event), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_UserWarning = __Pyx_GetName(__pyx_b, __pyx_n_s__UserWarning); if (!__pyx_builtin_UserWarning) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AttributeError = __Pyx_GetName(__pyx_b, __pyx_n_s__AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_hex = __Pyx_GetName(__pyx_b, __pyx_n_s__hex); if (!__pyx_builtin_hex) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_DeprecationWarning = __Pyx_GetName(__pyx_b, __pyx_n_s__DeprecationWarning); if (!__pyx_builtin_DeprecationWarning) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_id = __Pyx_GetName(__pyx_b, __pyx_n_s__id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_min = __Pyx_GetName(__pyx_b, __pyx_n_s__min); if (!__pyx_builtin_min) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_65 = PyInt_FromLong(65); if (unlikely(!__pyx_int_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_66 = PyInt_FromLong(66); if (unlikely(!__pyx_int_66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_67 = PyInt_FromLong(67); if (unlikely(!__pyx_int_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_68 = PyInt_FromLong(68); if (unlikely(!__pyx_int_68)) {__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;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  #if CYTHON_REFNANNY
  void* __pyx_refnanny = NULL;
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_core(void)", __LINE__, __FILE__);
  #endif
  __pyx_init_filenames();
  __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;}
  #if PY_MAJOR_VERSION < 3
  __pyx_empty_bytes = PyString_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #else
  __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;}
  #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, __Pyx_DOCSTR(__pyx_k_45), 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_gevent__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;}
  /*--- Global init code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_6gevent_4core_event = &__pyx_vtable_6gevent_4core_event;
  #if PY_MAJOR_VERSION >= 3
  __pyx_vtable_6gevent_4core_event._addref = (PyObject *(*)(struct __pyx_obj_6gevent_4core_event *))__pyx_f_6gevent_4core_5event__addref;
  __pyx_vtable_6gevent_4core_event._delref = (PyObject *(*)(struct __pyx_obj_6gevent_4core_event *))__pyx_f_6gevent_4core_5event__delref;
  #else
  *(void(**)(void))&__pyx_vtable_6gevent_4core_event._addref = (void(*)(void))__pyx_f_6gevent_4core_5event__addref;
  *(void(**)(void))&__pyx_vtable_6gevent_4core_event._delref = (void(*)(void))__pyx_f_6gevent_4core_5event__delref;
  #endif
  if (PyType_Ready(&__pyx_type_6gevent_4core_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6gevent_4core_event.tp_dict, __pyx_vtabptr_6gevent_4core_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "event", (PyObject *)&__pyx_type_6gevent_4core_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_event = &__pyx_type_6gevent_4core_event;
  __pyx_vtabptr_6gevent_4core_read_event = &__pyx_vtable_6gevent_4core_read_event;
  __pyx_vtable_6gevent_4core_read_event.__pyx_base = *__pyx_vtabptr_6gevent_4core_event;
  __pyx_type_6gevent_4core_read_event.tp_base = __pyx_ptype_6gevent_4core_event;
  if (PyType_Ready(&__pyx_type_6gevent_4core_read_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6gevent_4core_read_event.tp_dict, __pyx_vtabptr_6gevent_4core_read_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "read_event", (PyObject *)&__pyx_type_6gevent_4core_read_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_read_event = &__pyx_type_6gevent_4core_read_event;
  __pyx_vtabptr_6gevent_4core_write_event = &__pyx_vtable_6gevent_4core_write_event;
  __pyx_vtable_6gevent_4core_write_event.__pyx_base = *__pyx_vtabptr_6gevent_4core_event;
  __pyx_type_6gevent_4core_write_event.tp_base = __pyx_ptype_6gevent_4core_event;
  if (PyType_Ready(&__pyx_type_6gevent_4core_write_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6gevent_4core_write_event.tp_dict, __pyx_vtabptr_6gevent_4core_write_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "write_event", (PyObject *)&__pyx_type_6gevent_4core_write_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_write_event = &__pyx_type_6gevent_4core_write_event;
  __pyx_vtabptr_6gevent_4core_timer = &__pyx_vtable_6gevent_4core_timer;
  __pyx_vtable_6gevent_4core_timer.__pyx_base = *__pyx_vtabptr_6gevent_4core_event;
  __pyx_type_6gevent_4core_timer.tp_base = __pyx_ptype_6gevent_4core_event;
  if (PyType_Ready(&__pyx_type_6gevent_4core_timer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6gevent_4core_timer.tp_dict, __pyx_vtabptr_6gevent_4core_timer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "timer", (PyObject *)&__pyx_type_6gevent_4core_timer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_timer = &__pyx_type_6gevent_4core_timer;
  __pyx_vtabptr_6gevent_4core_signal = &__pyx_vtable_6gevent_4core_signal;
  __pyx_vtable_6gevent_4core_signal.__pyx_base = *__pyx_vtabptr_6gevent_4core_event;
  __pyx_type_6gevent_4core_signal.tp_base = __pyx_ptype_6gevent_4core_event;
  if (PyType_Ready(&__pyx_type_6gevent_4core_signal) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6gevent_4core_signal.tp_dict, __pyx_vtabptr_6gevent_4core_signal) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "signal", (PyObject *)&__pyx_type_6gevent_4core_signal) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_signal = &__pyx_type_6gevent_4core_signal;
  __pyx_vtabptr_6gevent_4core_active_event = &__pyx_vtable_6gevent_4core_active_event;
  __pyx_vtable_6gevent_4core_active_event.__pyx_base = *__pyx_vtabptr_6gevent_4core_event;
  __pyx_type_6gevent_4core_active_event.tp_base = __pyx_ptype_6gevent_4core_event;
  if (PyType_Ready(&__pyx_type_6gevent_4core_active_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6gevent_4core_active_event.tp_dict, __pyx_vtabptr_6gevent_4core_active_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "active_event", (PyObject *)&__pyx_type_6gevent_4core_active_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_active_event = &__pyx_type_6gevent_4core_active_event;
  if (PyType_Ready(&__pyx_type_6gevent_4core_buffer) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "buffer", (PyObject *)&__pyx_type_6gevent_4core_buffer) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_buffer = &__pyx_type_6gevent_4core_buffer;
  if (PyType_Ready(&__pyx_type_6gevent_4core_http_request) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "http_request", (PyObject *)&__pyx_type_6gevent_4core_http_request) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_type_6gevent_4core_http_request.tp_weaklistoffset == 0) __pyx_type_6gevent_4core_http_request.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_4core_http_request, __weakref__);
  __pyx_ptype_6gevent_4core_http_request = &__pyx_type_6gevent_4core_http_request;
  if (PyType_Ready(&__pyx_type_6gevent_4core_http_connection) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "http_connection", (PyObject *)&__pyx_type_6gevent_4core_http_connection) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_http_connection = &__pyx_type_6gevent_4core_http_connection;
  if (PyType_Ready(&__pyx_type_6gevent_4core_http) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "http", (PyObject *)&__pyx_type_6gevent_4core_http) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_http = &__pyx_type_6gevent_4core_http;
  /*--- Type import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "/home/denis/work/gevent/gevent/core.pyx":31
 * """
 * 
 * __author__ = ( 'Dug Song <dugsong@monkey.org>',             # <<<<<<<<<<<<<<
 *                'Martin Murray <mmurray@monkey.org>' )
 * __copyright__ = ( 'Copyright (c) 2004 Dug Song',
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_46));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_46));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_46));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_47));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_kp_s_47));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_47));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____author__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":33
 * __author__ = ( 'Dug Song <dugsong@monkey.org>',
 *                'Martin Murray <mmurray@monkey.org>' )
 * __copyright__ = ( 'Copyright (c) 2004 Dug Song',             # <<<<<<<<<<<<<<
 *                   'Copyright (c) 2003 Martin Murray' )
 * __license__ = 'BSD'
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_48));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_48));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_48));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_49));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_kp_s_49));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_49));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____copyright__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":35
 * __copyright__ = ( 'Copyright (c) 2004 Dug Song',
 *                   'Copyright (c) 2003 Martin Murray' )
 * __license__ = 'BSD'             # <<<<<<<<<<<<<<
 * __url__ = 'http://monkey.org/~dugsong/pyevent/'
 * __version__ = '0.4+'
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____license__, ((PyObject *)__pyx_n_s__BSD)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":36
 *                   'Copyright (c) 2003 Martin Murray' )
 * __license__ = 'BSD'
 * __url__ = 'http://monkey.org/~dugsong/pyevent/'             # <<<<<<<<<<<<<<
 * __version__ = '0.4+'
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____url__, ((PyObject *)__pyx_kp_s_50)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":37
 * __license__ = 'BSD'
 * __url__ = 'http://monkey.org/~dugsong/pyevent/'
 * __version__ = '0.4+'             # <<<<<<<<<<<<<<
 * 
 * __all__ = ['event', 'read_event', 'write_event', 'timer', 'signal', 'active_event',
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____version__, ((PyObject *)__pyx_kp_s_51)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":39
 * __version__ = '0.4+'
 * 
 * __all__ = ['event', 'read_event', 'write_event', 'timer', 'signal', 'active_event',             # <<<<<<<<<<<<<<
 *            'init', 'dispatch', 'loop', 'get_version', 'get_method', 'get_header_version']
 * # note, that .pxi files append stuff to __all__
 */
  __pyx_t_1 = PyList_New(12); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__event));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__event));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__event));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__read_event));
  PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__read_event));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__read_event));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__write_event));
  PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__write_event));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__write_event));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__timer));
  PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__timer));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__timer));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__signal));
  PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__signal));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__signal));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__active_event));
  PyList_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__active_event));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__active_event));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__init));
  PyList_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__init));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__init));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dispatch));
  PyList_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__dispatch));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dispatch));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__loop));
  PyList_SET_ITEM(__pyx_t_1, 8, ((PyObject *)__pyx_n_s__loop));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__loop));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__get_version));
  PyList_SET_ITEM(__pyx_t_1, 9, ((PyObject *)__pyx_n_s__get_version));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__get_version));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__get_method));
  PyList_SET_ITEM(__pyx_t_1, 10, ((PyObject *)__pyx_n_s__get_method));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__get_method));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__get_header_version));
  PyList_SET_ITEM(__pyx_t_1, 11, ((PyObject *)__pyx_n_s__get_header_version));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__get_header_version));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":43
 * # note, that .pxi files append stuff to __all__
 * 
 * import sys             # <<<<<<<<<<<<<<
 * import traceback
 * from pprint import pformat
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":44
 * 
 * import sys
 * import traceback             # <<<<<<<<<<<<<<
 * from pprint import pformat
 * import weakref
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__traceback), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__traceback, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":45
 * import sys
 * import traceback
 * from pprint import pformat             # <<<<<<<<<<<<<<
 * import weakref
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pformat));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__pformat));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pformat));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__pprint), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__pformat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__pformat, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":46
 * import traceback
 * from pprint import pformat
 * import weakref             # <<<<<<<<<<<<<<
 * 
 * DEF EVENT_INTERNAL_AVAILABLE = False
 */
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__weakref), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__weakref, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":346
 *     """Create a new scheduled event with evtype=EV_READ"""
 * 
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):             # <<<<<<<<<<<<<<
 *         cdef short evtype = EV_READ
 *         if persist:
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_12 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":357
 *     """Create a new scheduled event with evtype=EV_WRITE"""
 * 
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):             # <<<<<<<<<<<<<<
 *         cdef short evtype = EV_WRITE
 *         if persist:
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_13 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":365
 * 
 * 
 * class readwrite_event(event):             # <<<<<<<<<<<<<<
 *     """Create a new scheduled event with evtype=EV_READ|EV_WRITE"""
 * 
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_event)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_event)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_event)));
  if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_52)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_CreateClass(__pyx_t_1, ((PyObject *)__pyx_t_2), __pyx_n_s__readwrite_event, "gevent.core"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":368
 *     """Create a new scheduled event with evtype=EV_READ|EV_WRITE"""
 * 
 *     def __init__(self, int handle, callback, timeout=None, arg=None, persist=False):             # <<<<<<<<<<<<<<
 *         cdef short evtype = EV_READ|EV_WRITE
 *         if persist:
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_k_14 = __pyx_t_1;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyCFunction_New(&__pyx_mdef_6gevent_4core_15readwrite_event___init__, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyMethod_New(__pyx_t_1, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____init__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__readwrite_event, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":445
 * 
 * 
 * def loop(nonblock=False):             # <<<<<<<<<<<<<<
 *     """Dispatch all pending events on queue in a single pass.
 *     Returns 0 on success, and 1 if no events are registered.
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_15 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":1
 * __all__ += ['dns_init', 'dns_shutdown', 'dns_err_to_string',             # <<<<<<<<<<<<<<
 *             'dns_resolve_ipv4', 'dns_resolve_ipv6',
 *             'dns_resolve_reverse', 'dns_resolve_reverse_ipv6']
 */
  __pyx_t_2 = PyList_New(7); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dns_init));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__dns_init));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dns_init));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dns_shutdown));
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__dns_shutdown));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dns_shutdown));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dns_err_to_string));
  PyList_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_n_s__dns_err_to_string));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dns_err_to_string));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dns_resolve_ipv4));
  PyList_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_n_s__dns_resolve_ipv4));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dns_resolve_ipv4));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dns_resolve_ipv6));
  PyList_SET_ITEM(__pyx_t_2, 4, ((PyObject *)__pyx_n_s__dns_resolve_ipv6));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dns_resolve_ipv6));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dns_resolve_reverse));
  PyList_SET_ITEM(__pyx_t_2, 5, ((PyObject *)__pyx_n_s__dns_resolve_reverse));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dns_resolve_reverse));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_53));
  PyList_SET_ITEM(__pyx_t_2, 6, ((PyObject *)__pyx_n_s_53));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_53));
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s____all__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_3, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":20
 * 
 * # Result codes
 * DNS_ERR_NONE         = 0             # <<<<<<<<<<<<<<
 * DNS_ERR_FORMAT       = 1
 * DNS_ERR_SERVERFAILED = 2
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_ERR_NONE, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":21
 * # Result codes
 * DNS_ERR_NONE         = 0
 * DNS_ERR_FORMAT       = 1             # <<<<<<<<<<<<<<
 * DNS_ERR_SERVERFAILED = 2
 * DNS_ERR_NOTEXIST     = 3
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_ERR_FORMAT, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":22
 * DNS_ERR_NONE         = 0
 * DNS_ERR_FORMAT       = 1
 * DNS_ERR_SERVERFAILED = 2             # <<<<<<<<<<<<<<
 * DNS_ERR_NOTEXIST     = 3
 * DNS_ERR_NOTIMPL      = 4
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_54, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":23
 * DNS_ERR_FORMAT       = 1
 * DNS_ERR_SERVERFAILED = 2
 * DNS_ERR_NOTEXIST     = 3             # <<<<<<<<<<<<<<
 * DNS_ERR_NOTIMPL      = 4
 * DNS_ERR_REFUSED      = 5
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_ERR_NOTEXIST, __pyx_int_3) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":24
 * DNS_ERR_SERVERFAILED = 2
 * DNS_ERR_NOTEXIST     = 3
 * DNS_ERR_NOTIMPL      = 4             # <<<<<<<<<<<<<<
 * DNS_ERR_REFUSED      = 5
 * DNS_ERR_TRUNCATED    = 65
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_ERR_NOTIMPL, __pyx_int_4) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":25
 * DNS_ERR_NOTEXIST     = 3
 * DNS_ERR_NOTIMPL      = 4
 * DNS_ERR_REFUSED      = 5             # <<<<<<<<<<<<<<
 * DNS_ERR_TRUNCATED    = 65
 * DNS_ERR_UNKNOWN      = 66
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_ERR_REFUSED, __pyx_int_5) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":26
 * DNS_ERR_NOTIMPL      = 4
 * DNS_ERR_REFUSED      = 5
 * DNS_ERR_TRUNCATED    = 65             # <<<<<<<<<<<<<<
 * DNS_ERR_UNKNOWN      = 66
 * DNS_ERR_TIMEOUT      = 67
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_ERR_TRUNCATED, __pyx_int_65) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":27
 * DNS_ERR_REFUSED      = 5
 * DNS_ERR_TRUNCATED    = 65
 * DNS_ERR_UNKNOWN      = 66             # <<<<<<<<<<<<<<
 * DNS_ERR_TIMEOUT      = 67
 * DNS_ERR_SHUTDOWN     = 68
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_ERR_UNKNOWN, __pyx_int_66) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":28
 * DNS_ERR_TRUNCATED    = 65
 * DNS_ERR_UNKNOWN      = 66
 * DNS_ERR_TIMEOUT      = 67             # <<<<<<<<<<<<<<
 * DNS_ERR_SHUTDOWN     = 68
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_ERR_TIMEOUT, __pyx_int_67) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":29
 * DNS_ERR_UNKNOWN      = 66
 * DNS_ERR_TIMEOUT      = 67
 * DNS_ERR_SHUTDOWN     = 68             # <<<<<<<<<<<<<<
 * 
 * # Types
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_ERR_SHUTDOWN, __pyx_int_68) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":32
 * 
 * # Types
 * DNS_IPv4_A    = 1             # <<<<<<<<<<<<<<
 * DNS_PTR       = 2
 * DNS_IPv6_AAAA = 3
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_IPv4_A, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":33
 * # Types
 * DNS_IPv4_A    = 1
 * DNS_PTR       = 2             # <<<<<<<<<<<<<<
 * DNS_IPv6_AAAA = 3
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_PTR, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":34
 * DNS_IPv4_A    = 1
 * DNS_PTR       = 2
 * DNS_IPv6_AAAA = 3             # <<<<<<<<<<<<<<
 * 
 * # Flags
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_IPv6_AAAA, __pyx_int_3) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":37
 * 
 * # Flags
 * DNS_QUERY_NO_SEARCH = 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DNS_QUERY_NO_SEARCH, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":499
 * 
 * # XXX - make sure event queue is always initialized.
 * init()             # <<<<<<<<<<<<<<
 * 
 * if get_version() != get_header_version() and get_header_version() is not None and get_version() != '1.3.99-trunk':
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__init); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":501
 * init()
 * 
 * if get_version() != get_header_version() and get_header_version() is not None and get_version() != '1.3.99-trunk':             # <<<<<<<<<<<<<<
 *     import warnings
 *     msg = "libevent version mismatch: system version is %r but this gevent is compiled against %r" % (get_version(), get_header_version())
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_version); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_header_version); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_header_version); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = (__pyx_t_2 != Py_None);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_6) {
      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_version); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_kp_s_55), Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = __pyx_t_7;
    } else {
      __pyx_t_8 = __pyx_t_6;
    }
    __pyx_t_6 = __pyx_t_8;
  } else {
    __pyx_t_6 = __pyx_t_5;
  }
  if (__pyx_t_6) {

    /* "/home/denis/work/gevent/gevent/core.pyx":502
 * 
 * if get_version() != get_header_version() and get_header_version() is not None and get_version() != '1.3.99-trunk':
 *     import warnings             # <<<<<<<<<<<<<<
 *     msg = "libevent version mismatch: system version is %r but this gevent is compiled against %r" % (get_version(), get_header_version())
 *     warnings.warn(msg, UserWarning, stacklevel=2)
 */
    __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__warnings), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__warnings, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "/home/denis/work/gevent/gevent/core.pyx":503
 * if get_version() != get_header_version() and get_header_version() is not None and get_version() != '1.3.99-trunk':
 *     import warnings
 *     msg = "libevent version mismatch: system version is %r but this gevent is compiled against %r" % (get_version(), get_header_version())             # <<<<<<<<<<<<<<
 *     warnings.warn(msg, UserWarning, stacklevel=2)
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_version); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_header_version); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_56), __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__msg, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/home/denis/work/gevent/gevent/core.pyx":504
 *     import warnings
 *     msg = "libevent version mismatch: system version is %r but this gevent is compiled against %r" % (get_version(), get_header_version())
 *     warnings.warn(msg, UserWarning, stacklevel=2)             # <<<<<<<<<<<<<<
 * 
 * include "evbuffer.pxi"
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__warnings); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__warn); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__msg); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_builtin_UserWarning);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_builtin_UserWarning);
    __Pyx_GIVEREF(__pyx_builtin_UserWarning);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__stacklevel), __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":1
 * __all__ += ['buffer']             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "string.h":
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__buffer));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__buffer));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__buffer));
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s____all__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_4, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":105
 *         return result
 * 
 *     def readlines(self, hint=-1):             # <<<<<<<<<<<<<<
 *         return list(self)
 * 
 */
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__http_request));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__http_request));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__http_request));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__http_connection));
  PyList_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__http_connection));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__http_connection));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__http));
  PyList_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__http));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__http));
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s____all__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_4, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":1
 * __all__ += ['http_request', 'http_connection', 'http']             # <<<<<<<<<<<<<<
 * 
 * EVHTTP_REQUEST      = 0
 */
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":3
 * __all__ += ['http_request', 'http_connection', 'http']
 * 
 * EVHTTP_REQUEST      = 0             # <<<<<<<<<<<<<<
 * EVHTTP_RESPONSE     = 1
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__EVHTTP_REQUEST, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":4
 * 
 * EVHTTP_REQUEST      = 0
 * EVHTTP_RESPONSE     = 1             # <<<<<<<<<<<<<<
 * 
 * EVHTTP_REQ_GET      = 0
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__EVHTTP_RESPONSE, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":6
 * EVHTTP_RESPONSE     = 1
 * 
 * EVHTTP_REQ_GET      = 0             # <<<<<<<<<<<<<<
 * EVHTTP_REQ_POST     = 1
 * EVHTTP_REQ_HEAD     = 2
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__EVHTTP_REQ_GET, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":7
 * 
 * EVHTTP_REQ_GET      = 0
 * EVHTTP_REQ_POST     = 1             # <<<<<<<<<<<<<<
 * EVHTTP_REQ_HEAD     = 2
 * EVHTTP_REQ_PUT      = 3
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__EVHTTP_REQ_POST, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":8
 * EVHTTP_REQ_GET      = 0
 * EVHTTP_REQ_POST     = 1
 * EVHTTP_REQ_HEAD     = 2             # <<<<<<<<<<<<<<
 * EVHTTP_REQ_PUT      = 3
 * EVHTTP_REQ_DELETE   = 4
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__EVHTTP_REQ_HEAD, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":9
 * EVHTTP_REQ_POST     = 1
 * EVHTTP_REQ_HEAD     = 2
 * EVHTTP_REQ_PUT      = 3             # <<<<<<<<<<<<<<
 * EVHTTP_REQ_DELETE   = 4
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__EVHTTP_REQ_PUT, __pyx_int_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":10
 * EVHTTP_REQ_HEAD     = 2
 * EVHTTP_REQ_PUT      = 3
 * EVHTTP_REQ_DELETE   = 4             # <<<<<<<<<<<<<<
 * 
 * HTTP_method2name = { 0: 'GET', 1: 'POST', 2: 'HEAD', 3: 'PUT', 4: 'DELETE' }
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__EVHTTP_REQ_DELETE, __pyx_int_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":12
 * EVHTTP_REQ_DELETE   = 4
 * 
 * HTTP_method2name = { 0: 'GET', 1: 'POST', 2: 'HEAD', 3: 'PUT', 4: 'DELETE' }             # <<<<<<<<<<<<<<
 * 
 * cdef extern from *:
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_0, ((PyObject *)__pyx_n_s__GET)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1, ((PyObject *)__pyx_n_s__POST)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2, ((PyObject *)__pyx_n_s__HEAD)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3, ((PyObject *)__pyx_n_s__PUT)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_4, ((PyObject *)__pyx_n_s__DELETE)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__HTTP_method2name, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":96
 * 
 * 
 * class ObjectDeleted(AttributeError):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_builtin_AttributeError);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_builtin_AttributeError);
  __Pyx_GIVEREF(__pyx_builtin_AttributeError);
  __pyx_t_3 = __Pyx_CreateClass(__pyx_t_4, ((PyObject *)__pyx_t_1), __pyx_n_s__ObjectDeleted, "gevent.core"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ObjectDeleted, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":99
 *     pass
 * 
 * class HttpRequestDeleted(ObjectDeleted):             # <<<<<<<<<<<<<<
 *     """Raised when an attribute is accessed of http_request instance whose _obj is 0"""
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ObjectDeleted); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_57)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_CreateClass(__pyx_t_4, ((PyObject *)__pyx_t_1), __pyx_n_s__HttpRequestDeleted, "gevent.core"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__HttpRequestDeleted, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":102
 *     """Raised when an attribute is accessed of http_request instance whose _obj is 0"""
 * 
 * class HttpConnectionDeleted(ObjectDeleted):             # <<<<<<<<<<<<<<
 *     """Raised when an attribute is accessed of http_connection instance whose _obj is 0"""
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ObjectDeleted); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_58)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_CreateClass(__pyx_t_4, ((PyObject *)__pyx_t_1), __pyx_n_s_32, "gevent.core"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_32, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":1
 * #             # <<<<<<<<<<<<<<
 * # event.pyx
 * #
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__event); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__add); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_4, "__doc__");
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_59), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__event); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__cancel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_4, "__doc__");
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_60), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__init); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_61), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__dispatch); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_4, "__doc__");
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_62), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__loop); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_63), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__get_version); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_4, "__doc__");
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_64), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__get_method); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_65), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__get_header_version); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_4, "__doc__");
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_66), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__reinit); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_67), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__dns_init); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_4, "__doc__");
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_68), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__dns_shutdown); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_69), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__dns_resolve_ipv4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_4, "__doc__");
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_70), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__dns_resolve_ipv6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_71), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__dns_resolve_reverse); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_4, "__doc__");
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_72), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s_53); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_73), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__buffer); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__read); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_74), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__http_request); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__remove_input_header); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_75), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__http_request); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s_77); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_76), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__pyx_m) {
    __Pyx_AddTraceback("init gevent.core");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init gevent.core");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

static const char *__pyx_filenames[] = {
  "core.pyx",
  "evhttp.pxi",
  "evbuffer.pxi",
  "evdns.pxi",
};

/* Runtime support code */

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

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
    if (unlikely(tstate->curexc_type))
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}


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

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

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

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


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

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

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

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

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

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
        #if PY_VERSION_HEX < 0x02050000
                 "need more than %d value%s to unpack", (int)index,
        #else
                 "need more than %zd value%s to unpack", index,
        #endif
                 (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void) {
    PyErr_SetString(PyExc_ValueError, "too many values to unpack");
}

static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
    PyObject *item;
    if (!(item = PyIter_Next(iter))) {
        if (!PyErr_Occurred()) {
            __Pyx_RaiseNeedMoreValuesError(index);
        }
    }
    return item;
}

static int __Pyx_EndUnpack(PyObject *iter) {
    PyObject *item;
    if ((item = PyIter_Next(iter))) {
        Py_DECREF(item);
        __Pyx_RaiseTooManyValuesError();
        return -1;
    }
    else if (!PyErr_Occurred())
        return 0;
    else
        return -1;
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #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;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
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
    return 0;
}

static PyObject* __Pyx_PyEval_CallObjectWithKeywords(PyObject *callable, PyObject *args, PyObject *kwargs) {
    PyObject* result;
    if (likely(PyDict_Check(kwargs))) {
        return PyEval_CallObjectWithKeywords(callable, args, kwargs);
    } else {
        PyObject* real_dict;
        real_dict = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, kwargs, NULL);
        if (unlikely(!real_dict))
            return NULL;
        result = PyEval_CallObjectWithKeywords(callable, args, real_dict);
        Py_DECREF(real_dict);
        return result; /* may be NULL */
    }
}

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 void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}

static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

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

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

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

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

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

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

#else /* Python 3+ */

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

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

    PyErr_SetObject(type, value);

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

bad:
    return;
}
#endif

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_ev_uint16_t(ev_uint16_t val) {
    const ev_uint16_t neg_one = (ev_uint16_t)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(ev_uint16_t) <  sizeof(long)) {
        return PyInt_FromLong((long)val);
    } else if (sizeof(ev_uint16_t) == sizeof(long)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else { /* (sizeof(ev_uint16_t) > sizeof(long)) */
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    }
}

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

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

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

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

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

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

static void __Pyx_WriteUnraisable(const char *name) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX < 0x03010000
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#else
    PyObject *ob = PyCapsule_New(vtable, 0, 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;
}

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

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

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

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

/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   if (x == Py_True) return 1;
   else if ((x == Py_False) | (x == Py_None)) return 0;
   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 */
