/* Generated by Cython 0.11.2 on Thu Oct  8 14:05:52 2009 */

#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.
#endif
#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)
#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)
#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                PyBytes_Type
  #define PyString_CheckExact          PyBytes_CheckExact
  #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)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define PyBytes_Type                 PyString_Type
#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 "libevent.h"
#include "string.h"
#include "errno.h"
#include "netinet/in.h"
#include "sys/socket.h"
#include "arpa/inet.h"
#define __PYX_USE_C99_COMPLEX defined(_Complex_I)


#ifdef __GNUC__
#define INLINE __inline__
#elif _WIN32
#define INLINE __inline
#else
#define INLINE 
#endif

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



static int __pyx_skip_dispatch = 0;


/* 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_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static 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_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 INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static 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 int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
static const char **__pyx_f;

static char __pyx_mdoc[] = "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";


#ifdef 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* (*NewContext)(const char*, int, const char*);
  void (*FinishContext)(void**);
} __Pyx_RefnannyAPIStruct;
static __Pyx_RefnannyAPIStruct *__Pyx_Refnanny = NULL;
#define __Pyx_ImportRefcountAPI(name)   (__Pyx_RefnannyAPIStruct *) PyCObject_Import((char *)name, (char *)"RefnannyAPI")
#define __Pyx_INCREF(r) __Pyx_Refnanny->INCREF(__pyx_refchk, (PyObject *)(r), __LINE__)
#define __Pyx_DECREF(r) __Pyx_Refnanny->DECREF(__pyx_refchk, (PyObject *)(r), __LINE__)
#define __Pyx_GOTREF(r) __Pyx_Refnanny->GOTREF(__pyx_refchk, (PyObject *)(r), __LINE__)
#define __Pyx_GIVEREF(r) __Pyx_Refnanny->GIVEREF(__pyx_refchk, (PyObject *)(r), __LINE__)
#define __Pyx_XDECREF(r) if((r) == NULL) ; else __Pyx_DECREF(r)
#define __Pyx_SetupRefcountContext(name)   void* __pyx_refchk = __Pyx_Refnanny->NewContext((name), __LINE__, __FILE__)
#define __Pyx_FinishRefcountContext()   __Pyx_Refnanny->FinishContext(&__pyx_refchk)
#else
#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)
#define __Pyx_SetupRefcountContext(name)
#define __Pyx_FinishRefcountContext()
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) if((r) == NULL) ; else __Pyx_GIVEREF(r)
#define __Pyx_XGOTREF(r) if((r) == NULL) ; else __Pyx_GOTREF(r)

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static 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 INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
    const char* function_name, int kw_allowed); /*proto*/

static 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_GetName(PyObject *dict, PyObject *name); /*proto*/

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

static INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static INLINE void __Pyx_RaiseTooManyValuesError(void);

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

static 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 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 INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/

static INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static INLINE char __Pyx_PyInt_AsChar(PyObject *);

static INLINE short __Pyx_PyInt_AsShort(PyObject *);

static INLINE int __Pyx_PyInt_AsInt(PyObject *);

static INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static INLINE long __Pyx_PyInt_AsLong(PyObject *);

static INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static void __Pyx_WriteUnraisable(const char *name); /*proto*/

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

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

/* 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":147
 * 
 * 
 * cdef class event:             # <<<<<<<<<<<<<<
 *     """Create a new event object with a user callback.
 * 
 */

struct __pyx_obj_6gevent_4core_event {
  PyObject_HEAD
  struct event ev;
  PyObject *_callback;
  PyObject *_arg;
};

/* "/home/denis/work/gevent/gevent/core.pyx":338
 * 
 * 
 * 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":110
 * 
 * 
 * cdef class http_request:             # <<<<<<<<<<<<<<
 *     """Wrapper around libevent's :class:`evhttp_request` structure."""
 * 
 */

struct __pyx_obj_6gevent_4core_http_request {
  PyObject_HEAD
  struct evhttp_request *__pyx___obj;
};

/* "/home/denis/work/gevent/gevent/core.pyx":286
 * 
 * 
 * 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":400
 * 
 * 
 * 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":17
 * 
 * 
 * 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":328
 * 
 * 
 * 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":318
 * 
 * 
 * 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":294
 * 
 * 
 * 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":472
 * 
 * 
 * cdef class http:             # <<<<<<<<<<<<<<
 *     cdef evhttp* __obj
 *     cdef object _gencb
 */

struct __pyx_obj_6gevent_4core_http {
  PyObject_HEAD
  struct evhttp *__pyx___obj;
  PyObject *_gencb;
  PyObject *_cbs;
};
/* 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 PyObject *__pyx_k_25 = 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_connection_closecb_handler(struct evhttp_connection *, void *); /*proto*/
static void __pyx_f_6gevent_4core__http_cb_handler(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 char __pyx_k_1[] = "User callback that will be called once the event is signalled.\n\n        The prototype: ``callback(event instance, evtype)``.\n        ";
static char __pyx_k_2[] = "Optional object set and read only by the user.";
static char __pyx_k_3[] = "Return True if the event is still scheduled to run.";
static char __pyx_k_6[] = "Dug Song <dugsong@monkey.org>";
static char __pyx_k_7[] = "Martin Murray <mmurray@monkey.org>";
static char __pyx_k_8[] = "Copyright (c) 2004 Dug Song";
static char __pyx_k_9[] = "Copyright (c) 2003 Martin Murray";
static char __pyx_k_11[] = "http://monkey.org/~dugsong/pyevent/";
static char __pyx_k_12[] = "0.4+";
static char __pyx_k_36[] = "libevent version mismatch: system version is %r but this gevent is compiled against %r";
static char __pyx_k_47[] = "Raised when an attribute is accessed of http_request instance whose _obj is 0";
static char __pyx_k_49[] = "Raised when an attribute is accessed of http_connection instance whose _obj is 0";
static char __pyx_k_50[] = "127.0.0.1";
static char __pyx_k_51[] = "127.0.0.1";
static PyObject *__pyx_int_0x01;
static PyObject *__pyx_int_0x02;
static PyObject *__pyx_int_0x04;
static PyObject *__pyx_int_0x08;
static PyObject *__pyx_int_0x10;
static PyObject *__pyx_int_neg_1;
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_65;
static PyObject *__pyx_int_66;
static PyObject *__pyx_int_67;
static PyObject *__pyx_int_68;
static PyObject *__pyx_int_8;
static char __pyx_k___main__[] = "__main__";
static PyObject *__pyx_kp___main__;
static char __pyx_k___init__[] = "__init__";
static PyObject *__pyx_kp___init__;
static char __pyx_k_add[] = "add";
static PyObject *__pyx_kp_add;
static char __pyx_k_cancel[] = "cancel";
static PyObject *__pyx_kp_cancel;
static char __pyx_k___repr__[] = "__repr__";
static PyObject *__pyx_kp___repr__;
static char __pyx_k___str__[] = "__str__";
static PyObject *__pyx_kp___str__;
static char __pyx_k___enter__[] = "__enter__";
static PyObject *__pyx_kp___enter__;
static char __pyx_k___exit__[] = "__exit__";
static PyObject *__pyx_kp___exit__;
static char __pyx_k___len__[] = "__len__";
static PyObject *__pyx_kp___len__;
static char __pyx_k___nonzero__[] = "__nonzero__";
static PyObject *__pyx_kp___nonzero__;
static char __pyx_k_read[] = "read";
static PyObject *__pyx_kp_read;
static char __pyx_k_readline[] = "readline";
static PyObject *__pyx_kp_readline;
static char __pyx_k_readlines[] = "readlines";
static PyObject *__pyx_kp_readlines;
static char __pyx_k_detach[] = "detach";
static PyObject *__pyx_kp_detach;
static char __pyx_k__format[] = "_format";
static PyObject *__pyx_kp__format;
static char __pyx_k_get_input_headers[] = "get_input_headers";
static PyObject *__pyx_kp_get_input_headers;
static char __pyx_k_send_reply[] = "send_reply";
static PyObject *__pyx_kp_send_reply;
static char __pyx_k_send_reply_start[] = "send_reply_start";
static PyObject *__pyx_kp_send_reply_start;
static char __pyx_k_send_reply_chunk[] = "send_reply_chunk";
static PyObject *__pyx_kp_send_reply_chunk;
static char __pyx_k_send_reply_end[] = "send_reply_end";
static PyObject *__pyx_kp_send_reply_end;
static char __pyx_k_send_error[] = "send_error";
static PyObject *__pyx_kp_send_error;
static char __pyx_k_find_input_header[] = "find_input_header";
static PyObject *__pyx_kp_find_input_header;
static char __pyx_k_find_output_header[] = "find_output_header";
static PyObject *__pyx_kp_find_output_header;
static char __pyx_k_add_input_header[] = "add_input_header";
static PyObject *__pyx_kp_add_input_header;
static char __pyx_k_add_output_header[] = "add_output_header";
static PyObject *__pyx_kp_add_output_header;
static char __pyx_k_remove_input_header[] = "remove_input_header";
static PyObject *__pyx_kp_remove_input_header;
static char __pyx_k_4[] = "remove_output_header";
static PyObject *__pyx_kp_4;
static char __pyx_k_clear_input_headers[] = "clear_input_headers";
static PyObject *__pyx_kp_clear_input_headers;
static char __pyx_k_5[] = "clear_output_headers";
static PyObject *__pyx_kp_5;
static char __pyx_k_set_closecb[] = "set_closecb";
static PyObject *__pyx_kp_set_closecb;
static char __pyx_k___dealloc__[] = "__dealloc__";
static PyObject *__pyx_kp___dealloc__;
static char __pyx_k_bind[] = "bind";
static PyObject *__pyx_kp_bind;
static char __pyx_k_accept[] = "accept";
static PyObject *__pyx_kp_accept;
static char __pyx_k_start[] = "start";
static PyObject *__pyx_kp_start;
static char __pyx_k_set_cb[] = "set_cb";
static PyObject *__pyx_kp_set_cb;
static char __pyx_k_set_gencb[] = "set_gencb";
static PyObject *__pyx_kp_set_gencb;
static char __pyx_k_evtype[] = "evtype";
static PyObject *__pyx_kp_evtype;
static char __pyx_k_handle[] = "handle";
static PyObject *__pyx_kp_handle;
static char __pyx_k_callback[] = "callback";
static PyObject *__pyx_kp_callback;
static char __pyx_k_arg[] = "arg";
static PyObject *__pyx_kp_arg;
static char __pyx_k_new[] = "new";
static PyObject *__pyx_kp_new;
static char __pyx_k_timeout[] = "timeout";
static PyObject *__pyx_kp_timeout;
static char __pyx_k_seconds[] = "seconds";
static PyObject *__pyx_kp_seconds;
static char __pyx_k_signalnum[] = "signalnum";
static PyObject *__pyx_kp_signalnum;
static char __pyx_k_nonblock[] = "nonblock";
static PyObject *__pyx_kp_nonblock;
static char __pyx_k_name[] = "name";
static PyObject *__pyx_kp_name;
static char __pyx_k_flags[] = "flags";
static PyObject *__pyx_kp_flags;
static char __pyx_k_ip[] = "ip";
static PyObject *__pyx_kp_ip;
static char __pyx_k_fail_requests[] = "fail_requests";
static PyObject *__pyx_kp_fail_requests;
static char __pyx_k__obj[] = "_obj";
static PyObject *__pyx_kp__obj;
static char __pyx_k_size[] = "size";
static PyObject *__pyx_kp_size;
static char __pyx_k_hint[] = "hint";
static PyObject *__pyx_kp_hint;
static char __pyx_k_code[] = "code";
static PyObject *__pyx_kp_code;
static char __pyx_k_reason[] = "reason";
static PyObject *__pyx_kp_reason;
static char __pyx_k_buf[] = "buf";
static PyObject *__pyx_kp_buf;
static char __pyx_k_key[] = "key";
static PyObject *__pyx_kp_key;
static char __pyx_k_value[] = "value";
static PyObject *__pyx_kp_value;
static char __pyx_k_address[] = "address";
static PyObject *__pyx_kp_address;
static char __pyx_k_port[] = "port";
static PyObject *__pyx_kp_port;
static char __pyx_k_fd[] = "fd";
static PyObject *__pyx_kp_fd;
static char __pyx_k_path[] = "path";
static PyObject *__pyx_kp_path;
static char __pyx_k___author__[] = "__author__";
static PyObject *__pyx_kp___author__;
static char __pyx_k___copyright__[] = "__copyright__";
static PyObject *__pyx_kp___copyright__;
static char __pyx_k___license__[] = "__license__";
static PyObject *__pyx_kp___license__;
static char __pyx_k_10[] = "BSD";
static PyObject *__pyx_kp_10;
static char __pyx_k___url__[] = "__url__";
static PyObject *__pyx_kp___url__;
static char __pyx_k___version__[] = "__version__";
static PyObject *__pyx_kp___version__;
static char __pyx_k_13[] = "event";
static PyObject *__pyx_kp_13;
static char __pyx_k_14[] = "read_event";
static PyObject *__pyx_kp_14;
static char __pyx_k_15[] = "write_event";
static PyObject *__pyx_kp_15;
static char __pyx_k_16[] = "timer";
static PyObject *__pyx_kp_16;
static char __pyx_k_17[] = "signal";
static PyObject *__pyx_kp_17;
static char __pyx_k_18[] = "active_event";
static PyObject *__pyx_kp_18;
static char __pyx_k_19[] = "init";
static PyObject *__pyx_kp_19;
static char __pyx_k_20[] = "dispatch";
static PyObject *__pyx_kp_20;
static char __pyx_k_21[] = "loop";
static PyObject *__pyx_kp_21;
static char __pyx_k_22[] = "get_version";
static PyObject *__pyx_kp_22;
static char __pyx_k_23[] = "get_method";
static PyObject *__pyx_kp_23;
static char __pyx_k_24[] = "get_header_version";
static PyObject *__pyx_kp_24;
static char __pyx_k___all__[] = "__all__";
static PyObject *__pyx_kp___all__;
static char __pyx_k_sys[] = "sys";
static PyObject *__pyx_kp_sys;
static char __pyx_k_traceback[] = "traceback";
static PyObject *__pyx_kp_traceback;
static char __pyx_k_pprint[] = "pprint";
static PyObject *__pyx_kp_pprint;
static char __pyx_k_pformat[] = "pformat";
static PyObject *__pyx_kp_pformat;
static char __pyx_k_EV_TIMEOUT[] = "EV_TIMEOUT";
static PyObject *__pyx_kp_EV_TIMEOUT;
static char __pyx_k_EV_READ[] = "EV_READ";
static PyObject *__pyx_kp_EV_READ;
static char __pyx_k_EV_WRITE[] = "EV_WRITE";
static PyObject *__pyx_kp_EV_WRITE;
static char __pyx_k_EV_SIGNAL[] = "EV_SIGNAL";
static PyObject *__pyx_kp_EV_SIGNAL;
static char __pyx_k_EV_PERSIST[] = "EV_PERSIST";
static PyObject *__pyx_kp_EV_PERSIST;
static char __pyx_k_26[] = "dns_init";
static PyObject *__pyx_kp_26;
static char __pyx_k_27[] = "dns_shutdown";
static PyObject *__pyx_kp_27;
static char __pyx_k_28[] = "dns_resolve_ipv4";
static PyObject *__pyx_kp_28;
static char __pyx_k_29[] = "dns_resolve_ipv6";
static PyObject *__pyx_kp_29;
static char __pyx_k_30[] = "dns_resolve_reverse";
static PyObject *__pyx_kp_30;
static char __pyx_k_31[] = "dns_resolve_reverse_ipv6";
static PyObject *__pyx_kp_31;
static char __pyx_k_32[] = "dns_shutdown";
static PyObject *__pyx_kp_32;
static char __pyx_k_DNS_ERR_NONE[] = "DNS_ERR_NONE";
static PyObject *__pyx_kp_DNS_ERR_NONE;
static char __pyx_k_DNS_ERR_FORMAT[] = "DNS_ERR_FORMAT";
static PyObject *__pyx_kp_DNS_ERR_FORMAT;
static char __pyx_k_33[] = "DNS_ERR_SERVERFAILED";
static PyObject *__pyx_kp_33;
static char __pyx_k_DNS_ERR_NOTEXIST[] = "DNS_ERR_NOTEXIST";
static PyObject *__pyx_kp_DNS_ERR_NOTEXIST;
static char __pyx_k_DNS_ERR_NOTIMPL[] = "DNS_ERR_NOTIMPL";
static PyObject *__pyx_kp_DNS_ERR_NOTIMPL;
static char __pyx_k_DNS_ERR_REFUSED[] = "DNS_ERR_REFUSED";
static PyObject *__pyx_kp_DNS_ERR_REFUSED;
static char __pyx_k_DNS_ERR_TRUNCATED[] = "DNS_ERR_TRUNCATED";
static PyObject *__pyx_kp_DNS_ERR_TRUNCATED;
static char __pyx_k_DNS_ERR_UNKNOWN[] = "DNS_ERR_UNKNOWN";
static PyObject *__pyx_kp_DNS_ERR_UNKNOWN;
static char __pyx_k_DNS_ERR_TIMEOUT[] = "DNS_ERR_TIMEOUT";
static PyObject *__pyx_kp_DNS_ERR_TIMEOUT;
static char __pyx_k_DNS_ERR_SHUTDOWN[] = "DNS_ERR_SHUTDOWN";
static PyObject *__pyx_kp_DNS_ERR_SHUTDOWN;
static char __pyx_k_34[] = "DNS_IPv4_A";
static PyObject *__pyx_kp_34;
static char __pyx_k_DNS_PTR[] = "DNS_PTR";
static PyObject *__pyx_kp_DNS_PTR;
static char __pyx_k_35[] = "DNS_IPv6_AAAA";
static PyObject *__pyx_kp_35;
static char __pyx_k_DNS_QUERY_NO_SEARCH[] = "DNS_QUERY_NO_SEARCH";
static PyObject *__pyx_kp_DNS_QUERY_NO_SEARCH;
static char __pyx_k_init[] = "init";
static PyObject *__pyx_kp_init;
static char __pyx_k_get_version[] = "get_version";
static PyObject *__pyx_kp_get_version;
static char __pyx_k_get_header_version[] = "get_header_version";
static PyObject *__pyx_kp_get_header_version;
static char __pyx_k_warnings[] = "warnings";
static PyObject *__pyx_kp_warnings;
static char __pyx_k_msg[] = "msg";
static PyObject *__pyx_kp_msg;
static char __pyx_k_warn[] = "warn";
static PyObject *__pyx_kp_warn;
static char __pyx_k_UserWarning[] = "UserWarning";
static PyObject *__pyx_kp_UserWarning;
static char __pyx_k_stacklevel[] = "stacklevel";
static PyObject *__pyx_kp_stacklevel;
static char __pyx_k_37[] = "buffer";
static PyObject *__pyx_kp_37;
static char __pyx_k_38[] = "http_request";
static PyObject *__pyx_kp_38;
static char __pyx_k_39[] = "http_connection";
static PyObject *__pyx_kp_39;
static char __pyx_k_40[] = "http";
static PyObject *__pyx_kp_40;
static char __pyx_k_EVHTTP_REQUEST[] = "EVHTTP_REQUEST";
static PyObject *__pyx_kp_EVHTTP_REQUEST;
static char __pyx_k_EVHTTP_RESPONSE[] = "EVHTTP_RESPONSE";
static PyObject *__pyx_kp_EVHTTP_RESPONSE;
static char __pyx_k_EVHTTP_REQ_GET[] = "EVHTTP_REQ_GET";
static PyObject *__pyx_kp_EVHTTP_REQ_GET;
static char __pyx_k_EVHTTP_REQ_POST[] = "EVHTTP_REQ_POST";
static PyObject *__pyx_kp_EVHTTP_REQ_POST;
static char __pyx_k_EVHTTP_REQ_HEAD[] = "EVHTTP_REQ_HEAD";
static PyObject *__pyx_kp_EVHTTP_REQ_HEAD;
static char __pyx_k_EVHTTP_REQ_PUT[] = "EVHTTP_REQ_PUT";
static PyObject *__pyx_kp_EVHTTP_REQ_PUT;
static char __pyx_k_EVHTTP_REQ_DELETE[] = "EVHTTP_REQ_DELETE";
static PyObject *__pyx_kp_EVHTTP_REQ_DELETE;
static char __pyx_k_41[] = "GET";
static PyObject *__pyx_kp_41;
static char __pyx_k_42[] = "POST";
static PyObject *__pyx_kp_42;
static char __pyx_k_43[] = "HEAD";
static PyObject *__pyx_kp_43;
static char __pyx_k_44[] = "PUT";
static PyObject *__pyx_kp_44;
static char __pyx_k_45[] = "DELETE";
static PyObject *__pyx_kp_45;
static char __pyx_k_46[] = "HTTP_method2name";
static PyObject *__pyx_kp_46;
static char __pyx_k_ObjectDeleted[] = "ObjectDeleted";
static PyObject *__pyx_kp_ObjectDeleted;
static char __pyx_k_AttributeError[] = "AttributeError";
static PyObject *__pyx_kp_AttributeError;
static char __pyx_k_HttpRequestDeleted[] = "HttpRequestDeleted";
static PyObject *__pyx_kp_HttpRequestDeleted;
static char __pyx_k_48[] = "HttpConnectionDeleted";
static PyObject *__pyx_kp_48;
static char __pyx_k_print_exc[] = "print_exc";
static PyObject *__pyx_kp_print_exc;
static char __pyx_k_stderr[] = "stderr";
static PyObject *__pyx_kp_stderr;
static char __pyx_k_write[] = "write";
static PyObject *__pyx_kp_write;
static char __pyx_k_53[] = "TIMEOUT";
static PyObject *__pyx_kp_53;
static char __pyx_k_54[] = "READ";
static PyObject *__pyx_kp_54;
static char __pyx_k_55[] = "WRITE";
static PyObject *__pyx_kp_55;
static char __pyx_k_56[] = "SIGNAL";
static PyObject *__pyx_kp_56;
static char __pyx_k_57[] = "PERSIST";
static PyObject *__pyx_kp_57;
static char __pyx_k_append[] = "append";
static PyObject *__pyx_kp_append;
static char __pyx_k_hex[] = "hex";
static PyObject *__pyx_kp_hex;
static char __pyx_k_join[] = "join";
static PyObject *__pyx_kp_join;
static char __pyx_k_IOError[] = "IOError";
static PyObject *__pyx_kp_IOError;
static char __pyx_k_pending[] = "pending";
static PyObject *__pyx_kp_pending;
static char __pyx_k_events_str[] = "events_str";
static PyObject *__pyx_kp_events_str;
static char __pyx_k___name__[] = "__name__";
static PyObject *__pyx_kp___name__;
static char __pyx_k_id[] = "id";
static PyObject *__pyx_kp_id;
static char __pyx_k_replace[] = "replace";
static PyObject *__pyx_kp_replace;
static char __pyx_k_indent[] = "indent";
static PyObject *__pyx_kp_indent;
static char __pyx_k_NotImplementedError[] = "NotImplementedError";
static PyObject *__pyx_kp_NotImplementedError;
static char __pyx_k_min[] = "min";
static PyObject *__pyx_kp_min;
static char __pyx_k_RuntimeError[] = "RuntimeError";
static PyObject *__pyx_kp_RuntimeError;
static char __pyx_k___iter__[] = "__iter__";
static PyObject *__pyx_kp___iter__;
static char __pyx_k_typestr[] = "typestr";
static PyObject *__pyx_kp_typestr;
static char __pyx_k_uri[] = "uri";
static PyObject *__pyx_kp_uri;
static char __pyx_k_major[] = "major";
static PyObject *__pyx_kp_major;
static char __pyx_k_minor[] = "minor";
static PyObject *__pyx_kp_minor;
static char __pyx_k_remote_host[] = "remote_host";
static PyObject *__pyx_kp_remote_host;
static char __pyx_k_remote_port[] = "remote_port";
static PyObject *__pyx_kp_remote_port;
static char __pyx_k_response_code[] = "response_code";
static PyObject *__pyx_kp_response_code;
static char __pyx_k_input_buffer[] = "input_buffer";
static PyObject *__pyx_kp_input_buffer;
static char __pyx_k_output_buffer[] = "output_buffer";
static PyObject *__pyx_kp_output_buffer;
static char __pyx_k___class__[] = "__class__";
static PyObject *__pyx_kp___class__;
static char __pyx_k_get[] = "get";
static PyObject *__pyx_kp_get;
static char __pyx_k_response_code_line[] = "response_code_line";
static PyObject *__pyx_kp_response_code_line;
static char __pyx_k_TypeError[] = "TypeError";
static PyObject *__pyx_kp_TypeError;
static char __pyx_k_92[] = "_cb_connection_close";
static PyObject *__pyx_kp_92;
static char __pyx_k_peer[] = "peer";
static PyObject *__pyx_kp_peer;
static PyObject *__pyx_kp_6;
static PyObject *__pyx_kp_7;
static PyObject *__pyx_kp_8;
static PyObject *__pyx_kp_9;
static PyObject *__pyx_kp_11;
static PyObject *__pyx_kp_12;
static PyObject *__pyx_kp_36;
static PyObject *__pyx_kp_47;
static PyObject *__pyx_kp_49;
static PyObject *__pyx_builtin_UserWarning;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_hex;
static PyObject *__pyx_builtin_IOError;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_min;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_kp_52;
static char __pyx_k_52[] = "Failed to execute callback for %s\n\n";
static PyObject *__pyx_kp_58;
static char __pyx_k_58[] = "|";
static PyObject *__pyx_kp_59;
static PyObject *__pyx_kp_60;
static PyObject *__pyx_kp_61;
static PyObject *__pyx_kp_62;
static PyObject *__pyx_kp_63;
static char __pyx_k_59[] = " pending";
static char __pyx_k_60[] = "";
static char __pyx_k_61[] = " %s";
static char __pyx_k_62[] = "";
static char __pyx_k_63[] = "<%s at %s%s fd=%s%s flags=0x%x cb=%s arg=%s>";
static PyObject *__pyx_kp_64;
static PyObject *__pyx_kp_65;
static PyObject *__pyx_kp_66;
static PyObject *__pyx_kp_67;
static PyObject *__pyx_kp_68;
static PyObject *__pyx_kp_70;
static PyObject *__pyx_kp_69;
static PyObject *__pyx_kp_71;
static PyObject *__pyx_kp_73;
static PyObject *__pyx_kp_72;
static PyObject *__pyx_kp_74;
static char __pyx_k_64[] = " pending";
static char __pyx_k_65[] = "";
static char __pyx_k_66[] = " %s";
static char __pyx_k_67[] = "";
static char __pyx_k_68[] = "\n";
static char __pyx_k_69[] = "\n";
static char __pyx_k_70[] = " ";
static char __pyx_k_71[] = "\n";
static char __pyx_k_72[] = "\n";
static char __pyx_k_73[] = " ";
static char __pyx_k_74[] = "%s%s fd=%s%s flags=0x%x\n  cb  = %s\n  arg = %s";
static PyObject *__pyx_kp_75;
static char __pyx_k_75[] = "Failed to execute callback for %s\n\n";
static PyObject *__pyx_kp_76;
static PyObject *__pyx_kp_77;
static PyObject *__pyx_kp_78;
static char __pyx_k_76[] = "";
static char __pyx_k_77[] = "evbuffer_pullup(%x, %s) returned NULL";
static char __pyx_k_78[] = "evbuffer_drain(%x, %s) returned %s";
static PyObject *__pyx_kp_79;
static char __pyx_k_79[] = "";
static PyObject *__pyx_kp_80;
static PyObject *__pyx_kp_81;
static PyObject *__pyx_kp_82;
static PyObject *__pyx_kp_83;
static char __pyx_k_80[] = "\"%s %s HTTP/%s.%s\" %s:%s";
static char __pyx_k_81[] = "response=%s";
static char __pyx_k_82[] = "input=%s";
static char __pyx_k_83[] = "output=%s";
static PyObject *__pyx_kp_84;
static PyObject *__pyx_kp_85;
static char __pyx_k_84[] = "<%s %s>";
static char __pyx_k_85[] = "<%s deleted>";
static PyObject *__pyx_kp_86;
static PyObject *__pyx_kp_87;
static char __pyx_k_86[] = "<%s _obj=0x%x %s>";
static char __pyx_k_87[] = "<%s _obj=0x%x>";
static PyObject *__pyx_kp_88;
static char __pyx_k_88[] = "Expected str or buffer: %r";
static PyObject *__pyx_kp_89;
static char __pyx_k_89[] = "Expected str or buffer: %r";
static PyObject *__pyx_kp_90;
static char __pyx_k_90[] = "Internal error in evhttp_add_header";
static PyObject *__pyx_kp_91;
static char __pyx_k_91[] = "Internal error in evhttp_add_header";
static PyObject *__pyx_kp_93;
static char __pyx_k_93[] = "Failed to execute callback for evhttp connection:\n  connection = %s\n server = %s\n\n";
static PyObject *__pyx_kp_94;
static PyObject *__pyx_kp_95;
static char __pyx_k_94[] = "<%s %s>";
static char __pyx_k_95[] = "<%s deleted>";
static PyObject *__pyx_kp_96;
static PyObject *__pyx_kp_97;
static char __pyx_k_96[] = "<%s _obj=0x%x %s>";
static char __pyx_k_97[] = "<%s _obj=0x%x>";
static PyObject *__pyx_kp_98;
static char __pyx_k_98[] = "Failed to execute callback for evhttp request:\n  request = %s\n callback = %s\n\n";
static char __pyx_k_99[] = "<h1>Internal Server Error</h1>";
static char __pyx_k_100[] = "Internal Server Error";
static PyObject *__pyx_kp_101;
static char __pyx_k_101[] = "Cannot bind %s:%s";
static PyObject *__pyx_kp_102;
static char __pyx_k_102[] = "evhttp_accept_socket(%s) returned %s";
static PyObject *__pyx_kp_103;
static char __pyx_k_103[] = "evhttp_start failed";
static PyObject *__pyx_kp_104;
static PyObject *__pyx_kp_105;
static char __pyx_k_104[] = "evhttp_set_cb(%r, %r) returned %s: callback already exists";
static char __pyx_k_105[] = "evhttp_set_cb(%r, %r) returned %s";

/* "/home/denis/work/gevent/gevent/core.pyx":131
 * EV_PERSIST = 0x10
 * 
 * cdef void __event_handler(int fd, short evtype, void *arg) with gil:             # <<<<<<<<<<<<<<
 *     cdef event ev = <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_ev = 0;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  short __pyx_t_8;
  PyGILState_STATE _save = PyGILState_Ensure();
  __Pyx_SetupRefcountContext("__event_handler");

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

  /* "/home/denis/work/gevent/gevent/core.pyx":133
 * cdef void __event_handler(int fd, short evtype, void *arg) with gil:
 *     cdef event ev = <event>arg
 *     try:             # <<<<<<<<<<<<<<
 *         assert ev.fd == fd, (ev.fd, fd)
 *         ev._callback(ev, evtype)
 */
  /*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":134
 *     cdef event ev = <event>arg
 *     try:
 *         assert ev.fd == fd, (ev.fd, fd)             # <<<<<<<<<<<<<<
 *         ev._callback(ev, evtype)
 *     except:
 */
        #ifndef PYREX_WITHOUT_ASSERTIONS
        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_ev), __pyx_kp_fd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = PyInt_FromLong(__pyx_v_fd); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L6_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[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L6_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[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_4)) {
          __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_ev), __pyx_kp_fd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = PyInt_FromLong(__pyx_v_fd); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(((PyObject *)__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_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_3 = 0;
          __pyx_t_2 = 0;
          PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_1));
          __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        }
        #endif

        /* "/home/denis/work/gevent/gevent/core.pyx":135
 *     try:
 *         assert ev.fd == fd, (ev.fd, fd)
 *         ev._callback(ev, 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 = 135; __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 = 135; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __Pyx_INCREF(((PyObject *)__pyx_v_ev));
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_ev));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_ev));
        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_ev->_callback, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __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":136
 *         assert ev.fd == fd, (ev.fd, fd)
 *         ev._callback(ev, 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 = 136; __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":137
 *         ev._callback(ev, evtype)
 *     except:
 *         traceback.print_exc()             # <<<<<<<<<<<<<<
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (ev, ))
 */
        __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_traceback); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_1);
        __pyx_t_5 = PyObject_GetAttr(__pyx_1, __pyx_kp_print_exc); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
        __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "/home/denis/work/gevent/gevent/core.pyx":138
 *     except:
 *         traceback.print_exc()
 *         try:             # <<<<<<<<<<<<<<
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (ev, ))
 *         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":139
 *         traceback.print_exc()
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (ev, ))             # <<<<<<<<<<<<<<
 *         except:
 *             pass
 */
            __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_sys); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_1);
            __pyx_t_6 = PyObject_GetAttr(__pyx_1, __pyx_kp_stderr); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
            __pyx_t_5 = PyObject_GetAttr(__pyx_t_6, __pyx_kp_write); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_6));
            __Pyx_INCREF(((PyObject *)__pyx_v_ev));
            PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_ev));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_ev));
            __pyx_t_7 = PyNumber_Remainder(__pyx_kp_52, ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
            __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_6));
            PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_7);
            __pyx_t_7 = 0;
            __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 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_L23_try_end;
          __pyx_L16_error:;
          __Pyx_XDECREF(__pyx_1); __pyx_1 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "/home/denis/work/gevent/gevent/core.pyx":140
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (ev, ))
 *         except:             # <<<<<<<<<<<<<<
 *             pass
 *     finally:
 */
          /*except:*/ {
            PyErr_Restore(0,0,0);
            goto __pyx_L17_exception_handled;
          }
          __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:;
        }
        __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_XDECREF(__pyx_save_exc_type);
      __Pyx_XDECREF(__pyx_save_exc_value);
      __Pyx_XDECREF(__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_1); __pyx_1 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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":143
 *             pass
 *     finally:
 *         if not event_pending(&ev.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):             # <<<<<<<<<<<<<<
 *             Py_DECREF(ev)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_READ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_1);
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_WRITE); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_2);
    __pyx_t_3 = PyNumber_Or(__pyx_1, __pyx_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_SIGNAL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_1);
    __pyx_t_2 = PyNumber_Or(__pyx_t_3, __pyx_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_TIMEOUT); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_2);
    __pyx_t_3 = PyNumber_Or(__pyx_t_2, __pyx_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_t_8 = __Pyx_PyInt_AsShort(__pyx_t_3); if (unlikely((__pyx_t_8 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = (!event_pending((&__pyx_v_ev->ev), __pyx_t_8, NULL));
    if (__pyx_t_4) {

      /* "/home/denis/work/gevent/gevent/core.pyx":144
 *     finally:
 *         if not event_pending(&ev.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):
 *             Py_DECREF(ev)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      Py_DECREF(((PyObject *)__pyx_v_ev));
      goto __pyx_L25;
    }
    __pyx_L25:;
    goto __pyx_L26;
    __pyx_L24_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_L26:;
    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_1);
  __Pyx_XDECREF(__pyx_2);
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("gevent.core.__event_handler");
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ev);
  __Pyx_FinishRefcountContext();
  PyGILState_Release(_save);
}

/* "/home/denis/work/gevent/gevent/core.pyx":158
 *     cdef object _callback, _arg
 * 
 *     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;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_evtype,&__pyx_kp_handle,&__pyx_kp_callback,&__pyx_kp_arg,0};
  __Pyx_SetupRefcountContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    values[3] = 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_kp_evtype);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_handle);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_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 = 158; __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 = 158; __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 = 158; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[2];
    __pyx_v_arg = values[3];
  } else {
    __pyx_v_arg = 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 = 158; __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 = 158; __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 = 158; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.event.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/core.pyx":159
 * 
 *     def __init__(self, short evtype, int handle, callback, arg=None):
 *         self._callback = callback             # <<<<<<<<<<<<<<
 *         self._arg = arg
 *         cdef void* c_self = <void*>self
 */
  __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":160
 *     def __init__(self, short evtype, int handle, callback, arg=None):
 *         self._callback = callback
 *         self._arg = arg             # <<<<<<<<<<<<<<
 *         cdef void* c_self = <void*>self
 *         if evtype == 0 and not handle:
 */
  __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":161
 *         self._callback = callback
 *         self._arg = arg
 *         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":162
 *         self._arg = arg
 *         cdef void* c_self = <void*>self
 *         if evtype == 0 and not handle:             # <<<<<<<<<<<<<<
 *             evtimer_set(&self.ev, __event_handler, c_self)
 *         else:
 */
  if ((__pyx_v_evtype == 0)) {
    __pyx_t_1 = (!__pyx_v_handle);
  } else {
    __pyx_t_1 = (__pyx_v_evtype == 0);
  }
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":163
 *         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":165
 *             evtimer_set(&self.ev, __event_handler, c_self)
 *         else:
 *             event_set(&self.ev, handle, evtype, __event_handler, c_self)             # <<<<<<<<<<<<<<
 * 
 *     property callback:
 */
    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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":173
 *         """
 * 
 *         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_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":174
 * 
 *         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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":176
 *             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_SetupRefcountContext("__set__");

  /* "/home/denis/work/gevent/gevent/core.pyx":177
 * 
 *         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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":182
 *         """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_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":183
 * 
 *         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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":185
 *             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_SetupRefcountContext("__set__");

  /* "/home/denis/work/gevent/gevent/core.pyx":186
 * 
 *         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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":191
 *         """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_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  short __pyx_t_3;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":192
 * 
 *         def __get__(self):
 *             return event_pending(&self.ev, EV_TIMEOUT|EV_SIGNAL|EV_READ|EV_WRITE, NULL)             # <<<<<<<<<<<<<<
 * 
 *     property fd:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_TIMEOUT); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_SIGNAL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_1 = PyNumber_Or(__pyx_1, __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_READ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_2 = PyNumber_Or(__pyx_t_1, __pyx_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_WRITE); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_1 = PyNumber_Or(__pyx_t_2, __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_AsShort(__pyx_t_1); if (unlikely((__pyx_t_3 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(event_pending((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), __pyx_t_3, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __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_1);
  __Pyx_XDECREF(__pyx_2);
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.event.pending.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":196
 *     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_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":197
 * 
 *         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 = 197; __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":201
 *     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_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":202
 * 
 *         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 = 202; __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":206
 *     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_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  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_SetupRefcountContext("__get__");
  __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":207
 * 
 *         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 = 207; __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":208
 *         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":210
 *             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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_TIMEOUT); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_1);
  __Pyx_GIVEREF(__pyx_1);
  __Pyx_INCREF(__pyx_kp_53);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_53);
  __Pyx_GIVEREF(__pyx_kp_53);
  __pyx_1 = 0;
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_READ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_1);
  __Pyx_GIVEREF(__pyx_1);
  __Pyx_INCREF(__pyx_kp_54);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_54);
  __Pyx_GIVEREF(__pyx_kp_54);
  __pyx_1 = 0;
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_WRITE); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_1);
  __Pyx_GIVEREF(__pyx_1);
  __Pyx_INCREF(__pyx_kp_55);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_kp_55);
  __Pyx_GIVEREF(__pyx_kp_55);
  __pyx_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":211
 *             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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_SIGNAL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_1);
  __Pyx_GIVEREF(__pyx_1);
  __Pyx_INCREF(__pyx_kp_56);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_kp_56);
  __Pyx_GIVEREF(__pyx_kp_56);
  __pyx_1 = 0;
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_PERSIST); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_1);
  __Pyx_GIVEREF(__pyx_1);
  __Pyx_INCREF(__pyx_kp_57);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_kp_57);
  __Pyx_GIVEREF(__pyx_kp_57);
  __pyx_1 = 0;
  __pyx_t_7 = PyTuple_New(5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_7, 2, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_7, 3, ((PyObject *)__pyx_t_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
  PyTuple_SET_ITEM(__pyx_t_7, 4, ((PyObject *)__pyx_t_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  if (likely(((PyObject *)__pyx_t_7) != Py_None)) {
    __pyx_t_2 = 0; __pyx_t_6 = ((PyObject *)__pyx_t_7); __Pyx_INCREF(__pyx_t_6);
  } else {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  for (;;) {

    /* "/home/denis/work/gevent/gevent/core.pyx":210
 *             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 (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
    __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_7); __pyx_t_2++;
    if (PyTuple_CheckExact(__pyx_t_7) && likely(PyTuple_GET_SIZE(__pyx_t_7) == 2)) {
      PyObject* tuple = __pyx_t_7;
      __pyx_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_2);
      __pyx_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_v_event);
      __pyx_v_event = __pyx_2;
      __pyx_2 = 0;
      __Pyx_DECREF(__pyx_v_txt);
      __pyx_v_txt = __pyx_3;
      __pyx_3 = 0;
    } else {
      __pyx_1 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_2);
      __pyx_3 = __Pyx_UnpackItem(__pyx_1, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_3);
      if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_DECREF(__pyx_v_event);
      __pyx_v_event = __pyx_2;
      __pyx_2 = 0;
      __Pyx_DECREF(__pyx_v_txt);
      __pyx_v_txt = __pyx_3;
      __pyx_3 = 0;
    }

    /* "/home/denis/work/gevent/gevent/core.pyx":212
 *             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 = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_event = __pyx_t_8;

    /* "/home/denis/work/gevent/gevent/core.pyx":213
 *                                  (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":214
 *                 c_event = event
 *                 if events & c_event:
 *                     result.append(txt)             # <<<<<<<<<<<<<<
 *                     c_event = c_event ^ 0xffffff
 *                     events = events & c_event
 */
      __pyx_t_7 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_v_txt); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "/home/denis/work/gevent/gevent/core.pyx":215
 *                 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":216
 *                     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_6); __pyx_t_6 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":217
 *                     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":218
 *                     events = events & c_event
 *             if events:
 *                 result.append(hex(events))             # <<<<<<<<<<<<<<
 *             return '|'.join(result)
 * 
 */
    __pyx_t_6 = PyInt_FromLong(__pyx_v_events); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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_builtin_hex, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/denis/work/gevent/gevent/core.pyx":219
 *             if events:
 *                 result.append(hex(events))
 *             return '|'.join(result)             # <<<<<<<<<<<<<<
 * 
 *     property flags:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = PyObject_GetAttr(__pyx_kp_58, __pyx_kp_join); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  __Pyx_INCREF(__pyx_v_result);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_result);
  __Pyx_GIVEREF(__pyx_v_result);
  __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(((PyObject *)__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_1);
  __Pyx_XDECREF(__pyx_2);
  __Pyx_XDECREF(__pyx_3);
  __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_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":223
 *     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_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/core.pyx":224
 * 
 *         def __get__(self):
 *             return self.ev.ev_flags             # <<<<<<<<<<<<<<
 * 
 *     def add(self, timeout=-1):
 */
  __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 = 224; __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":226
 *             return self.ev.ev_flags
 * 
 *     def add(self, timeout=-1):             # <<<<<<<<<<<<<<
 *         """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_r = NULL;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  short __pyx_t_3;
  int __pyx_t_4;
  double __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_timeout,0};
  __Pyx_SetupRefcountContext("add");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    values[0] = __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_kp_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 = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_timeout = values[0];
  } else {
    __pyx_v_timeout = __pyx_int_neg_1;
    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 = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.event.add");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/core.pyx":232
 *         cdef double c_timeout
 *         cdef int result
 *         if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):             # <<<<<<<<<<<<<<
 *             Py_INCREF(self)
 *         if timeout >= 0.0:
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_READ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_WRITE); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_1 = PyNumber_Or(__pyx_1, __pyx_2); 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_DECREF(__pyx_1); __pyx_1 = 0;
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_SIGNAL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_2 = PyNumber_Or(__pyx_t_1, __pyx_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_TIMEOUT); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_1 = PyNumber_Or(__pyx_t_2, __pyx_2); 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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_AsShort(__pyx_t_1); if (unlikely((__pyx_t_3 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = (!event_pending((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), __pyx_t_3, NULL));
  if (__pyx_t_4) {

    /* "/home/denis/work/gevent/gevent/core.pyx":233
 *         cdef int result
 *         if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):
 *             Py_INCREF(self)             # <<<<<<<<<<<<<<
 *         if timeout >= 0.0:
 *             c_timeout = <double>timeout
 */
    Py_INCREF(__pyx_v_self);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/core.pyx":234
 *         if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):
 *             Py_INCREF(self)
 *         if timeout >= 0.0:             # <<<<<<<<<<<<<<
 *             c_timeout = <double>timeout
 *             tv.tv_sec = <long>c_timeout
 */
  __pyx_t_1 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_timeout, __pyx_t_1, Py_GE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "/home/denis/work/gevent/gevent/core.pyx":235
 *             Py_INCREF(self)
 *         if timeout >= 0.0:
 *             c_timeout = <double>timeout             # <<<<<<<<<<<<<<
 *             tv.tv_sec = <long>c_timeout
 *             tv.tv_usec = <unsigned int>((c_timeout - <double>tv.tv_sec) * 1000000.0)
 */
    __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_v_timeout); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_timeout = ((double)__pyx_t_5);

    /* "/home/denis/work/gevent/gevent/core.pyx":236
 *         if timeout >= 0.0:
 *             c_timeout = <double>timeout
 *             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":237
 *             c_timeout = <double>timeout
 *             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)
 *         else:
 */
    __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":238
 *             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)             # <<<<<<<<<<<<<<
 *         else:
 *             result = event_add(&self.ev, NULL)
 */
    __pyx_v_result = event_add((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), (&__pyx_v_tv));
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/core.pyx":240
 *             result = event_add(&self.ev, &tv)
 *         else:
 *             result = event_add(&self.ev, NULL)             # <<<<<<<<<<<<<<
 *         if result < 0:
 *             raise IOError(errno, strerror(errno))
 */
    __pyx_v_result = event_add((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), NULL);
  }
  __pyx_L7:;

  /* "/home/denis/work/gevent/gevent/core.pyx":241
 *         else:
 *             result = event_add(&self.ev, NULL)
 *         if result < 0:             # <<<<<<<<<<<<<<
 *             raise IOError(errno, strerror(errno))
 * 
 */
  __pyx_t_4 = (__pyx_v_result < 0);
  if (__pyx_t_4) {

    /* "/home/denis/work/gevent/gevent/core.pyx":242
 *             result = event_add(&self.ev, NULL)
 *         if result < 0:
 *             raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 * 
 *     def cancel(self):
 */
    __pyx_t_2 = PyInt_FromLong(errno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __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 = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __Pyx_XDECREF(__pyx_2);
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("gevent.core.event.add");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":244
 *             raise IOError(errno, strerror(errno))
 * 
 *     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;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  short __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_SetupRefcountContext("cancel");

  /* "/home/denis/work/gevent/gevent/core.pyx":247
 *         """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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_TIMEOUT); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_SIGNAL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_1 = PyNumber_Or(__pyx_1, __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_READ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_2 = PyNumber_Or(__pyx_t_1, __pyx_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_WRITE); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_1 = PyNumber_Or(__pyx_t_2, __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_AsShort(__pyx_t_1); if (unlikely((__pyx_t_3 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = event_pending((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev), __pyx_t_3, NULL);
  if (__pyx_t_4) {

    /* "/home/denis/work/gevent/gevent/core.pyx":248
 *         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:
 *                 raise IOError(errno, strerror(errno))
 */
    __pyx_v_result = event_del((&((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->ev));

    /* "/home/denis/work/gevent/gevent/core.pyx":249
 *         if event_pending(&self.ev, EV_TIMEOUT|EV_SIGNAL|EV_READ|EV_WRITE, NULL):
 *             result = event_del(&self.ev)
 *             if result < 0:             # <<<<<<<<<<<<<<
 *                 raise IOError(errno, strerror(errno))
 *             Py_DECREF(self)
 */
    __pyx_t_5 = (__pyx_v_result < 0);
    if (__pyx_t_5) {

      /* "/home/denis/work/gevent/gevent/core.pyx":250
 *             result = event_del(&self.ev)
 *             if result < 0:
 *                 raise IOError(errno, strerror(errno))             # <<<<<<<<<<<<<<
 *             Py_DECREF(self)
 * 
 */
      __pyx_t_1 = PyInt_FromLong(errno); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyBytes_FromString(strerror(errno)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/denis/work/gevent/gevent/core.pyx":251
 *             if result < 0:
 *                 raise IOError(errno, strerror(errno))
 *             Py_DECREF(self)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
    Py_DECREF(__pyx_v_self);
    goto __pyx_L5;
  }
  __pyx_L5:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __Pyx_XDECREF(__pyx_2);
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("gevent.core.event.cancel");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":253
 *             Py_DECREF(self)
 * 
 *     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_event_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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_SetupRefcountContext("__repr__");
  __pyx_v_pending = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_event_str = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/core.pyx":254
 * 
 *     def __repr__(self):
 *         if self.pending:             # <<<<<<<<<<<<<<
 *             pending = ' pending'
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_pending); 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_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __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":255
 *     def __repr__(self):
 *         if self.pending:
 *             pending = ' pending'             # <<<<<<<<<<<<<<
 *         else:
 *             pending = ''
 */
    __Pyx_INCREF(__pyx_kp_59);
    __Pyx_DECREF(__pyx_v_pending);
    __pyx_v_pending = __pyx_kp_59;
    goto __pyx_L5;
  }
  /*else*/ {

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

  /* "/home/denis/work/gevent/gevent/core.pyx":258
 *         else:
 *             pending = ''
 *         if self.events_str:             # <<<<<<<<<<<<<<
 *             event_str = ' %s' % self.events_str
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_events_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __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 = 258; __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":259
 *             pending = ''
 *         if self.events_str:
 *             event_str = ' %s' % self.events_str             # <<<<<<<<<<<<<<
 *         else:
 *             event_str = ''
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_events_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Remainder(__pyx_kp_61, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __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_event_str);
    __pyx_v_event_str = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/core.pyx":261
 *             event_str = ' %s' % self.events_str
 *         else:
 *             event_str = ''             # <<<<<<<<<<<<<<
 *         return '<%s at %s%s fd=%s%s flags=0x%x cb=%s arg=%s>' % \
 *                (type(self).__name__, hex(id(self)), pending, self.fd, self.events_str, self.flags, self._callback, self._arg)
 */
    __Pyx_INCREF(__pyx_kp_62);
    __Pyx_DECREF(__pyx_v_event_str);
    __pyx_v_event_str = __pyx_kp_62;
  }
  __pyx_L6:;

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

  /* "/home/denis/work/gevent/gevent/core.pyx":263
 *             event_str = ''
 *         return '<%s at %s%s fd=%s%s flags=0x%x cb=%s arg=%s>' % \
 *                (type(self).__name__, hex(id(self)), pending, self.fd, self.events_str, self.flags, self._callback, self._arg)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyType_Type)), ((PyObject *)__pyx_t_3), NULL); 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_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_kp___name__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __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 = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__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 = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_fd); 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_5 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_events_str); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_flags); 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);
  __pyx_t_7 = PyTuple_New(8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_pending);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_pending);
  __Pyx_GIVEREF(__pyx_v_pending);
  PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  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_INCREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_callback);
  PyTuple_SET_ITEM(__pyx_t_7, 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_7, 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_6 = 0;
  __pyx_t_6 = PyNumber_Remainder(__pyx_kp_63, ((PyObject *)__pyx_t_7)); 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);
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 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_AddTraceback("gevent.core.event.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_pending);
  __Pyx_DECREF(__pyx_v_event_str);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":265
 *                (type(self).__name__, hex(id(self)), pending, self.fd, self.events_str, self.flags, 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_event_str;
  PyObject *__pyx_v_cb;
  PyObject *__pyx_v_arg;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  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_SetupRefcountContext("__str__");
  __pyx_v_pending = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_event_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":266
 * 
 *     def __str__(self):
 *         if self.pending:             # <<<<<<<<<<<<<<
 *             pending = ' pending'
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_pending); 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_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __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":267
 *     def __str__(self):
 *         if self.pending:
 *             pending = ' pending'             # <<<<<<<<<<<<<<
 *         else:
 *             pending = ''
 */
    __Pyx_INCREF(__pyx_kp_64);
    __Pyx_DECREF(__pyx_v_pending);
    __pyx_v_pending = __pyx_kp_64;
    goto __pyx_L5;
  }
  /*else*/ {

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

  /* "/home/denis/work/gevent/gevent/core.pyx":270
 *         else:
 *             pending = ''
 *         if self.events_str:             # <<<<<<<<<<<<<<
 *             event_str = ' %s' % self.events_str
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_events_str); 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_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __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":271
 *             pending = ''
 *         if self.events_str:
 *             event_str = ' %s' % self.events_str             # <<<<<<<<<<<<<<
 *         else:
 *             event_str = ''
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_events_str); 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_3 = PyNumber_Remainder(__pyx_kp_66, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __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_event_str);
    __pyx_v_event_str = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

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

  /* "/home/denis/work/gevent/gevent/core.pyx":274
 *         else:
 *             event_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=0x%x\n  cb  = %s\n  arg = %s' % \
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_kp_replace); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __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(__pyx_kp_70, __pyx_int_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyNumber_Add(__pyx_kp_69, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __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 = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_kp_68);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_68);
  __Pyx_GIVEREF(__pyx_kp_68);
  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, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__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":275
 *             event_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=0x%x\n  cb  = %s\n  arg = %s' % \
 *                (type(self).__name__, pending, self.fd, self.events_str, self.flags, cb, arg)
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_pformat); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_INCREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  __Pyx_GIVEREF(((struct __pyx_obj_6gevent_4core_event *)__pyx_v_self)->_arg);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_2));
  if (PyDict_SetItem(__pyx_2, __pyx_kp_indent, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_1, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_kp_replace); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Multiply(__pyx_kp_73, __pyx_int_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Add(__pyx_kp_72, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __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 = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_kp_71);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_71);
  __Pyx_GIVEREF(__pyx_kp_71);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_v_arg);
  __pyx_v_arg = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":276
 *         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=0x%x\n  cb  = %s\n  arg = %s' % \             # <<<<<<<<<<<<<<
 *                (type(self).__name__, pending, self.fd, self.events_str, self.flags, cb, arg)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "/home/denis/work/gevent/gevent/core.pyx":277
 *         arg = pformat(self._arg, indent=2).replace('\n', '\n' + ' ' * 8)
 *         return '%s%s fd=%s%s flags=0x%x\n  cb  = %s\n  arg = %s' % \
 *                (type(self).__name__, pending, self.fd, self.events_str, self.flags, cb, arg)             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyType_Type)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_kp___name__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_fd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_events_str); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_flags); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_pending);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_pending);
  __Pyx_GIVEREF(__pyx_v_pending);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_cb);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_v_cb);
  __Pyx_GIVEREF(__pyx_v_cb);
  __Pyx_INCREF(__pyx_v_arg);
  PyTuple_SET_ITEM(__pyx_t_6, 6, __pyx_v_arg);
  __Pyx_GIVEREF(__pyx_v_arg);
  __pyx_t_3 = 0;
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Remainder(__pyx_kp_74, ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(((PyObject *)__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_1);
  __Pyx_XDECREF(__pyx_2);
  __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.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_pending);
  __Pyx_DECREF(__pyx_v_event_str);
  __Pyx_DECREF(__pyx_v_cb);
  __Pyx_DECREF(__pyx_v_arg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":279
 *                (type(self).__name__, pending, self.fd, self.events_str, self.flags, 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_SetupRefcountContext("__enter__");

  /* "/home/denis/work/gevent/gevent/core.pyx":280
 * 
 *     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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":282
 *         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_SetupRefcountContext("__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":283
 * 
 *     def __exit__(self, *exit_args):
 *         self.cancel()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_cancel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __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 = 283; __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":289
 *     """Create a new scheduled event with evtype=EV_READ"""
 * 
 *     def __init__(self, int handle, callback, timeout=-1, arg=None):             # <<<<<<<<<<<<<<
 *         event.__init__(self, EV_READ, handle, callback, arg)
 *         self.add(timeout)
 */

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;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_handle,&__pyx_kp_callback,&__pyx_kp_timeout,&__pyx_kp_arg,0};
  __Pyx_SetupRefcountContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    values[2] = __pyx_int_neg_1;
    values[3] = 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_kp_handle);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_timeout);
        if (unlikely(value)) { values[2] = value; kw_args--; }
      }
      case  3:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_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 = 289; __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 = 289; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[1];
    __pyx_v_timeout = values[2];
    __pyx_v_arg = values[3];
  } else {
    __pyx_v_timeout = __pyx_int_neg_1;
    __pyx_v_arg = Py_None;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      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 = 289; __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, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.read_event.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/core.pyx":290
 * 
 *     def __init__(self, int handle, callback, timeout=-1, arg=None):
 *         event.__init__(self, EV_READ, handle, callback, arg)             # <<<<<<<<<<<<<<
 *         self.add(timeout)
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_event)), __pyx_kp___init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_READ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_handle); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_1);
  __Pyx_GIVEREF(__pyx_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_arg);
  PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_arg);
  __Pyx_GIVEREF(__pyx_v_arg);
  __pyx_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":291
 *     def __init__(self, int handle, callback, timeout=-1, arg=None):
 *         event.__init__(self, EV_READ, handle, callback, arg)
 *         self.add(timeout)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_add); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __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 = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_timeout);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_timeout);
  __Pyx_GIVEREF(__pyx_v_timeout);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.read_event.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":297
 *     """Create a new scheduled event with evtype=EV_WRITE"""
 * 
 *     def __init__(self, int handle, callback, timeout=-1, arg=None):             # <<<<<<<<<<<<<<
 *         event.__init__(self, EV_WRITE, handle, callback, arg)
 *         self.add(timeout)
 */

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;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_handle,&__pyx_kp_callback,&__pyx_kp_timeout,&__pyx_kp_arg,0};
  __Pyx_SetupRefcountContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    values[2] = __pyx_int_neg_1;
    values[3] = 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_kp_handle);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_timeout);
        if (unlikely(value)) { values[2] = value; kw_args--; }
      }
      case  3:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_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 = 297; __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 = 297; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_callback = values[1];
    __pyx_v_timeout = values[2];
    __pyx_v_arg = values[3];
  } else {
    __pyx_v_timeout = __pyx_int_neg_1;
    __pyx_v_arg = Py_None;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      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 = 297; __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, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.write_event.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/core.pyx":298
 * 
 *     def __init__(self, int handle, callback, timeout=-1, arg=None):
 *         event.__init__(self, EV_WRITE, handle, callback, arg)             # <<<<<<<<<<<<<<
 *         self.add(timeout)
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_event)), __pyx_kp___init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_WRITE); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_handle); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_1);
  __Pyx_GIVEREF(__pyx_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_arg);
  PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_arg);
  __Pyx_GIVEREF(__pyx_v_arg);
  __pyx_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":299
 *     def __init__(self, int handle, callback, timeout=-1, arg=None):
 *         event.__init__(self, EV_WRITE, handle, callback, arg)
 *         self.add(timeout)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_add); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __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 = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_timeout);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_timeout);
  __Pyx_GIVEREF(__pyx_v_timeout);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.write_event.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":302
 * 
 * 
 * cdef void __simple_handler(int fd, short evtype, void *arg) with gil:             # <<<<<<<<<<<<<<
 *     cdef event ev = <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_ev = 0;
  PyObject *__pyx_v_args;
  PyObject *__pyx_v_kwargs;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 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;
  short __pyx_t_7;
  int __pyx_t_8;
  PyGILState_STATE _save = PyGILState_Ensure();
  __Pyx_SetupRefcountContext("__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":303
 * 
 * cdef void __simple_handler(int fd, short evtype, void *arg) with gil:
 *     cdef event ev = <event>arg             # <<<<<<<<<<<<<<
 *     try:
 *         args, kwargs = ev._arg
 */
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6gevent_4core_event *)__pyx_v_arg)));
  __pyx_v_ev = ((struct __pyx_obj_6gevent_4core_event *)__pyx_v_arg);

  /* "/home/denis/work/gevent/gevent/core.pyx":304
 * cdef void __simple_handler(int fd, short evtype, void *arg) with gil:
 *     cdef event ev = <event>arg
 *     try:             # <<<<<<<<<<<<<<
 *         args, kwargs = ev._arg
 *         ev._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":305
 *     cdef event ev = <event>arg
 *     try:
 *         args, kwargs = ev._arg             # <<<<<<<<<<<<<<
 *         ev._callback(*args, **kwargs)
 *     except:
 */
        if (PyTuple_CheckExact(__pyx_v_ev->_arg) && likely(PyTuple_GET_SIZE(__pyx_v_ev->_arg) == 2)) {
          PyObject* tuple = __pyx_v_ev->_arg;
          __pyx_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_2);
          __pyx_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_3);
          __Pyx_DECREF(__pyx_v_args);
          __pyx_v_args = __pyx_2;
          __pyx_2 = 0;
          __Pyx_DECREF(__pyx_v_kwargs);
          __pyx_v_kwargs = __pyx_3;
          __pyx_3 = 0;
        } else {
          __pyx_1 = PyObject_GetIter(__pyx_v_ev->_arg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_1);
          __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_2);
          __pyx_3 = __Pyx_UnpackItem(__pyx_1, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_3);
          if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
          __Pyx_DECREF(__pyx_v_args);
          __pyx_v_args = __pyx_2;
          __pyx_2 = 0;
          __Pyx_DECREF(__pyx_v_kwargs);
          __pyx_v_kwargs = __pyx_3;
          __pyx_3 = 0;
        }

        /* "/home/denis/work/gevent/gevent/core.pyx":306
 *     try:
 *         args, kwargs = ev._arg
 *         ev._callback(*args, **kwargs)             # <<<<<<<<<<<<<<
 *     except:
 *         traceback.print_exc()
 */
        __pyx_1 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_1));
        __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_v_ev->_callback, ((PyObject *)__pyx_1), __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 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_2); __pyx_2 = 0;
      __Pyx_XDECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_XDECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "/home/denis/work/gevent/gevent/core.pyx":307
 *         args, kwargs = ev._arg
 *         ev._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 = 307; __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":308
 *         ev._callback(*args, **kwargs)
 *     except:
 *         traceback.print_exc()             # <<<<<<<<<<<<<<
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (ev, ))
 */
        __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_traceback); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_2);
        __pyx_t_4 = PyObject_GetAttr(__pyx_2, __pyx_kp_print_exc); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L8_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;

        /* "/home/denis/work/gevent/gevent/core.pyx":309
 *     except:
 *         traceback.print_exc()
 *         try:             # <<<<<<<<<<<<<<
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (ev, ))
 *         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":310
 *         traceback.print_exc()
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (ev, ))             # <<<<<<<<<<<<<<
 *         except:
 *             pass
 */
            __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_sys); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_3);
            __pyx_t_5 = PyObject_GetAttr(__pyx_3, __pyx_kp_stderr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_3); __pyx_3 = 0;
            __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_kp_write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __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 = 310; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_5));
            __Pyx_INCREF(((PyObject *)__pyx_v_ev));
            PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_ev));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_ev));
            __pyx_t_6 = PyNumber_Remainder(__pyx_kp_75, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(((PyObject *)__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 = 310; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(((PyObject *)__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, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __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;
          }
          __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_1); __pyx_1 = 0;
          __Pyx_XDECREF(__pyx_2); __pyx_2 = 0;
          __Pyx_XDECREF(__pyx_3); __pyx_3 = 0;
          __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":311
 *         try:
 *             sys.stderr.write('Failed to execute callback for %s\n\n' % (ev, ))
 *         except:             # <<<<<<<<<<<<<<
 *             pass
 *     finally:
 */
          /*except:*/ {
            PyErr_Restore(0,0,0);
            goto __pyx_L17_exception_handled;
          }
          __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:;
        }
        __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_XDECREF(__pyx_save_exc_type);
      __Pyx_XDECREF(__pyx_save_exc_value);
      __Pyx_XDECREF(__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_1); __pyx_1 = 0;
      __Pyx_XDECREF(__pyx_2); __pyx_2 = 0;
      __Pyx_XDECREF(__pyx_3); __pyx_3 = 0;
      __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;
      __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":314
 *             pass
 *     finally:
 *         if not event_pending(&ev.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):             # <<<<<<<<<<<<<<
 *             Py_DECREF(ev)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_READ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_1);
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_WRITE); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_2);
    __pyx_t_3 = PyNumber_Or(__pyx_1, __pyx_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_SIGNAL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_3);
    __pyx_t_2 = PyNumber_Or(__pyx_t_3, __pyx_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_TIMEOUT); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_1);
    __pyx_t_3 = PyNumber_Or(__pyx_t_2, __pyx_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_t_7 = __Pyx_PyInt_AsShort(__pyx_t_3); if (unlikely((__pyx_t_7 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = (!event_pending((&__pyx_v_ev->ev), __pyx_t_7, NULL));
    if (__pyx_t_8) {

      /* "/home/denis/work/gevent/gevent/core.pyx":315
 *     finally:
 *         if not event_pending(&ev.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):
 *             Py_DECREF(ev)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      Py_DECREF(((PyObject *)__pyx_v_ev));
      goto __pyx_L25;
    }
    __pyx_L25:;
    goto __pyx_L26;
    __pyx_L24_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_L26:;
    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_1);
  __Pyx_XDECREF(__pyx_2);
  __Pyx_XDECREF(__pyx_3);
  __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_WriteUnraisable("gevent.core.__simple_handler");
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ev);
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_FinishRefcountContext();
  PyGILState_Release(_save);
}

/* "/home/denis/work/gevent/gevent/core.pyx":321
 *     """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_kp_seconds,&__pyx_kp_callback,0};
  __Pyx_SetupRefcountContext("__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_kp_seconds);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __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 = 321; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_seconds = __pyx_PyFloat_AsDouble(values[0]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __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(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __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 = 321; __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":322
 * 
 *     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":323
 *     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 = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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(((PyObject *)__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 = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":324
 *         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":325
 *         self._arg = (args, kwargs)
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 *         self.add(seconds)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_add); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __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 = 325; __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 = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":331
 *     """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_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;
  short __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_signalnum,&__pyx_kp_callback,0};
  __Pyx_SetupRefcountContext("__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_kp_signalnum);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __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 = 331; __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 = 331; __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 = 331; __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 = 331; __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":332
 * 
 *     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":333
 *     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(-1)
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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(((PyObject *)__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 = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":334
 *         self._callback = callback
 *         self._arg = (args, kwargs)
 *         event_set(&self.ev, signalnum, EV_SIGNAL|EV_PERSIST, __simple_handler, <void*>self)             # <<<<<<<<<<<<<<
 *         self.add(-1)
 * 
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_SIGNAL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_PERSIST); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_1 = PyNumber_Or(__pyx_1, __pyx_2); 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_DECREF(__pyx_1); __pyx_1 = 0;
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_AsShort(__pyx_t_1); if (unlikely((__pyx_t_2 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  event_set((&((struct __pyx_obj_6gevent_4core_signal *)__pyx_v_self)->__pyx_base.ev), __pyx_v_signalnum, __pyx_t_2, __pyx_f_6gevent_4core___simple_handler, ((void *)__pyx_v_self));

  /* "/home/denis/work/gevent/gevent/core.pyx":335
 *         self._arg = (args, kwargs)
 *         event_set(&self.ev, signalnum, EV_SIGNAL|EV_PERSIST, __simple_handler, <void*>self)
 *         self.add(-1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_add); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_int_neg_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __Pyx_XDECREF(__pyx_2);
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.signal.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":341
 *     """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_1 = 0;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_callback,0};
  __Pyx_SetupRefcountContext("__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_kp_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 = 341; __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 = 341; __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":342
 * 
 *     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":343
 *     def __init__(self, callback, *args, **kwargs):
 *         self._callback = callback
 *         self._arg = (args, kwargs)             # <<<<<<<<<<<<<<
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 *         Py_INCREF(self)
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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(((PyObject *)__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 = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":344
 *         self._callback = callback
 *         self._arg = (args, kwargs)
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)             # <<<<<<<<<<<<<<
 *         Py_INCREF(self)
 *         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":345
 *         self._arg = (args, kwargs)
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 *         Py_INCREF(self)             # <<<<<<<<<<<<<<
 *         event_active(&self.ev, EV_TIMEOUT, 1)
 * 
 */
  Py_INCREF(__pyx_v_self);

  /* "/home/denis/work/gevent/gevent/core.pyx":346
 *         evtimer_set(&self.ev, __simple_handler, <void*>self)
 *         Py_INCREF(self)
 *         event_active(&self.ev, EV_TIMEOUT, 1)             # <<<<<<<<<<<<<<
 * 
 *     def add(self, timeout=-1):
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_EV_TIMEOUT); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  event_active((&((struct __pyx_obj_6gevent_4core_active_event *)__pyx_v_self)->__pyx_base.ev), __pyx_t_2, 1);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":348
 *         event_active(&self.ev, EV_TIMEOUT, 1)
 * 
 *     def add(self, timeout=-1):             # <<<<<<<<<<<<<<
 *         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_kp_timeout,0};
  __Pyx_SetupRefcountContext("add");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    values[0] = __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_kp_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 = 348; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_timeout = values[0];
  } else {
    __pyx_v_timeout = __pyx_int_neg_1;
    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 = 348; __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":349
 * 
 *     def add(self, timeout=-1):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":352
 * 
 * 
 * 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_SetupRefcountContext("init");
  __pyx_self = __pyx_self;

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

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

/* "/home/denis/work/gevent/gevent/core.pyx":357
 * 
 * 
 * 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_SetupRefcountContext("dispatch");
  __pyx_self = __pyx_self;

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

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

  /* "/home/denis/work/gevent/gevent/core.pyx":365
 *     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":366
 *         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 = 366; __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 = 366; __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 = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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_IOError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__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 = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/denis/work/gevent/gevent/core.pyx":367
 *     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 = 367; __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":370
 * 
 * 
 * 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_kp_nonblock,0};
  __Pyx_SetupRefcountContext("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_25;
    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_kp_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 = 370; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_nonblock = values[0];
  } else {
    __pyx_v_nonblock = __pyx_k_25;
    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 = 370; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.loop");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/core.pyx":376
 *     """
 *     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":377
 *     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 = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/core.pyx":378
 *     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":379
 *     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":380
 *         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:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/denis/work/gevent/gevent/core.pyx":381
 *     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":382
 *         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 = 382; __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 = 382; __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 = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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_IOError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__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 = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/denis/work/gevent/gevent/core.pyx":383
 *     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 = 383; __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_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":386
 * 
 * 
 * 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_SetupRefcountContext("get_version");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/core.pyx":388
 * 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 = 388; __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.get_version");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":391
 * 
 * 
 * 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_SetupRefcountContext("get_method");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/core.pyx":393
 * 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 = 393; __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.get_method");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":404
 * # _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_SetupRefcountContext("get_header_version");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/core.pyx":406
 * 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":407
 *     """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 = 407; __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":408
 *     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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/core.pyx":415
 * # 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_SetupRefcountContext("reinit");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/core.pyx":417
 * 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":418
 *     """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 = 418; __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":419
 *     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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":60
 * DNS_QUERY_NO_SEARCH	= 1
 * 
 * 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_SetupRefcountContext("dns_init");
  __pyx_self = __pyx_self;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":62
 * def dns_init():
 *     """Initialize async DNS resolver."""
 *     evdns_init()             # <<<<<<<<<<<<<<
 * 
 * cdef void __evdns_callback(int result, char t, int count, int ttl,
 */
  evdns_init();

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

/* "/home/denis/work/gevent/gevent/evdns.pxi":64
 *     evdns_init()
 * 
 * cdef void __evdns_callback(int result, char t, int count, int ttl,             # <<<<<<<<<<<<<<
 *                      void *addrs, void *arg) with gil:
 *     cdef int i
 */

static  void __pyx_f_6gevent_4core___evdns_callback(int __pyx_v_result, char __pyx_v_t, int __pyx_v_count, int __pyx_v_ttl, void *__pyx_v_addrs, void *__pyx_v_arg) {
  int __pyx_v_i;
  char __pyx_v_str[INET6_ADDRSTRLEN];
  PyObject *__pyx_v_ctx;
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_args;
  PyObject *__pyx_v_x;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyGILState_STATE _save = PyGILState_Ensure();
  __Pyx_SetupRefcountContext("__evdns_callback");
  __pyx_v_ctx = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_callback = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_args = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":68
 *     cdef int i
 *     cdef char str[INET6_ADDRSTRLEN]
 *     ctx = <tuple>(arg)             # <<<<<<<<<<<<<<
 *     (callback, args) = ctx
 *     Py_DECREF(ctx)
 */
  __Pyx_INCREF(((PyObject *)((PyObject *)__pyx_v_arg)));
  __Pyx_DECREF(__pyx_v_ctx);
  __pyx_v_ctx = ((PyObject *)__pyx_v_arg);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":69
 *     cdef char str[INET6_ADDRSTRLEN]
 *     ctx = <tuple>(arg)
 *     (callback, args) = ctx             # <<<<<<<<<<<<<<
 *     Py_DECREF(ctx)
 * 
 */
  if (PyTuple_CheckExact(__pyx_v_ctx) && likely(PyTuple_GET_SIZE(__pyx_v_ctx) == 2)) {
    PyObject* tuple = __pyx_v_ctx;
    __pyx_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_2);
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_3);
    __Pyx_DECREF(__pyx_v_callback);
    __pyx_v_callback = __pyx_2;
    __pyx_2 = 0;
    __Pyx_DECREF(__pyx_v_args);
    __pyx_v_args = __pyx_3;
    __pyx_3 = 0;
  } else {
    __pyx_1 = PyObject_GetIter(__pyx_v_ctx); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_2);
    __pyx_3 = __Pyx_UnpackItem(__pyx_1, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_3);
    if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_DECREF(__pyx_v_callback);
    __pyx_v_callback = __pyx_2;
    __pyx_2 = 0;
    __Pyx_DECREF(__pyx_v_args);
    __pyx_v_args = __pyx_3;
    __pyx_3 = 0;
  }

  /* "/home/denis/work/gevent/gevent/evdns.pxi":70
 *     ctx = <tuple>(arg)
 *     (callback, args) = ctx
 *     Py_DECREF(ctx)             # <<<<<<<<<<<<<<
 * 
 *     if t == DNS_IPv4_A:
 */
  Py_DECREF(__pyx_v_ctx);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":72
 *     Py_DECREF(ctx)
 * 
 *     if t == DNS_IPv4_A:             # <<<<<<<<<<<<<<
 *         x = []
 *         for i from 0 <= i < count:
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_t); 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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_34); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_1, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":73
 * 
 *     if t == DNS_IPv4_A:
 *         x = []             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < count:
 *             x.append(PyString_FromString(inet_ntoa((<in_addr *>addrs)[i])))
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_v_x);
    __pyx_v_x = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "/home/denis/work/gevent/gevent/evdns.pxi":74
 *     if t == DNS_IPv4_A:
 *         x = []
 *         for i from 0 <= i < count:             # <<<<<<<<<<<<<<
 *             x.append(PyString_FromString(inet_ntoa((<in_addr *>addrs)[i])))
 *     elif t == DNS_IPv6_AAAA:
 */
    __pyx_t_4 = __pyx_v_count;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

      /* "/home/denis/work/gevent/gevent/evdns.pxi":75
 *         x = []
 *         for i from 0 <= i < count:
 *             x.append(PyString_FromString(inet_ntoa((<in_addr *>addrs)[i])))             # <<<<<<<<<<<<<<
 *     elif t == DNS_IPv6_AAAA:
 *         x = []
 */
      __pyx_t_2 = PyString_FromString(inet_ntoa((((struct in_addr *)__pyx_v_addrs)[__pyx_v_i]))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_x, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 75; __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_1); __pyx_t_1 = 0;
    }
    goto __pyx_L3;
  }

  /* "/home/denis/work/gevent/gevent/evdns.pxi":76
 *         for i from 0 <= i < count:
 *             x.append(PyString_FromString(inet_ntoa((<in_addr *>addrs)[i])))
 *     elif t == DNS_IPv6_AAAA:             # <<<<<<<<<<<<<<
 *         x = []
 *         for i from 0 <= i < count:
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_35); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_2, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":77
 *             x.append(PyString_FromString(inet_ntoa((<in_addr *>addrs)[i])))
 *     elif t == DNS_IPv6_AAAA:
 *         x = []             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < count:
 *             x.append(PyString_FromString(inet_ntop(AF_INET6, <void *>&(<in6_addr *>addrs)[i], str, sizeof(str))))
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_v_x);
    __pyx_v_x = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "/home/denis/work/gevent/gevent/evdns.pxi":78
 *     elif t == DNS_IPv6_AAAA:
 *         x = []
 *         for i from 0 <= i < count:             # <<<<<<<<<<<<<<
 *             x.append(PyString_FromString(inet_ntop(AF_INET6, <void *>&(<in6_addr *>addrs)[i], str, sizeof(str))))
 *     elif t == DNS_PTR and count == 1: # only 1 PTR possible
 */
    __pyx_t_4 = __pyx_v_count;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

      /* "/home/denis/work/gevent/gevent/evdns.pxi":79
 *         x = []
 *         for i from 0 <= i < count:
 *             x.append(PyString_FromString(inet_ntop(AF_INET6, <void *>&(<in6_addr *>addrs)[i], str, sizeof(str))))             # <<<<<<<<<<<<<<
 *     elif t == DNS_PTR and count == 1: # only 1 PTR possible
 *         x = PyString_FromString((<char **>addrs)[0])
 */
      __pyx_t_2 = PyString_FromString(inet_ntop(AF_INET6, ((void *)(&(((struct in6_addr *)__pyx_v_addrs)[__pyx_v_i]))), __pyx_v_str, (sizeof(__pyx_v_str)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_x, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 79; __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_1); __pyx_t_1 = 0;
    }
    goto __pyx_L3;
  }

  /* "/home/denis/work/gevent/gevent/evdns.pxi":80
 *         for i from 0 <= i < count:
 *             x.append(PyString_FromString(inet_ntop(AF_INET6, <void *>&(<in6_addr *>addrs)[i], str, sizeof(str))))
 *     elif t == DNS_PTR and count == 1: # only 1 PTR possible             # <<<<<<<<<<<<<<
 *         x = PyString_FromString((<char **>addrs)[0])
 *     else:
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_DNS_PTR); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_3, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
    __pyx_t_5 = (__pyx_v_count == 1);
    __pyx_t_6 = __pyx_t_5;
  } else {
    __pyx_t_6 = __pyx_t_3;
  }
  if (__pyx_t_6) {

    /* "/home/denis/work/gevent/gevent/evdns.pxi":81
 *             x.append(PyString_FromString(inet_ntop(AF_INET6, <void *>&(<in6_addr *>addrs)[i], str, sizeof(str))))
 *     elif t == DNS_PTR and count == 1: # only 1 PTR possible
 *         x = PyString_FromString((<char **>addrs)[0])             # <<<<<<<<<<<<<<
 *     else:
 *         x = None
 */
    __pyx_t_2 = PyString_FromString((((char **)__pyx_v_addrs)[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

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

  /* "/home/denis/work/gevent/gevent/evdns.pxi":84
 *     else:
 *         x = None
 *     try:             # <<<<<<<<<<<<<<
 *         callback(result, t, ttl, x, args)
 *     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":85
 *         x = None
 *     try:
 *         callback(result, t, ttl, x, args)             # <<<<<<<<<<<<<<
 *     except:
 *         traceback.print_exc()
 */
      __pyx_t_2 = PyInt_FromLong(__pyx_v_result); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyInt_FromLong(__pyx_v_ttl); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyTuple_New(5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __Pyx_INCREF(__pyx_v_args);
      PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_v_args);
      __Pyx_GIVEREF(__pyx_v_args);
      __pyx_t_2 = 0;
      __pyx_t_1 = 0;
      __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_Call(__pyx_v_callback, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(((PyObject *)__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_L15_try_end;
    __pyx_L8_error:;
    __Pyx_XDECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_XDECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_XDECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

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

      /* "/home/denis/work/gevent/gevent/evdns.pxi":87
 *         callback(result, t, ttl, x, args)
 *     except:
 *         traceback.print_exc()             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_traceback); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_1);
      __pyx_t_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_print_exc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_t_9 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L9_exception_handled;
    }
    __pyx_L10_except_error:;
    __Pyx_XDECREF(__pyx_save_exc_type);
    __Pyx_XDECREF(__pyx_save_exc_value);
    __Pyx_XDECREF(__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_1);
  __Pyx_XDECREF(__pyx_2);
  __Pyx_XDECREF(__pyx_3);
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("gevent.core.__evdns_callback");
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_ctx);
  __Pyx_DECREF(__pyx_v_callback);
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_x);
  __Pyx_FinishRefcountContext();
  PyGILState_Release(_save);
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":90
 * 
 * 
 * def dns_resolve_ipv4(char *name, int flags, callback, *args):             # <<<<<<<<<<<<<<
 *     """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, *args)`` prototype\n    - *args*     -- option callback arguments\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;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_t;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_name,&__pyx_kp_flags,&__pyx_kp_callback,0};
  __Pyx_SetupRefcountContext("dns_resolve_ipv4");
  __pyx_self = __pyx_self;
  if (PyTuple_GET_SIZE(__pyx_args) > 3) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 3, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);
    if (unlikely(!__pyx_v_args)) return NULL;
  } 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[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      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;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_name);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_flags);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_ipv4", 0, 3, 3, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_ipv4", 0, 3, 3, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 3) ? PyTuple_GET_SIZE(__pyx_args) : 3;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "dns_resolve_ipv4") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 90; __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 = 90; __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 = 90; __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 = 90; __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 = 90; __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", 0, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_AddTraceback("gevent.core.dns_resolve_ipv4");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":98
 *     - *args*     -- option callback arguments
 *     """
 *     t = (callback, args)             # <<<<<<<<<<<<<<
 *     Py_INCREF(t)
 *     evdns_resolve_ipv4(name, flags, __evdns_callback, <void *>t)
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_args);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_args);
  __Pyx_GIVEREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_t);
  __pyx_v_t = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":99
 *     """
 *     t = (callback, args)
 *     Py_INCREF(t)             # <<<<<<<<<<<<<<
 *     evdns_resolve_ipv4(name, flags, __evdns_callback, <void *>t)
 * 
 */
  Py_INCREF(__pyx_v_t);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":100
 *     t = (callback, args)
 *     Py_INCREF(t)
 *     evdns_resolve_ipv4(name, flags, __evdns_callback, <void *>t)             # <<<<<<<<<<<<<<
 * 
 * def dns_resolve_ipv6(char *name, int flags, callback, *args):
 */
  evdns_resolve_ipv4(__pyx_v_name, __pyx_v_flags, __pyx_f_6gevent_4core___evdns_callback, ((void *)__pyx_v_t));

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("gevent.core.dns_resolve_ipv4");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":102
 *     evdns_resolve_ipv4(name, flags, __evdns_callback, <void *>t)
 * 
 * def dns_resolve_ipv6(char *name, int flags, callback, *args):             # <<<<<<<<<<<<<<
 *     """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, *args)`` prototype\n    - *args*     -- option callback arguments\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;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_t;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_name,&__pyx_kp_flags,&__pyx_kp_callback,0};
  __Pyx_SetupRefcountContext("dns_resolve_ipv6");
  __pyx_self = __pyx_self;
  if (PyTuple_GET_SIZE(__pyx_args) > 3) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 3, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);
    if (unlikely(!__pyx_v_args)) return NULL;
  } 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[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      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;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_name);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_flags);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_ipv6", 0, 3, 3, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_ipv6", 0, 3, 3, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 3) ? PyTuple_GET_SIZE(__pyx_args) : 3;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "dns_resolve_ipv6") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __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 = 102; __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 = 102; __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 = 102; __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 = 102; __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", 0, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_AddTraceback("gevent.core.dns_resolve_ipv6");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":110
 *     - *args*     -- option callback arguments
 *     """
 *     t = (callback, args)             # <<<<<<<<<<<<<<
 *     Py_INCREF(t)
 *     evdns_resolve_ipv6(name, flags, __evdns_callback, <void *>t)
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_args);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_args);
  __Pyx_GIVEREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_t);
  __pyx_v_t = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":111
 *     """
 *     t = (callback, args)
 *     Py_INCREF(t)             # <<<<<<<<<<<<<<
 *     evdns_resolve_ipv6(name, flags, __evdns_callback, <void *>t)
 * 
 */
  Py_INCREF(__pyx_v_t);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":112
 *     t = (callback, args)
 *     Py_INCREF(t)
 *     evdns_resolve_ipv6(name, flags, __evdns_callback, <void *>t)             # <<<<<<<<<<<<<<
 * 
 * def dns_resolve_reverse(char *ip, int flags, callback, *args):
 */
  evdns_resolve_ipv6(__pyx_v_name, __pyx_v_flags, __pyx_f_6gevent_4core___evdns_callback, ((void *)__pyx_v_t));

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("gevent.core.dns_resolve_ipv6");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":114
 *     evdns_resolve_ipv6(name, flags, __evdns_callback, <void *>t)
 * 
 * def dns_resolve_reverse(char *ip, int flags, callback, *args):             # <<<<<<<<<<<<<<
 *     """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    - *name*     -- IPv4 address (as 4-byte binary string)\n    - *flags*    -- either 0 or DNS_QUERY_NO_SEARCH\n    - *callback* -- callback with ``(result, type, ttl, addrs, *args)`` prototype\n    - *args*     -- option callback arguments\n    ";
static PyObject *__pyx_pf_6gevent_4core_dns_resolve_reverse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_ip;
  int __pyx_v_flags;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_t;
  struct in_addr __pyx_v_addr;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_ip,&__pyx_kp_flags,&__pyx_kp_callback,0};
  __Pyx_SetupRefcountContext("dns_resolve_reverse");
  __pyx_self = __pyx_self;
  if (PyTuple_GET_SIZE(__pyx_args) > 3) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 3, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);
    if (unlikely(!__pyx_v_args)) return NULL;
  } 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[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      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;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_ip);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_flags);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_reverse", 0, 3, 3, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_reverse", 0, 3, 3, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 3) ? PyTuple_GET_SIZE(__pyx_args) : 3;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "dns_resolve_reverse") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_ip = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_ip) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 114; __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 = 114; __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_ip = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_ip) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 114; __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 = 114; __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", 0, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_AddTraceback("gevent.core.dns_resolve_reverse");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":122
 *     - *args*     -- option callback arguments
 *     """
 *     t = (callback, args)             # <<<<<<<<<<<<<<
 *     Py_INCREF(t)
 *     cdef in_addr addr
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_args);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_args);
  __Pyx_GIVEREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_t);
  __pyx_v_t = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":123
 *     """
 *     t = (callback, args)
 *     Py_INCREF(t)             # <<<<<<<<<<<<<<
 *     cdef in_addr addr
 *     inet_aton(ip, &addr)
 */
  Py_INCREF(__pyx_v_t);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":125
 *     Py_INCREF(t)
 *     cdef in_addr addr
 *     inet_aton(ip, &addr)             # <<<<<<<<<<<<<<
 *     evdns_resolve_reverse(&addr, flags, __evdns_callback, <void *>t)
 * 
 */
  inet_aton(__pyx_v_ip, (&__pyx_v_addr));

  /* "/home/denis/work/gevent/gevent/evdns.pxi":126
 *     cdef in_addr addr
 *     inet_aton(ip, &addr)
 *     evdns_resolve_reverse(&addr, flags, __evdns_callback, <void *>t)             # <<<<<<<<<<<<<<
 * 
 * def dns_resolve_reverse_ipv6(char *ip, int flags, callback, *args):
 */
  evdns_resolve_reverse((&__pyx_v_addr), __pyx_v_flags, __pyx_f_6gevent_4core___evdns_callback, ((void *)__pyx_v_t));

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("gevent.core.dns_resolve_reverse");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":128
 *     evdns_resolve_reverse(&addr, flags, __evdns_callback, <void *>t)
 * 
 * def dns_resolve_reverse_ipv6(char *ip, int flags, callback, *args):             # <<<<<<<<<<<<<<
 *     """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    - *name*     -- IPv6 address (as 16-byte binary string)\n    - *flags*    -- either 0 or DNS_QUERY_NO_SEARCH\n    - *callback* -- callback with ``(result, type, ttl, addrs, *args)`` prototype\n    - *args*     -- option callback arguments\n    ";
static PyObject *__pyx_pf_6gevent_4core_dns_resolve_reverse_ipv6(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_ip;
  int __pyx_v_flags;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_t;
  struct in6_addr __pyx_v_addr;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_ip,&__pyx_kp_flags,&__pyx_kp_callback,0};
  __Pyx_SetupRefcountContext("dns_resolve_reverse_ipv6");
  __pyx_self = __pyx_self;
  if (PyTuple_GET_SIZE(__pyx_args) > 3) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 3, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);
    if (unlikely(!__pyx_v_args)) return NULL;
  } 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[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      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;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_ip);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_flags);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_reverse_ipv6", 0, 3, 3, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("dns_resolve_reverse_ipv6", 0, 3, 3, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 3) ? PyTuple_GET_SIZE(__pyx_args) : 3;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "dns_resolve_reverse_ipv6") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_ip = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_ip) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 128; __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 = 128; __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_ip = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_ip) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 128; __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 = 128; __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", 0, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_AddTraceback("gevent.core.dns_resolve_reverse_ipv6");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":136
 *     - *args*     -- option callback arguments
 *     """
 *     t = (callback, args)             # <<<<<<<<<<<<<<
 *     Py_INCREF(t)
 *     cdef in6_addr addr
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_INCREF(__pyx_v_args);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_args);
  __Pyx_GIVEREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_t);
  __pyx_v_t = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":137
 *     """
 *     t = (callback, args)
 *     Py_INCREF(t)             # <<<<<<<<<<<<<<
 *     cdef in6_addr addr
 *     inet_pton(AF_INET6, ip, &addr)
 */
  Py_INCREF(__pyx_v_t);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":139
 *     Py_INCREF(t)
 *     cdef in6_addr addr
 *     inet_pton(AF_INET6, ip, &addr)             # <<<<<<<<<<<<<<
 *     evdns_resolve_reverse_ipv6(&addr, flags, __evdns_callback, <void *>t)
 * 
 */
  inet_pton(AF_INET6, __pyx_v_ip, (&__pyx_v_addr));

  /* "/home/denis/work/gevent/gevent/evdns.pxi":140
 *     cdef in6_addr addr
 *     inet_pton(AF_INET6, ip, &addr)
 *     evdns_resolve_reverse_ipv6(&addr, flags, __evdns_callback, <void *>t)             # <<<<<<<<<<<<<<
 * 
 * def dns_shutdown(int fail_requests=0):
 */
  evdns_resolve_reverse_ipv6((&__pyx_v_addr), __pyx_v_flags, __pyx_f_6gevent_4core___evdns_callback, ((void *)__pyx_v_t));

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("gevent.core.dns_resolve_reverse_ipv6");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evdns.pxi":142
 *     evdns_resolve_reverse_ipv6(&addr, flags, __evdns_callback, <void *>t)
 * 
 * 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_kp_fail_requests,0};
  __Pyx_SetupRefcountContext("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_kp_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 = 142; __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 = 142; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_fail_requests = 0;
    }
  } else {
    __pyx_v_fail_requests = 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 = 142; __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 = 142; __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":144
 * 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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":24
 *     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_kp__obj,0};
  __Pyx_SetupRefcountContext("__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_kp__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 = 24; __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 = 24; __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 = 24; __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 = 24; __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":25
 * 
 *     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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":29
 *     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_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":30
 * 
 *         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 = 30; __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":32
 *             return <size_t>(self.__obj)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         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;
  __Pyx_SetupRefcountContext("__len__");

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

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

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":35
 *         return evbuffer_get_length(self.__obj)
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         return self.__obj and 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_SetupRefcountContext("__nonzero__");

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":36
 * 
 *     def __nonzero__(self):
 *         return self.__obj and evbuffer_get_length(self.__obj)             # <<<<<<<<<<<<<<
 * 
 *     # cython does not implement generators
 */
  if ((((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj != 0)) {
    __pyx_t_1 = evbuffer_get_length(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj);
  } else {
    __pyx_t_1 = (((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj != 0);
  }
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

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

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":43
 *     #        yield self.readline()
 * 
 *     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;
  PyObject *__pyx_v_res = 0;
  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;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_size,0};
  __Pyx_SetupRefcountContext("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_kp_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 = 43; __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 = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_size = -1;
    }
  } else {
    __pyx_v_size = -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 = 43; __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 = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.buffer.read");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":48
 *         If *size* is negative, drain the whole buffer.
 *         """
 *         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":49
 *         """
 *         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":50
 *         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_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":52
 *             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 = 52; __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 = 52; __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 = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__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 = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_size = __pyx_t_5;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":53
 *         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":54
 *             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(__pyx_kp_76);
    __pyx_r = __pyx_kp_76;
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":55
 *         if size <= 0:
 *             return ''
 *         cdef char* data = <char*>evbuffer_pullup(self.__obj, size)             # <<<<<<<<<<<<<<
 *         if not data:
 *             raise RuntimeError('evbuffer_pullup(%x, %s) returned NULL' % (self._obj, size))
 */
  __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":56
 *             return ''
 *         cdef char* data = <char*>evbuffer_pullup(self.__obj, size)
 *         if not data:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('evbuffer_pullup(%x, %s) returned NULL' % (self._obj, size))
 *         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":57
 *         cdef char* data = <char*>evbuffer_pullup(self.__obj, size)
 *         if not data:
 *             raise RuntimeError('evbuffer_pullup(%x, %s) returned NULL' % (self._obj, size))             # <<<<<<<<<<<<<<
 *         cdef object result = PyString_FromStringAndSize(data, size)
 *         cdef res = EVBUFFER_DRAIN(self.__obj, size)
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__obj); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyInt_FromLong(__pyx_v_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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(__pyx_kp_77, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__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[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":58
 *         if not data:
 *             raise RuntimeError('evbuffer_pullup(%x, %s) returned NULL' % (self._obj, size))
 *         cdef object result = PyString_FromStringAndSize(data, size)             # <<<<<<<<<<<<<<
 *         cdef res = EVBUFFER_DRAIN(self.__obj, size)
 *         if res:
 */
  __pyx_t_4 = PyString_FromStringAndSize(__pyx_v_data, __pyx_v_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":59
 *             raise RuntimeError('evbuffer_pullup(%x, %s) returned NULL' % (self._obj, size))
 *         cdef object result = PyString_FromStringAndSize(data, size)
 *         cdef res = EVBUFFER_DRAIN(self.__obj, size)             # <<<<<<<<<<<<<<
 *         if res:
 *             raise RuntimeError('evbuffer_drain(%x, %s) returned %s' % (self._obj, size, res))
 */
  __pyx_t_4 = PyInt_FromLong(EVBUFFER_DRAIN(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj, __pyx_v_size)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_res = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":60
 *         cdef object result = PyString_FromStringAndSize(data, size)
 *         cdef res = EVBUFFER_DRAIN(self.__obj, size)
 *         if res:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('evbuffer_drain(%x, %s) returned %s' % (self._obj, size, res))
 *         return result
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_res); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":61
 *         cdef res = EVBUFFER_DRAIN(self.__obj, size)
 *         if res:
 *             raise RuntimeError('evbuffer_drain(%x, %s) returned %s' % (self._obj, size, res))             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__obj); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_res);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_res);
    __Pyx_GIVEREF(__pyx_v_res);
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(__pyx_kp_78, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":62
 *         if res:
 *             raise RuntimeError('evbuffer_drain(%x, %s) returned %s' % (self._obj, size, res))
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def readline(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.buffer.read");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evbuffer.pxi":64
 *         return result
 * 
 *     def readline(self):             # <<<<<<<<<<<<<<
 *         cdef char* res = evbuffer_readline(self.__obj)
 *         if res:
 */

static PyObject *__pyx_pf_6gevent_4core_6buffer_readline(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_6buffer_readline(PyObject *__pyx_v_self, PyObject *unused) {
  char *__pyx_v_res;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("readline");

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":65
 * 
 *     def readline(self):
 *         cdef char* res = evbuffer_readline(self.__obj)             # <<<<<<<<<<<<<<
 *         if res:
 *             return res
 */
  __pyx_v_res = evbuffer_readline(((struct __pyx_obj_6gevent_4core_buffer *)__pyx_v_self)->__pyx___obj);

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":66
 *     def readline(self):
 *         cdef char* res = evbuffer_readline(self.__obj)
 *         if res:             # <<<<<<<<<<<<<<
 *             return res
 *         return ''
 */
  __pyx_t_1 = (__pyx_v_res != 0);
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evbuffer.pxi":67
 *         cdef char* res = evbuffer_readline(self.__obj)
 *         if res:
 *             return res             # <<<<<<<<<<<<<<
 *         return ''
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_res); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":68
 *         if res:
 *             return res
 *         return ''             # <<<<<<<<<<<<<<
 * 
 *     def readlines(self, hint=-1):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_kp_79);
  __pyx_r = __pyx_kp_79;
  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.buffer.readline");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

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

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_kp_hint,0};
  __Pyx_SetupRefcountContext("readlines");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    values[0] = __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_kp_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 = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_hint = values[0];
  } else {
    __pyx_v_hint = __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 = 70; __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":71
 * 
 *     def readlines(self, hint=-1):
 *         return list(self.__iter__())             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___iter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __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 = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyList_Type)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__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_FinishRefcountContext();
  return __pyx_r;
}

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

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;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__obj,0};
  __Pyx_SetupRefcountContext("__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_kp__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 = 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;}
  } 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 = 118; __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 = 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):
 *         self.__obj = <evhttp_request*>_obj             # <<<<<<<<<<<<<<
 * 
 *     property _obj:
 */
  ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj = ((struct evhttp_request *)__pyx_v__obj);

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

/* "/home/denis/work/gevent/gevent/evhttp.pxi":123
 *     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_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":124
 * 
 *         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 = 124; __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":126
 *             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_SetupRefcountContext("__nonzero__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":127
 * 
 *     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":128
 *     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":130
 *             return True
 *         else:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     def detach(self):
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

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

/* "/home/denis/work/gevent/gevent/evhttp.pxi":132
 *             return False
 * 
 *     def detach(self):             # <<<<<<<<<<<<<<
 *         self.__obj = NULL
 * 
 */

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;
  __Pyx_SetupRefcountContext("detach");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":133
 * 
 *     def detach(self):
 *         self.__obj = NULL             # <<<<<<<<<<<<<<
 * 
 *     def _format(self):
 */
  ((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj = NULL;

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

/* "/home/denis/work/gevent/gevent/evhttp.pxi":135
 *         self.__obj = NULL
 * 
 *     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_1 = 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;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  __Pyx_SetupRefcountContext("_format");
  __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":136
 * 
 *     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_kp_typestr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_uri); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_major); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_minor); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":137
 *     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_kp_remote_host); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_remote_port); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 137; __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 = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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 = ((PyObject *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":138
 *         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(__pyx_kp_80, __pyx_v_args); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 138; __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":139
 *                 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_kp_response_code); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 139; __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 = 139; __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":140
 *         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_kp_response_code); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyNumber_Remainder(__pyx_kp_81, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_1 = PyNumber_InPlaceAdd(__pyx_v_res, __pyx_t_6); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_v_res);
    __pyx_v_res = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":141
 *         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_6 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_input_buffer); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_8) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":142
 *             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_6 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_input_buffer); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = PyObject_Length(__pyx_t_6); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyNumber_Remainder(__pyx_kp_82, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_1 = PyNumber_InPlaceAdd(__pyx_v_res, __pyx_t_7); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_v_res);
    __pyx_v_res = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":143
 *         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_kp_output_buffer); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __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 = 143; __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":144
 *             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_kp_output_buffer); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __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 = 144; __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 = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyNumber_Remainder(__pyx_kp_83, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_1 = PyNumber_InPlaceAdd(__pyx_v_res, __pyx_t_6); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_v_res);
    __pyx_v_res = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":145
 *         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_1);
  __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_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":147
 *         return res
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj:
 *             return '<%s %s>' % (self.__class__.__name__, 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_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_SetupRefcountContext("__str__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":148
 * 
 *     def __str__(self):
 *         if self.__obj:             # <<<<<<<<<<<<<<
 *             return '<%s %s>' % (self.__class__.__name__, self._format())
 *         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":149
 *     def __str__(self):
 *         if self.__obj:
 *             return '<%s %s>' % (self.__class__.__name__, self._format())             # <<<<<<<<<<<<<<
 *         else:
 *             return '<%s deleted>' % self.__class__.__name__
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___class__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_kp___name__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __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_GetAttr(__pyx_v_self, __pyx_kp__format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __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[1]; __pyx_lineno = 149; __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[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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(__pyx_kp_84, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":151
 *             return '<%s %s>' % (self.__class__.__name__, self._format())
 *         else:
 *             return '<%s deleted>' % self.__class__.__name__             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___class__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_kp___name__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(__pyx_kp_85, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __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.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":153
 *             return '<%s deleted>' % self.__class__.__name__
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj:
 *             return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, 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_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;
  __Pyx_SetupRefcountContext("__repr__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":154
 * 
 *     def __repr__(self):
 *         if self.__obj:             # <<<<<<<<<<<<<<
 *             return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, self._format())
 *         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":155
 *     def __repr__(self):
 *         if self.__obj:
 *             return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, self._format())             # <<<<<<<<<<<<<<
 *         else:
 *             return '<%s _obj=0x%x>' % (self.__class__.__name__, self._obj)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___class__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_kp___name__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __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_GetAttr(__pyx_v_self, __pyx_kp__obj); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __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(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(__pyx_kp_86, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":157
 *             return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, self._format())
 *         else:
 *             return '<%s _obj=0x%x>' % (self.__class__.__name__, self._obj)             # <<<<<<<<<<<<<<
 * 
 *     def get_input_headers(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___class__); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_kp___name__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__obj); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(__pyx_kp_87, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __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_request.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":159
 *             return '<%s _obj=0x%x>' % (self.__class__.__name__, self._obj)
 * 
 *     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;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_SetupRefcountContext("get_input_headers");
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":160
 * 
 *     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":161
 *     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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":162
 *         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":163
 *             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":165
 *         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 = 165; __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":166
 *         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":167
 *         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":168
 *         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":169
 *             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_2 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_1 = __pyx_t_2;
      __pyx_t_2 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_1 = Py_None;
    }
    if ((__pyx_v_value != 0)) {
      __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_2 = __pyx_t_2;
      __pyx_t_2 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_2 = Py_None;
    }
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_1);
    __Pyx_GIVEREF(__pyx_1);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_2);
    __Pyx_GIVEREF(__pyx_2);
    __pyx_1 = 0;
    __pyx_2 = 0;
    __pyx_t_3 = __Pyx_PyObject_Append(__pyx_v_result, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":170
 *             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":171
 *             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_1);
  __Pyx_XDECREF(__pyx_2);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.get_input_headers");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":175
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_SetupRefcountContext("__get__");

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

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":178
 *             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 = 178; __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 = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_http_connection)), ((PyObject *)__pyx_t_3), NULL); 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_DECREF(((PyObject *)__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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core.http_request.connection.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":182
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":183
 * 
 *         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":184
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             if self.__obj.remote_host:
 *                 return self.__obj.remote_host
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":185
 *             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":186
 *                 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 = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.remote_host.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":190
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":191
 * 
 *         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":192
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.remote_port
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":193
 *             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 = 193; __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.remote_port.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

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

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_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":198
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return (self.remote_host, self.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":199
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return (self.remote_host, self.remote_port)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":200
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return (self.remote_host, self.remote_port)             # <<<<<<<<<<<<<<
 * 
 *     property kind:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_remote_host); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_remote_port); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 200; __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 = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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 = ((PyObject *)__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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_request.remote.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":204
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":205
 * 
 *         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":206
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.kind
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":207
 *             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 = 207; __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.kind.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":211
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":212
 * 
 *         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":213
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.type
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":214
 *             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 = 214; __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.type.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":218
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":219
 * 
 *         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":220
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return HTTP_method2name.get(self.__obj.type) or str(self.__obj.type)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":221
 *             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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_46); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_get); 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_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_6gevent_4core_http_request *)__pyx_v_self)->__pyx___obj->type); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 221; __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 = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_1) {
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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 = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = __pyx_t_4;
    __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __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_1);
  __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_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":225
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":226
 * 
 *         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":227
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             if self.__obj.uri:
 *                 return self.__obj.uri
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":228
 *             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":229
 *                 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 = 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;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.uri.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":233
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":234
 * 
 *         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":235
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.major
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 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 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 = 236; __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.major.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":240
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":241
 * 
 *         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":242
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.minor
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 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
 *             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 = 243; __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.minor.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":247
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":248
 * 
 *         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":249
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return (self.__obj.major, self.__obj.minor)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":250
 *             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 = 250; __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 = 250; __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 = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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 = ((PyObject *)__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_1);
  __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_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":254
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":255
 * 
 *         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":256
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.response_code
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":257
 *             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 = 257; __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.response_code.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":261
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":262
 * 
 *         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":263
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             if self.__obj.response_code_line:
 *                 return self.__obj.response_code_line
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":264
 *             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":265
 *                 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 = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.response_code_line.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

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

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_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":270
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return (self.response_code, self.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":271
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return (self.response_code, self.response_code_line)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 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.response_code, self.response_code_line)             # <<<<<<<<<<<<<<
 * 
 *     property chunked:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_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_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_response_code_line); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __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 = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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 = ((PyObject *)__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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_request.response.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":276
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":277
 * 
 *         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":278
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return self.__obj.chunked
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 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
 *             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 = 279; __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.chunked.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

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

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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":284
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return 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":285
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return buffer(<size_t>self.__obj.input_buffer)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

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

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __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_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

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

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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":291
 * 
 *         def __get__(self):
 *             if not self.__obj:             # <<<<<<<<<<<<<<
 *                 raise HttpRequestDeleted
 *             return 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":292
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *             return buffer(<size_t>self.__obj.output_buffer)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":293
 *             if not self.__obj:
 *                 raise HttpRequestDeleted
 *             return buffer(<size_t>self.__obj.output_buffer)             # <<<<<<<<<<<<<<
 * 
 *     def send_reply(self, int code, char *reason, object buf):
 */
  __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->output_buffer)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 293; __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 = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_buffer)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __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_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":295
 *             return buffer(<size_t>self.__obj.output_buffer)
 * 
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  char *__pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_code,&__pyx_kp_reason,&__pyx_kp_buf,0};
  __Pyx_SetupRefcountContext("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_kp_code);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_reason);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("send_reply", 1, 3, 3, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_buf);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("send_reply", 1, 3, 3, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 295; __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 = 295; __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 = 295; __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 = 295; __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 = 295; __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 = 295; __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 = 295; __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:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":296
 * 
 *     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":297
 *     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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":299
 *             raise HttpRequestDeleted
 *         cdef evbuffer* c_buf
 *         if isinstance(buf, buffer):             # <<<<<<<<<<<<<<
 *             evhttp_send_reply(self.__obj, code, reason, (<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":300
 *         cdef evbuffer* c_buf
 *         if isinstance(buf, buffer):
 *             evhttp_send_reply(self.__obj, code, reason, (<buffer>buf).__obj)             # <<<<<<<<<<<<<<
 *         elif isinstance(buf, str):
 *             c_buf = evbuffer_new()
 */
    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":301
 *         if isinstance(buf, buffer):
 *             evhttp_send_reply(self.__obj, code, reason, (<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":302
 *             evhttp_send_reply(self.__obj, code, reason, (<buffer>buf).__obj)
 *         elif isinstance(buf, str):
 *             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":303
 *         elif isinstance(buf, str):
 *             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_2 = __Pyx_PyBytes_AsString(__pyx_v_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    evbuffer_add(__pyx_v_c_buf, ((char *)__pyx_t_2), __pyx_t_3);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":304
 *             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":305
 *             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":307
 *             evbuffer_free(c_buf)
 *         else:
 *             raise TypeError('Expected str or buffer: %r' % (buf, ))             # <<<<<<<<<<<<<<
 * 
 *     def send_reply_start(self, int code, char *reason):
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_buf);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_buf);
    __Pyx_GIVEREF(__pyx_v_buf);
    __pyx_t_5 = PyNumber_Remainder(__pyx_kp_88, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__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[1]; __pyx_lineno = 307; __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_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.http_request.send_reply");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":309
 *             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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_code,&__pyx_kp_reason,0};
  __Pyx_SetupRefcountContext("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_kp_code);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_reason);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("send_reply_start", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 309; __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 = 309; __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 = 309; __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 = 309; __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 = 309; __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 = 309; __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 = 309; __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:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":310
 * 
 *     def send_reply_start(self, int code, char *reason):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         evhttp_send_reply_start(self.__obj, code, reason)
 */
  __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":311
 *     def send_reply_start(self, int code, char *reason):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         evhttp_send_reply_start(self.__obj, code, reason)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":312
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         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_1);
  __Pyx_AddTraceback("gevent.core.http_request.send_reply_start");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":314
 *         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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  char *__pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_SetupRefcountContext("send_reply_chunk");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":315
 * 
 *     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":316
 *     def send_reply_chunk(self, object buf):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         cdef evbuffer* c_buf
 *         if isinstance(buf, buffer):
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":318
 *             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":319
 *         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":320
 *         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":321
 *             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":322
 *         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_2 = __Pyx_PyBytes_AsString(__pyx_v_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    evbuffer_add(__pyx_v_c_buf, ((char *)__pyx_t_2), __pyx_t_3);

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":323
 *             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":324
 *             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":326
 *             evbuffer_free(c_buf)
 *         else:
 *             raise TypeError('Expected str or buffer: %r' % (buf, ))             # <<<<<<<<<<<<<<
 * 
 *     def send_reply_end(self):
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_buf);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_buf);
    __Pyx_GIVEREF(__pyx_v_buf);
    __pyx_t_5 = PyNumber_Remainder(__pyx_kp_89, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__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[1]; __pyx_lineno = 326; __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_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("gevent.core.http_request.send_reply_chunk");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":328
 *             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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  __Pyx_SetupRefcountContext("send_reply_end");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":329
 * 
 *     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":330
 *     def send_reply_end(self):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         evhttp_send_reply_end(self.__obj)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":331
 *         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_1);
  __Pyx_AddTraceback("gevent.core.http_request.send_reply_end");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":333
 *         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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_code,&__pyx_kp_reason,0};
  __Pyx_SetupRefcountContext("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_kp_code);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_reason);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("send_error", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __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 = 333; __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 = 333; __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 = 333; __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 = 333; __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 = 333; __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 = 333; __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:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":334
 * 
 *     def send_error(self, int code, char* reason):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpRequestDeleted
 *         evhttp_send_error(self.__obj, code, reason)
 */
  __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":335
 *     def send_error(self, int code, char* reason):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         evhttp_send_error(self.__obj, code, reason)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":336
 *         if not self.__obj:
 *             raise HttpRequestDeleted
 *         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_1);
  __Pyx_AddTraceback("gevent.core.http_request.send_error");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":338
 *         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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("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 = 338; __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:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":339
 * 
 *     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":340
 *     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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":341
 *         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":342
 *             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":343
 *         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 = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.find_input_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":345
 *             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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("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 = 345; __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:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":346
 * 
 *     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":347
 *     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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":348
 *         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":349
 *             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":350
 *         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 = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.find_output_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":352
 *             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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,&__pyx_kp_value,0};
  __Pyx_SetupRefcountContext("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_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_value);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_input_header", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 352; __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 = 352; __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 = 352; __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 = 352; __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 = 352; __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 = 352; __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 = 352; __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:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":353
 * 
 *     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":354
 *     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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":355
 *         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 = 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_2) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":356
 *             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_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(__pyx_kp_90);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_90);
    __Pyx_GIVEREF(__pyx_kp_90);
    __pyx_t_4 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 356; __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_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_request.add_input_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":358
 *             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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,&__pyx_kp_value,0};
  __Pyx_SetupRefcountContext("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_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_value);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_output_header", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 358; __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 = 358; __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 = 358; __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 = 358; __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 = 358; __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 = 358; __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 = 358; __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:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":359
 * 
 *     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":360
 *     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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":361
 *         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 = 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_2) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":362
 *             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_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(__pyx_kp_91);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_91);
    __Pyx_GIVEREF(__pyx_kp_91);
    __pyx_t_4 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 362; __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_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http_request.add_output_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":364
 *             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;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("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 = 364; __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:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":366
 *     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":367
 *         """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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":368
 *         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_2 = 1;
  } else {
    __pyx_2 = 0;
  }
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_2); 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_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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.remove_input_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":370
 *         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;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_SetupRefcountContext("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 = 370; __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:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":372
 *     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":373
 *         """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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":374
 *         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_2 = 1;
  } else {
    __pyx_2 = 0;
  }
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 374; __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http_request.remove_output_header");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":376
 *         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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  __Pyx_SetupRefcountContext("clear_input_headers");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":377
 * 
 *     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":378
 *     def clear_input_headers(self):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         evhttp_clear_headers(self.__obj.input_headers)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":379
 *         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_1);
  __Pyx_AddTraceback("gevent.core.http_request.clear_input_headers");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":381
 *         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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  __Pyx_SetupRefcountContext("clear_output_headers");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":382
 * 
 *     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":383
 *     def clear_output_headers(self):
 *         if not self.__obj:
 *             raise HttpRequestDeleted             # <<<<<<<<<<<<<<
 *         evhttp_clear_headers(self.__obj.output_headers)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_HttpRequestDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":384
 *         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_1);
  __Pyx_AddTraceback("gevent.core.http_request.clear_output_headers");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":387
 * 
 * 
 * cdef void _http_connection_closecb_handler(evhttp_connection* connection, void *arg) with gil:             # <<<<<<<<<<<<<<
 *     try:
 *         server = <object>arg
 */

static  void __pyx_f_6gevent_4core__http_connection_closecb_handler(struct evhttp_connection *__pyx_v_connection, void *__pyx_v_arg) {
  PyObject *__pyx_v_server;
  PyObject *__pyx_v_conn;
  PyObject *__pyx_1 = 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;
  PyGILState_STATE _save = PyGILState_Ensure();
  __Pyx_SetupRefcountContext("_http_connection_closecb_handler");
  __pyx_v_server = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_conn = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":388
 * 
 * cdef void _http_connection_closecb_handler(evhttp_connection* connection, void *arg) with gil:
 *     try:             # <<<<<<<<<<<<<<
 *         server = <object>arg
 *         conn = http_connection(<size_t>connection)
 */
  {
    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":389
 * cdef void _http_connection_closecb_handler(evhttp_connection* connection, void *arg) with gil:
 *     try:
 *         server = <object>arg             # <<<<<<<<<<<<<<
 *         conn = http_connection(<size_t>connection)
 *         server._cb_connection_close(conn)
 */
      __Pyx_INCREF(((PyObject *)__pyx_v_arg));
      __Pyx_DECREF(__pyx_v_server);
      __pyx_v_server = ((PyObject *)__pyx_v_arg);

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":390
 *     try:
 *         server = <object>arg
 *         conn = http_connection(<size_t>connection)             # <<<<<<<<<<<<<<
 *         server._cb_connection_close(conn)
 *     except:
 */
      __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_connection)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(((PyObject *)__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 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_http_connection)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_v_conn);
      __pyx_v_conn = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":391
 *         server = <object>arg
 *         conn = http_connection(<size_t>connection)
 *         server._cb_connection_close(conn)             # <<<<<<<<<<<<<<
 *     except:
 *         traceback.print_exc()
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_server, __pyx_kp_92); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_conn);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_conn);
      __Pyx_GIVEREF(__pyx_v_conn);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__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":392
 *         conn = http_connection(<size_t>connection)
 *         server._cb_connection_close(conn)
 *     except:             # <<<<<<<<<<<<<<
 *         traceback.print_exc()
 *         try:
 */
    /*except:*/ {
      __Pyx_AddTraceback("gevent.core._http_connection_closecb_handler");
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __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":393
 *         server._cb_connection_close(conn)
 *     except:
 *         traceback.print_exc()             # <<<<<<<<<<<<<<
 *         try:
 *             sys.stderr.write('Failed to execute callback for evhttp connection:\n  connection = %s\n server = %s\n\n' % (conn, server))
 */
      __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_traceback); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_1);
      __pyx_t_4 = PyObject_GetAttr(__pyx_1, __pyx_kp_print_exc); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L5_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;

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":394
 *     except:
 *         traceback.print_exc()
 *         try:             # <<<<<<<<<<<<<<
 *             sys.stderr.write('Failed to execute callback for evhttp connection:\n  connection = %s\n server = %s\n\n' % (conn, server))
 *         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":395
 *         traceback.print_exc()
 *         try:
 *             sys.stderr.write('Failed to execute callback for evhttp connection:\n  connection = %s\n server = %s\n\n' % (conn, server))             # <<<<<<<<<<<<<<
 *         except:
 *             pass
 */
          __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_sys); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_1);
          __pyx_t_5 = PyObject_GetAttr(__pyx_1, __pyx_kp_stderr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
          __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_kp_write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_5));
          __Pyx_INCREF(__pyx_v_conn);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_conn);
          __Pyx_GIVEREF(__pyx_v_conn);
          __Pyx_INCREF(__pyx_v_server);
          PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_server);
          __Pyx_GIVEREF(__pyx_v_server);
          __pyx_t_6 = PyNumber_Remainder(__pyx_kp_93, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(((PyObject *)__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 = 395; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(((PyObject *)__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, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __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;
        }
        __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_L20_try_end;
        __pyx_L13_error:;
        __Pyx_XDECREF(__pyx_1); __pyx_1 = 0;
        __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/evhttp.pxi":396
 *         try:
 *             sys.stderr.write('Failed to execute callback for evhttp connection:\n  connection = %s\n server = %s\n\n' % (conn, server))
 *         except:             # <<<<<<<<<<<<<<
 *             pass
 * 
 */
        /*except:*/ {
          PyErr_Restore(0,0,0);
          goto __pyx_L14_exception_handled;
        }
        __pyx_L14_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_L20_try_end:;
      }
      __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_XDECREF(__pyx_save_exc_type);
    __Pyx_XDECREF(__pyx_save_exc_value);
    __Pyx_XDECREF(__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_1);
  __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_WriteUnraisable("gevent.core._http_connection_closecb_handler");
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_server);
  __Pyx_DECREF(__pyx_v_conn);
  __Pyx_FinishRefcountContext();
  PyGILState_Release(_save);
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":404
 *     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_kp__obj,0};
  __Pyx_SetupRefcountContext("__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_kp__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 = 404; __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 = 404; __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 = 404; __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 = 404; __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":405
 * 
 *     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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":409
 *     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_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":410
 * 
 *         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 = 410; __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":412
 *             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_SetupRefcountContext("__nonzero__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":413
 * 
 *     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":414
 *     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":416
 *             return True
 *         else:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

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

/* "/home/denis/work/gevent/gevent/evhttp.pxi":418
 *             return False
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj:
 *             return '<%s %s>' % (self.__class__.__name__, 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_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_SetupRefcountContext("__str__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":419
 * 
 *     def __str__(self):
 *         if self.__obj:             # <<<<<<<<<<<<<<
 *             return '<%s %s>' % (self.__class__.__name__, self.peer)
 *         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":420
 *     def __str__(self):
 *         if self.__obj:
 *             return '<%s %s>' % (self.__class__.__name__, self.peer)             # <<<<<<<<<<<<<<
 *         else:
 *             return '<%s deleted>' % (self.__class__.__name__)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___class__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_kp___name__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 420; __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_GetAttr(__pyx_v_self, __pyx_kp_peer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(__pyx_kp_94, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":422
 *             return '<%s %s>' % (self.__class__.__name__, self.peer)
 *         else:
 *             return '<%s deleted>' % (self.__class__.__name__)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___class__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_kp___name__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(__pyx_kp_95, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __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_connection.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":424
 *             return '<%s deleted>' % (self.__class__.__name__)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj:
 *             return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, 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_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;
  __Pyx_SetupRefcountContext("__repr__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":425
 * 
 *     def __repr__(self):
 *         if self.__obj:             # <<<<<<<<<<<<<<
 *             return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, self.peer)
 *         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":426
 *     def __repr__(self):
 *         if self.__obj:
 *             return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, self.peer)             # <<<<<<<<<<<<<<
 *         else:
 *             return '<%s _obj=0x%x>' % (self.__class__.__name__, self._obj)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___class__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_kp___name__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 426; __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_GetAttr(__pyx_v_self, __pyx_kp__obj); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_peer); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 426; __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 = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(__pyx_kp_96, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":428
 *             return '<%s _obj=0x%x %s>' % (self.__class__.__name__, self._obj, self.peer)
 *         else:
 *             return '<%s _obj=0x%x>' % (self.__class__.__name__, self._obj)             # <<<<<<<<<<<<<<
 * 
 *     property peer:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___class__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_kp___name__); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 428; __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_GetAttr(__pyx_v_self, __pyx_kp__obj); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_5 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(__pyx_kp_97, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __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_connection.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":432
 *     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;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_SetupRefcountContext("__get__");
  __pyx_v_addr = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":433
 * 
 *         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":434
 *         def __get__(self):
 *             if not self.__obj:
 *                 raise HttpConnectionDeleted             # <<<<<<<<<<<<<<
 *             cdef char* address = NULL
 *             cdef ev_uint16_t port = 0
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_48); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":435
 *             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":436
 *                 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":437
 *             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":438
 *             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":439
 *             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 = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_v_addr);
    __pyx_v_addr = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":441
 *                 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":442
 *             else:
 *                 addr = None
 *             return (addr, port)             # <<<<<<<<<<<<<<
 * 
 *     def set_closecb(self, callback):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_port); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 442; __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 = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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 = ((PyObject *)__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_1);
  __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_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":444
 *             return (addr, port)
 * 
 *     def set_closecb(self, callback):             # <<<<<<<<<<<<<<
 *         if not self.__obj:
 *             raise HttpConnectionDeleted
 */

static PyObject *__pyx_pf_6gevent_4core_15http_connection_set_closecb(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_15http_connection_set_closecb(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_1 = 0;
  int __pyx_t_1;
  __Pyx_SetupRefcountContext("set_closecb");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":445
 * 
 *     def set_closecb(self, callback):
 *         if not self.__obj:             # <<<<<<<<<<<<<<
 *             raise HttpConnectionDeleted
 *         evhttp_connection_set_closecb(self.__obj, _http_connection_closecb_handler, <void *>callback)
 */
  __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":446
 *     def set_closecb(self, callback):
 *         if not self.__obj:
 *             raise HttpConnectionDeleted             # <<<<<<<<<<<<<<
 *         evhttp_connection_set_closecb(self.__obj, _http_connection_closecb_handler, <void *>callback)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_48); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __Pyx_Raise(__pyx_1, 0, 0);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":447
 *         if not self.__obj:
 *             raise HttpConnectionDeleted
 *         evhttp_connection_set_closecb(self.__obj, _http_connection_closecb_handler, <void *>callback)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  evhttp_connection_set_closecb(((struct __pyx_obj_6gevent_4core_http_connection *)__pyx_v_self)->__pyx___obj, __pyx_f_6gevent_4core__http_connection_closecb_handler, ((void *)__pyx_v_callback));

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __Pyx_AddTraceback("gevent.core.http_connection.set_closecb");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":450
 * 
 * 
 * cdef void _http_cb_handler(evhttp_request* request, void *arg) with gil:             # <<<<<<<<<<<<<<
 *     cdef object callback = <object>arg
 *     try:
 */

static  void __pyx_f_6gevent_4core__http_cb_handler(struct evhttp_request *__pyx_v_request, void *__pyx_v_arg) {
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_r;
  PyObject *__pyx_1 = 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;
  int __pyx_t_7;
  PyGILState_STATE _save = PyGILState_Ensure();
  __Pyx_SetupRefcountContext("_http_cb_handler");
  __pyx_v_r = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":451
 * 
 * cdef void _http_cb_handler(evhttp_request* request, void *arg) with gil:
 *     cdef object callback = <object>arg             # <<<<<<<<<<<<<<
 *     try:
 *         r = http_request(<size_t>request)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_arg));
  __pyx_v_callback = ((PyObject *)__pyx_v_arg);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":452
 * cdef void _http_cb_handler(evhttp_request* request, void *arg) with gil:
 *     cdef object callback = <object>arg
 *     try:             # <<<<<<<<<<<<<<
 *         r = http_request(<size_t>request)
 *         callback(r)
 */
  {
    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":453
 *     cdef object callback = <object>arg
 *     try:
 *         r = http_request(<size_t>request)             # <<<<<<<<<<<<<<
 *         callback(r)
 *     except:
 */
      __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_request)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(((PyObject *)__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 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6gevent_4core_http_request)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_v_r);
      __pyx_v_r = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":454
 *     try:
 *         r = http_request(<size_t>request)
 *         callback(r)             # <<<<<<<<<<<<<<
 *     except:
 *         traceback.print_exc()
 */
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      __Pyx_INCREF(__pyx_v_r);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_r);
      __Pyx_GIVEREF(__pyx_v_r);
      __pyx_t_2 = PyObject_Call(__pyx_v_callback, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__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_L10_try_end;
    __pyx_L3_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":455
 *         r = http_request(<size_t>request)
 *         callback(r)
 *     except:             # <<<<<<<<<<<<<<
 *         traceback.print_exc()
 *         try:
 */
    /*except:*/ {
      __Pyx_AddTraceback("gevent.core._http_cb_handler");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":456
 *         callback(r)
 *     except:
 *         traceback.print_exc()             # <<<<<<<<<<<<<<
 *         try:
 *             sys.stderr.write('Failed to execute callback for evhttp request:\n  request = %s\n callback = %s\n\n' % (r, callback))
 */
      __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_traceback); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_1);
      __pyx_t_4 = PyObject_GetAttr(__pyx_1, __pyx_kp_print_exc); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L5_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;

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":457
 *     except:
 *         traceback.print_exc()
 *         try:             # <<<<<<<<<<<<<<
 *             sys.stderr.write('Failed to execute callback for evhttp request:\n  request = %s\n callback = %s\n\n' % (r, callback))
 *         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":458
 *         traceback.print_exc()
 *         try:
 *             sys.stderr.write('Failed to execute callback for evhttp request:\n  request = %s\n callback = %s\n\n' % (r, callback))             # <<<<<<<<<<<<<<
 *         except:
 *             pass
 */
          __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_sys); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_1);
          __pyx_t_5 = PyObject_GetAttr(__pyx_1, __pyx_kp_stderr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
          __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_kp_write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_5));
          __Pyx_INCREF(__pyx_v_r);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_r);
          __Pyx_GIVEREF(__pyx_v_r);
          __Pyx_INCREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          __pyx_t_6 = PyNumber_Remainder(__pyx_kp_98, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(((PyObject *)__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 = 458; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(((PyObject *)__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, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __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;
        }
        __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_L20_try_end;
        __pyx_L13_error:;
        __Pyx_XDECREF(__pyx_1); __pyx_1 = 0;
        __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/evhttp.pxi":459
 *         try:
 *             sys.stderr.write('Failed to execute callback for evhttp request:\n  request = %s\n callback = %s\n\n' % (r, callback))
 *         except:             # <<<<<<<<<<<<<<
 *             pass
 *         if request.response_code == 0:
 */
        /*except:*/ {
          PyErr_Restore(0,0,0);
          goto __pyx_L14_exception_handled;
        }
        __pyx_L14_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_L20_try_end:;
      }

      /* "/home/denis/work/gevent/gevent/evhttp.pxi":461
 *         except:
 *             pass
 *         if request.response_code == 0:             # <<<<<<<<<<<<<<
 *             report_internal_error(request)
 * 
 */
      __pyx_t_7 = (__pyx_v_request->response_code == 0);
      if (__pyx_t_7) {

        /* "/home/denis/work/gevent/gevent/evhttp.pxi":462
 *             pass
 *         if request.response_code == 0:
 *             report_internal_error(request)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_f_6gevent_4core_report_internal_error(__pyx_v_request);
        goto __pyx_L21;
      }
      __pyx_L21:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XDECREF(__pyx_save_exc_type);
    __Pyx_XDECREF(__pyx_save_exc_value);
    __Pyx_XDECREF(__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_1);
  __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_WriteUnraisable("gevent.core._http_cb_handler");
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_DECREF(__pyx_v_r);
  __Pyx_FinishRefcountContext();
  PyGILState_Release(_save);
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":465
 * 
 * 
 * cdef void report_internal_error(evhttp_request* request):             # <<<<<<<<<<<<<<
 *     cdef evbuffer*  c_buf = evbuffer_new()
 *     evbuffer_add(c_buf, "<h1>Internal Server Error</h1>", 30)
 */

static  void __pyx_f_6gevent_4core_report_internal_error(struct evhttp_request *__pyx_v_request) {
  struct evbuffer *__pyx_v_c_buf;
  __Pyx_SetupRefcountContext("report_internal_error");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":466
 * 
 * cdef void report_internal_error(evhttp_request* request):
 *     cdef evbuffer*  c_buf = evbuffer_new()             # <<<<<<<<<<<<<<
 *     evbuffer_add(c_buf, "<h1>Internal Server Error</h1>", 30)
 *     evhttp_send_reply(request, 500, "Internal Server Error", c_buf)
 */
  __pyx_v_c_buf = evbuffer_new();

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":467
 * cdef void report_internal_error(evhttp_request* request):
 *     cdef evbuffer*  c_buf = evbuffer_new()
 *     evbuffer_add(c_buf, "<h1>Internal Server Error</h1>", 30)             # <<<<<<<<<<<<<<
 *     evhttp_send_reply(request, 500, "Internal Server Error", c_buf)
 *     evbuffer_free(c_buf)
 */
  evbuffer_add(__pyx_v_c_buf, __pyx_k_99, 30);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":468
 *     cdef evbuffer*  c_buf = evbuffer_new()
 *     evbuffer_add(c_buf, "<h1>Internal Server Error</h1>", 30)
 *     evhttp_send_reply(request, 500, "Internal Server Error", c_buf)             # <<<<<<<<<<<<<<
 *     evbuffer_free(c_buf)
 * 
 */
  evhttp_send_reply(__pyx_v_request, 500, __pyx_k_100, __pyx_v_c_buf);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":469
 *     evbuffer_add(c_buf, "<h1>Internal Server Error</h1>", 30)
 *     evhttp_send_reply(request, 500, "Internal Server Error", c_buf)
 *     evbuffer_free(c_buf)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  evbuffer_free(__pyx_v_c_buf);

  __Pyx_FinishRefcountContext();
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":477
 *     cdef list _cbs
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.__obj = evhttp_new(current_base)
 *         self._gencb = 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) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_SetupRefcountContext("__init__");
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":478
 * 
 *     def __init__(self):
 *         self.__obj = evhttp_new(current_base)             # <<<<<<<<<<<<<<
 *         self._gencb = None
 *         self._cbs = []
 */
  ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj = evhttp_new(current_base);

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":479
 *     def __init__(self):
 *         self.__obj = evhttp_new(current_base)
 *         self._gencb = None             # <<<<<<<<<<<<<<
 *         self._cbs = []
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_gencb);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_gencb);
  ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_gencb = Py_None;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":480
 *         self.__obj = evhttp_new(current_base)
 *         self._gencb = None
 *         self._cbs = []             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_cbs);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_cbs));
  ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_cbs = __pyx_t_1;
  __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("gevent.core.http.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":482
 *         self._cbs = []
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.__obj != NULL:
 *             evhttp_free(self.__obj)
 */

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_SetupRefcountContext("__dealloc__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":483
 * 
 *     def __dealloc__(self):
 *         if self.__obj != NULL:             # <<<<<<<<<<<<<<
 *             evhttp_free(self.__obj)
 *         self.__obj = NULL
 */
  __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":484
 *     def __dealloc__(self):
 *         if self.__obj != 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":485
 *         if self.__obj != NULL:
 *             evhttp_free(self.__obj)
 *         self.__obj = NULL             # <<<<<<<<<<<<<<
 * 
 *     property _obj:
 */
  ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj = NULL;

  __Pyx_FinishRefcountContext();
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":489
 *     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_SetupRefcountContext("__get__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":490
 * 
 *         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 = 490; __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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":492
 *             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_SetupRefcountContext("__nonzero__");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":493
 * 
 *     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":494
 *     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":496
 *             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_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":498
 *             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;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_address,&__pyx_kp_port,0};
  __Pyx_SetupRefcountContext("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_kp_address);
        if (unlikely(value)) { values[0] = value; kw_args--; }
      }
      case  1:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_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 = 498; __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 = 498; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_address = __pyx_k_50;
    }
    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 = 498; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_port = 80;
    }
  } else {
    __pyx_v_address = __pyx_k_50;
    __pyx_v_port = 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 = 498; __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 = 498; __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 = 498; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http.bind");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":499
 * 
 *     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('Cannot bind %s:%s' % (address, port))
 */
  __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":500
 *     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('Cannot bind %s:%s' % (address, port))
 * 
 */
  __pyx_t_1 = __pyx_v_res;
  if (__pyx_t_1) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":501
 *         cdef int res = evhttp_bind_socket(self.__obj, address, port)
 *         if res:
 *             raise RuntimeError('Cannot bind %s:%s' % (address, port))             # <<<<<<<<<<<<<<
 * 
 *     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 = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyInt_FromLong(__pyx_v_port); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 501; __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 = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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 = PyNumber_Remainder(__pyx_kp_101, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__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[1]; __pyx_lineno = 501; __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_AddTraceback("gevent.core.http.bind");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":503
 *             raise RuntimeError('Cannot bind %s:%s' % (address, port))
 * 
 *     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_SetupRefcountContext("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 = 503; __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:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":504
 * 
 *     def accept(self, int fd):
 *         cdef res = evhttp_accept_socket(self.__obj, fd)             # <<<<<<<<<<<<<<
 *         if res:
 *             raise RuntimeError("evhttp_accept_socket(%s) returned %s" % (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 = 504; __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":505
 *     def accept(self, int fd):
 *         cdef res = evhttp_accept_socket(self.__obj, fd)
 *         if res:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("evhttp_accept_socket(%s) returned %s" % (fd, res))
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_res); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":506
 *         cdef res = evhttp_accept_socket(self.__obj, fd)
 *         if res:
 *             raise RuntimeError("evhttp_accept_socket(%s) returned %s" % (fd, res))             # <<<<<<<<<<<<<<
 * 
 *     def start(cls, char* address='127.0.0.1', int port=80):
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_fd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 506; __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 = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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(__pyx_kp_102, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__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 = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__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 = 506; __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_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":508
 *             raise RuntimeError("evhttp_accept_socket(%s) returned %s" % (fd, res))
 * 
 *     def start(cls, char* address='127.0.0.1', int port=80):             # <<<<<<<<<<<<<<
 *         #cdef evhttp* obj = evhttp_start(address, port)
 *         #if obj:
 */

static PyObject *__pyx_pf_6gevent_4core_4http_start(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_4http_start(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_address;
  int __pyx_v_port;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_address,&__pyx_kp_port,0};
  __Pyx_SetupRefcountContext("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:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_address);
        if (unlikely(value)) { values[0] = value; kw_args--; }
      }
      case  1:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_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), "start") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 508; __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 = 508; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_address = __pyx_k_51;
    }
    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 = 508; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_port = 80;
    }
  } else {
    __pyx_v_address = __pyx_k_51;
    __pyx_v_port = 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 = 508; __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 = 508; __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("start", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("gevent.core.http.start");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":512
 *         #if obj:
 *         #    return cls(<size_t>obj)
 *         raise RuntimeError('evhttp_start failed')             # <<<<<<<<<<<<<<
 * 
 *     def set_cb(self, char* path, object callback):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_kp_103);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_103);
  __Pyx_GIVEREF(__pyx_kp_103);
  __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_Raise(__pyx_t_2, 0, 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  {__pyx_filename = __pyx_f[1]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("gevent.core.http.start");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":514
 *         raise RuntimeError('evhttp_start failed')
 * 
 *     def set_cb(self, char* path, object callback):             # <<<<<<<<<<<<<<
 *         cdef res = EVHTTP_SET_CB(self.__obj, path, _http_cb_handler, <void *>callback)
 *         if res == 0:
 */

static PyObject *__pyx_pf_6gevent_4core_4http_set_cb(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_4http_set_cb(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_path;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_res = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_path,&__pyx_kp_callback,0};
  __Pyx_SetupRefcountContext("set_cb");
  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_kp_path);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("set_cb", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 514; __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_cb") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_path = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_path) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 514; __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_path = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_path) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 514; __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("set_cb", 1, 2, 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.set_cb");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":515
 * 
 *     def set_cb(self, char* path, object callback):
 *         cdef res = EVHTTP_SET_CB(self.__obj, path, _http_cb_handler, <void *>callback)             # <<<<<<<<<<<<<<
 *         if res == 0:
 *             self._cbs.append(callback)
 */
  __pyx_t_1 = PyInt_FromLong(EVHTTP_SET_CB(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj, __pyx_v_path, __pyx_f_6gevent_4core__http_cb_handler, ((void *)__pyx_v_callback))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 515; __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":516
 *     def set_cb(self, char* path, object callback):
 *         cdef res = EVHTTP_SET_CB(self.__obj, path, _http_cb_handler, <void *>callback)
 *         if res == 0:             # <<<<<<<<<<<<<<
 *             self._cbs.append(callback)
 *             return
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_res, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 516; __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[1]; __pyx_lineno = 516; __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/evhttp.pxi":517
 *         cdef res = EVHTTP_SET_CB(self.__obj, path, _http_cb_handler, <void *>callback)
 *         if res == 0:
 *             self._cbs.append(callback)             # <<<<<<<<<<<<<<
 *             return
 *         elif res == -1:
 */
    __pyx_t_3 = PyList_Append(((PyObject *)((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_cbs), __pyx_v_callback); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":518
 *         if res == 0:
 *             self._cbs.append(callback)
 *             return             # <<<<<<<<<<<<<<
 *         elif res == -1:
 *             raise RuntimeError('evhttp_set_cb(%r, %r) returned %s: callback already exists' % (path, callback, res))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L6;
  }

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":519
 *             self._cbs.append(callback)
 *             return
 *         elif res == -1:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('evhttp_set_cb(%r, %r) returned %s: callback already exists' % (path, callback, res))
 *         else:
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_res, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 519; __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[1]; __pyx_lineno = 519; __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/evhttp.pxi":520
 *             return
 *         elif res == -1:
 *             raise RuntimeError('evhttp_set_cb(%r, %r) returned %s: callback already exists' % (path, callback, res))             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError('evhttp_set_cb(%r, %r) returned %s' % (path, callback, res))
 */
    __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 520; __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 = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_callback);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_callback);
    __Pyx_GIVEREF(__pyx_v_callback);
    __Pyx_INCREF(__pyx_v_res);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_res);
    __Pyx_GIVEREF(__pyx_v_res);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(__pyx_kp_104, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/denis/work/gevent/gevent/evhttp.pxi":522
 *             raise RuntimeError('evhttp_set_cb(%r, %r) returned %s: callback already exists' % (path, callback, res))
 *         else:
 *             raise RuntimeError('evhttp_set_cb(%r, %r) returned %s' % (path, callback, res))             # <<<<<<<<<<<<<<
 * 
 *     def set_gencb(self, callback):
 */
    __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 522; __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 = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_callback);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_callback);
    __Pyx_GIVEREF(__pyx_v_callback);
    __Pyx_INCREF(__pyx_v_res);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_res);
    __Pyx_GIVEREF(__pyx_v_res);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(__pyx_kp_105, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 522; __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_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("gevent.core.http.set_cb");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_FinishRefcountContext();
  return __pyx_r;
}

/* "/home/denis/work/gevent/gevent/evhttp.pxi":524
 *             raise RuntimeError('evhttp_set_cb(%r, %r) returned %s' % (path, callback, res))
 * 
 *     def set_gencb(self, callback):             # <<<<<<<<<<<<<<
 *         self._gencb = callback
 *         evhttp_set_gencb(self.__obj, _http_cb_handler, <void *>callback)
 */

static PyObject *__pyx_pf_6gevent_4core_4http_set_gencb(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
static PyObject *__pyx_pf_6gevent_4core_4http_set_gencb(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_SetupRefcountContext("set_gencb");

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":525
 * 
 *     def set_gencb(self, callback):
 *         self._gencb = callback             # <<<<<<<<<<<<<<
 *         evhttp_set_gencb(self.__obj, _http_cb_handler, <void *>callback)
 * 
 */
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_GOTREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_gencb);
  __Pyx_DECREF(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_gencb);
  ((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->_gencb = __pyx_v_callback;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":526
 *     def set_gencb(self, callback):
 *         self._gencb = callback
 *         evhttp_set_gencb(self.__obj, _http_cb_handler, <void *>callback)             # <<<<<<<<<<<<<<
 * 
 */
  evhttp_set_gencb(((struct __pyx_obj_6gevent_4core_http *)__pyx_v_self)->__pyx___obj, __pyx_f_6gevent_4core__http_cb_handler, ((void *)__pyx_v_callback));

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

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->_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 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_k_1, 0},
  {(char *)"arg", __pyx_getprop_6gevent_4core_5event_arg, __pyx_setprop_6gevent_4core_5event_arg, __pyx_k_2, 0},
  {(char *)"pending", __pyx_getprop_6gevent_4core_5event_pending, 0, __pyx_k_3, 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},
  {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*/
};

static PyObject *__pyx_tp_new_6gevent_4core_read_event(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_6gevent_4core_event(t, a, k);
  if (!o) return 0;
  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*/
};

static PyObject *__pyx_tp_new_6gevent_4core_write_event(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_6gevent_4core_event(t, a, k);
  if (!o) return 0;
  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*/
};

static PyObject *__pyx_tp_new_6gevent_4core_timer(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_6gevent_4core_event(t, a, k);
  if (!o) return 0;
  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*/
};

static PyObject *__pyx_tp_new_6gevent_4core_signal(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_6gevent_4core_event(t, a, k);
  if (!o) return 0;
  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*/
};

static PyObject *__pyx_tp_new_6gevent_4core_active_event(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_6gevent_4core_event(t, a, k);
  if (!o) return 0;
  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*/
};

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("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_NOARGS, __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*/
  0, /*tp_iter*/
  0, /*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*/
};

static PyObject *__pyx_tp_new_6gevent_4core_http_request(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_request(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

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("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 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, /*tp_flags*/
  __Pyx_DOCSTR("Wrapper around libevent's :class:`evhttp_request` structure."), /*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_request, /*tp_methods*/
  0, /*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*/
};

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)},
  {__Pyx_NAMESTR("set_closecb"), (PyCFunction)__pyx_pf_6gevent_4core_15http_connection_set_closecb, METH_O, __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*/
};

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->_gencb = Py_None; Py_INCREF(Py_None);
  p->_cbs = ((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->_gencb);
  Py_XDECREF(((PyObject *)p->_cbs));
  (*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->_gencb) {
    e = (*v)(p->_gencb, a); if (e) return e;
  }
  if (p->_cbs) {
    e = (*v)(p->_cbs, 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->_gencb);
  p->_gencb = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_cbs);
  p->_cbs = ((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)},
  {__Pyx_NAMESTR("start"), (PyCFunction)__pyx_pf_6gevent_4core_4http_start, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("set_cb"), (PyCFunction)__pyx_pf_6gevent_4core_4http_set_cb, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("set_gencb"), (PyCFunction)__pyx_pf_6gevent_4core_4http_set_gencb, METH_O, __Pyx_DOCSTR(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*/
  0, /*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*/
};

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_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("dns_shutdown"), (PyCFunction)__pyx_pf_6gevent_4core_dns_shutdown, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6gevent_4core_dns_shutdown)},
  {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_mdoc), /* 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___main__, __pyx_k___main__, sizeof(__pyx_k___main__), 1, 1, 1},
  {&__pyx_kp___init__, __pyx_k___init__, sizeof(__pyx_k___init__), 1, 1, 1},
  {&__pyx_kp_add, __pyx_k_add, sizeof(__pyx_k_add), 1, 1, 1},
  {&__pyx_kp_cancel, __pyx_k_cancel, sizeof(__pyx_k_cancel), 1, 1, 1},
  {&__pyx_kp___repr__, __pyx_k___repr__, sizeof(__pyx_k___repr__), 1, 1, 1},
  {&__pyx_kp___str__, __pyx_k___str__, sizeof(__pyx_k___str__), 1, 1, 1},
  {&__pyx_kp___enter__, __pyx_k___enter__, sizeof(__pyx_k___enter__), 1, 1, 1},
  {&__pyx_kp___exit__, __pyx_k___exit__, sizeof(__pyx_k___exit__), 1, 1, 1},
  {&__pyx_kp___len__, __pyx_k___len__, sizeof(__pyx_k___len__), 1, 1, 1},
  {&__pyx_kp___nonzero__, __pyx_k___nonzero__, sizeof(__pyx_k___nonzero__), 1, 1, 1},
  {&__pyx_kp_read, __pyx_k_read, sizeof(__pyx_k_read), 1, 1, 1},
  {&__pyx_kp_readline, __pyx_k_readline, sizeof(__pyx_k_readline), 1, 1, 1},
  {&__pyx_kp_readlines, __pyx_k_readlines, sizeof(__pyx_k_readlines), 1, 1, 1},
  {&__pyx_kp_detach, __pyx_k_detach, sizeof(__pyx_k_detach), 1, 1, 1},
  {&__pyx_kp__format, __pyx_k__format, sizeof(__pyx_k__format), 1, 1, 1},
  {&__pyx_kp_get_input_headers, __pyx_k_get_input_headers, sizeof(__pyx_k_get_input_headers), 1, 1, 1},
  {&__pyx_kp_send_reply, __pyx_k_send_reply, sizeof(__pyx_k_send_reply), 1, 1, 1},
  {&__pyx_kp_send_reply_start, __pyx_k_send_reply_start, sizeof(__pyx_k_send_reply_start), 1, 1, 1},
  {&__pyx_kp_send_reply_chunk, __pyx_k_send_reply_chunk, sizeof(__pyx_k_send_reply_chunk), 1, 1, 1},
  {&__pyx_kp_send_reply_end, __pyx_k_send_reply_end, sizeof(__pyx_k_send_reply_end), 1, 1, 1},
  {&__pyx_kp_send_error, __pyx_k_send_error, sizeof(__pyx_k_send_error), 1, 1, 1},
  {&__pyx_kp_find_input_header, __pyx_k_find_input_header, sizeof(__pyx_k_find_input_header), 1, 1, 1},
  {&__pyx_kp_find_output_header, __pyx_k_find_output_header, sizeof(__pyx_k_find_output_header), 1, 1, 1},
  {&__pyx_kp_add_input_header, __pyx_k_add_input_header, sizeof(__pyx_k_add_input_header), 1, 1, 1},
  {&__pyx_kp_add_output_header, __pyx_k_add_output_header, sizeof(__pyx_k_add_output_header), 1, 1, 1},
  {&__pyx_kp_remove_input_header, __pyx_k_remove_input_header, sizeof(__pyx_k_remove_input_header), 1, 1, 1},
  {&__pyx_kp_4, __pyx_k_4, sizeof(__pyx_k_4), 1, 1, 1},
  {&__pyx_kp_clear_input_headers, __pyx_k_clear_input_headers, sizeof(__pyx_k_clear_input_headers), 1, 1, 1},
  {&__pyx_kp_5, __pyx_k_5, sizeof(__pyx_k_5), 1, 1, 1},
  {&__pyx_kp_set_closecb, __pyx_k_set_closecb, sizeof(__pyx_k_set_closecb), 1, 1, 1},
  {&__pyx_kp___dealloc__, __pyx_k___dealloc__, sizeof(__pyx_k___dealloc__), 1, 1, 1},
  {&__pyx_kp_bind, __pyx_k_bind, sizeof(__pyx_k_bind), 1, 1, 1},
  {&__pyx_kp_accept, __pyx_k_accept, sizeof(__pyx_k_accept), 1, 1, 1},
  {&__pyx_kp_start, __pyx_k_start, sizeof(__pyx_k_start), 1, 1, 1},
  {&__pyx_kp_set_cb, __pyx_k_set_cb, sizeof(__pyx_k_set_cb), 1, 1, 1},
  {&__pyx_kp_set_gencb, __pyx_k_set_gencb, sizeof(__pyx_k_set_gencb), 1, 1, 1},
  {&__pyx_kp_evtype, __pyx_k_evtype, sizeof(__pyx_k_evtype), 1, 1, 1},
  {&__pyx_kp_handle, __pyx_k_handle, sizeof(__pyx_k_handle), 1, 1, 1},
  {&__pyx_kp_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 1, 1, 1},
  {&__pyx_kp_arg, __pyx_k_arg, sizeof(__pyx_k_arg), 1, 1, 1},
  {&__pyx_kp_new, __pyx_k_new, sizeof(__pyx_k_new), 1, 1, 1},
  {&__pyx_kp_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 1, 1, 1},
  {&__pyx_kp_seconds, __pyx_k_seconds, sizeof(__pyx_k_seconds), 1, 1, 1},
  {&__pyx_kp_signalnum, __pyx_k_signalnum, sizeof(__pyx_k_signalnum), 1, 1, 1},
  {&__pyx_kp_nonblock, __pyx_k_nonblock, sizeof(__pyx_k_nonblock), 1, 1, 1},
  {&__pyx_kp_name, __pyx_k_name, sizeof(__pyx_k_name), 1, 1, 1},
  {&__pyx_kp_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 1, 1, 1},
  {&__pyx_kp_ip, __pyx_k_ip, sizeof(__pyx_k_ip), 1, 1, 1},
  {&__pyx_kp_fail_requests, __pyx_k_fail_requests, sizeof(__pyx_k_fail_requests), 1, 1, 1},
  {&__pyx_kp__obj, __pyx_k__obj, sizeof(__pyx_k__obj), 1, 1, 1},
  {&__pyx_kp_size, __pyx_k_size, sizeof(__pyx_k_size), 1, 1, 1},
  {&__pyx_kp_hint, __pyx_k_hint, sizeof(__pyx_k_hint), 1, 1, 1},
  {&__pyx_kp_code, __pyx_k_code, sizeof(__pyx_k_code), 1, 1, 1},
  {&__pyx_kp_reason, __pyx_k_reason, sizeof(__pyx_k_reason), 1, 1, 1},
  {&__pyx_kp_buf, __pyx_k_buf, sizeof(__pyx_k_buf), 1, 1, 1},
  {&__pyx_kp_key, __pyx_k_key, sizeof(__pyx_k_key), 1, 1, 1},
  {&__pyx_kp_value, __pyx_k_value, sizeof(__pyx_k_value), 1, 1, 1},
  {&__pyx_kp_address, __pyx_k_address, sizeof(__pyx_k_address), 1, 1, 1},
  {&__pyx_kp_port, __pyx_k_port, sizeof(__pyx_k_port), 1, 1, 1},
  {&__pyx_kp_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 1, 1, 1},
  {&__pyx_kp_path, __pyx_k_path, sizeof(__pyx_k_path), 1, 1, 1},
  {&__pyx_kp___author__, __pyx_k___author__, sizeof(__pyx_k___author__), 1, 1, 1},
  {&__pyx_kp___copyright__, __pyx_k___copyright__, sizeof(__pyx_k___copyright__), 1, 1, 1},
  {&__pyx_kp___license__, __pyx_k___license__, sizeof(__pyx_k___license__), 1, 1, 1},
  {&__pyx_kp_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 1, 0},
  {&__pyx_kp___url__, __pyx_k___url__, sizeof(__pyx_k___url__), 1, 1, 1},
  {&__pyx_kp___version__, __pyx_k___version__, sizeof(__pyx_k___version__), 1, 1, 1},
  {&__pyx_kp_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 1, 0},
  {&__pyx_kp_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 1, 0},
  {&__pyx_kp_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 1, 0},
  {&__pyx_kp_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 1, 0},
  {&__pyx_kp_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 1, 0},
  {&__pyx_kp_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 1, 0},
  {&__pyx_kp_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 1, 0},
  {&__pyx_kp_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 1, 0},
  {&__pyx_kp_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 1, 0},
  {&__pyx_kp_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 1, 0},
  {&__pyx_kp_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 1, 0},
  {&__pyx_kp_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 1, 0},
  {&__pyx_kp___all__, __pyx_k___all__, sizeof(__pyx_k___all__), 1, 1, 1},
  {&__pyx_kp_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 1, 1, 1},
  {&__pyx_kp_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 1, 1, 1},
  {&__pyx_kp_pprint, __pyx_k_pprint, sizeof(__pyx_k_pprint), 1, 1, 1},
  {&__pyx_kp_pformat, __pyx_k_pformat, sizeof(__pyx_k_pformat), 1, 1, 1},
  {&__pyx_kp_EV_TIMEOUT, __pyx_k_EV_TIMEOUT, sizeof(__pyx_k_EV_TIMEOUT), 1, 1, 1},
  {&__pyx_kp_EV_READ, __pyx_k_EV_READ, sizeof(__pyx_k_EV_READ), 1, 1, 1},
  {&__pyx_kp_EV_WRITE, __pyx_k_EV_WRITE, sizeof(__pyx_k_EV_WRITE), 1, 1, 1},
  {&__pyx_kp_EV_SIGNAL, __pyx_k_EV_SIGNAL, sizeof(__pyx_k_EV_SIGNAL), 1, 1, 1},
  {&__pyx_kp_EV_PERSIST, __pyx_k_EV_PERSIST, sizeof(__pyx_k_EV_PERSIST), 1, 1, 1},
  {&__pyx_kp_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 1, 0},
  {&__pyx_kp_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 1, 0},
  {&__pyx_kp_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 1, 0},
  {&__pyx_kp_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 1, 0},
  {&__pyx_kp_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 1, 0},
  {&__pyx_kp_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 1, 0},
  {&__pyx_kp_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 1, 0},
  {&__pyx_kp_DNS_ERR_NONE, __pyx_k_DNS_ERR_NONE, sizeof(__pyx_k_DNS_ERR_NONE), 1, 1, 1},
  {&__pyx_kp_DNS_ERR_FORMAT, __pyx_k_DNS_ERR_FORMAT, sizeof(__pyx_k_DNS_ERR_FORMAT), 1, 1, 1},
  {&__pyx_kp_33, __pyx_k_33, sizeof(__pyx_k_33), 1, 1, 1},
  {&__pyx_kp_DNS_ERR_NOTEXIST, __pyx_k_DNS_ERR_NOTEXIST, sizeof(__pyx_k_DNS_ERR_NOTEXIST), 1, 1, 1},
  {&__pyx_kp_DNS_ERR_NOTIMPL, __pyx_k_DNS_ERR_NOTIMPL, sizeof(__pyx_k_DNS_ERR_NOTIMPL), 1, 1, 1},
  {&__pyx_kp_DNS_ERR_REFUSED, __pyx_k_DNS_ERR_REFUSED, sizeof(__pyx_k_DNS_ERR_REFUSED), 1, 1, 1},
  {&__pyx_kp_DNS_ERR_TRUNCATED, __pyx_k_DNS_ERR_TRUNCATED, sizeof(__pyx_k_DNS_ERR_TRUNCATED), 1, 1, 1},
  {&__pyx_kp_DNS_ERR_UNKNOWN, __pyx_k_DNS_ERR_UNKNOWN, sizeof(__pyx_k_DNS_ERR_UNKNOWN), 1, 1, 1},
  {&__pyx_kp_DNS_ERR_TIMEOUT, __pyx_k_DNS_ERR_TIMEOUT, sizeof(__pyx_k_DNS_ERR_TIMEOUT), 1, 1, 1},
  {&__pyx_kp_DNS_ERR_SHUTDOWN, __pyx_k_DNS_ERR_SHUTDOWN, sizeof(__pyx_k_DNS_ERR_SHUTDOWN), 1, 1, 1},
  {&__pyx_kp_34, __pyx_k_34, sizeof(__pyx_k_34), 1, 1, 1},
  {&__pyx_kp_DNS_PTR, __pyx_k_DNS_PTR, sizeof(__pyx_k_DNS_PTR), 1, 1, 1},
  {&__pyx_kp_35, __pyx_k_35, sizeof(__pyx_k_35), 1, 1, 1},
  {&__pyx_kp_DNS_QUERY_NO_SEARCH, __pyx_k_DNS_QUERY_NO_SEARCH, sizeof(__pyx_k_DNS_QUERY_NO_SEARCH), 1, 1, 1},
  {&__pyx_kp_init, __pyx_k_init, sizeof(__pyx_k_init), 1, 1, 1},
  {&__pyx_kp_get_version, __pyx_k_get_version, sizeof(__pyx_k_get_version), 1, 1, 1},
  {&__pyx_kp_get_header_version, __pyx_k_get_header_version, sizeof(__pyx_k_get_header_version), 1, 1, 1},
  {&__pyx_kp_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 1, 1, 1},
  {&__pyx_kp_msg, __pyx_k_msg, sizeof(__pyx_k_msg), 1, 1, 1},
  {&__pyx_kp_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 1, 1, 1},
  {&__pyx_kp_UserWarning, __pyx_k_UserWarning, sizeof(__pyx_k_UserWarning), 1, 1, 1},
  {&__pyx_kp_stacklevel, __pyx_k_stacklevel, sizeof(__pyx_k_stacklevel), 1, 1, 1},
  {&__pyx_kp_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 1, 0},
  {&__pyx_kp_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 1, 0},
  {&__pyx_kp_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 1, 0},
  {&__pyx_kp_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 1, 0},
  {&__pyx_kp_EVHTTP_REQUEST, __pyx_k_EVHTTP_REQUEST, sizeof(__pyx_k_EVHTTP_REQUEST), 1, 1, 1},
  {&__pyx_kp_EVHTTP_RESPONSE, __pyx_k_EVHTTP_RESPONSE, sizeof(__pyx_k_EVHTTP_RESPONSE), 1, 1, 1},
  {&__pyx_kp_EVHTTP_REQ_GET, __pyx_k_EVHTTP_REQ_GET, sizeof(__pyx_k_EVHTTP_REQ_GET), 1, 1, 1},
  {&__pyx_kp_EVHTTP_REQ_POST, __pyx_k_EVHTTP_REQ_POST, sizeof(__pyx_k_EVHTTP_REQ_POST), 1, 1, 1},
  {&__pyx_kp_EVHTTP_REQ_HEAD, __pyx_k_EVHTTP_REQ_HEAD, sizeof(__pyx_k_EVHTTP_REQ_HEAD), 1, 1, 1},
  {&__pyx_kp_EVHTTP_REQ_PUT, __pyx_k_EVHTTP_REQ_PUT, sizeof(__pyx_k_EVHTTP_REQ_PUT), 1, 1, 1},
  {&__pyx_kp_EVHTTP_REQ_DELETE, __pyx_k_EVHTTP_REQ_DELETE, sizeof(__pyx_k_EVHTTP_REQ_DELETE), 1, 1, 1},
  {&__pyx_kp_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 1, 0},
  {&__pyx_kp_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 1, 0},
  {&__pyx_kp_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 1, 0},
  {&__pyx_kp_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 1, 0},
  {&__pyx_kp_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 1, 0},
  {&__pyx_kp_46, __pyx_k_46, sizeof(__pyx_k_46), 1, 1, 1},
  {&__pyx_kp_ObjectDeleted, __pyx_k_ObjectDeleted, sizeof(__pyx_k_ObjectDeleted), 0, 1, 1},
  {&__pyx_kp_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 1, 1, 1},
  {&__pyx_kp_HttpRequestDeleted, __pyx_k_HttpRequestDeleted, sizeof(__pyx_k_HttpRequestDeleted), 0, 1, 1},
  {&__pyx_kp_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 1, 1},
  {&__pyx_kp_print_exc, __pyx_k_print_exc, sizeof(__pyx_k_print_exc), 1, 1, 1},
  {&__pyx_kp_stderr, __pyx_k_stderr, sizeof(__pyx_k_stderr), 1, 1, 1},
  {&__pyx_kp_write, __pyx_k_write, sizeof(__pyx_k_write), 1, 1, 1},
  {&__pyx_kp_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 1, 0},
  {&__pyx_kp_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 1, 0},
  {&__pyx_kp_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 1, 0},
  {&__pyx_kp_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 1, 0},
  {&__pyx_kp_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 1, 0},
  {&__pyx_kp_append, __pyx_k_append, sizeof(__pyx_k_append), 1, 1, 1},
  {&__pyx_kp_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 1, 1, 1},
  {&__pyx_kp_join, __pyx_k_join, sizeof(__pyx_k_join), 1, 1, 1},
  {&__pyx_kp_IOError, __pyx_k_IOError, sizeof(__pyx_k_IOError), 1, 1, 1},
  {&__pyx_kp_pending, __pyx_k_pending, sizeof(__pyx_k_pending), 1, 1, 1},
  {&__pyx_kp_events_str, __pyx_k_events_str, sizeof(__pyx_k_events_str), 1, 1, 1},
  {&__pyx_kp___name__, __pyx_k___name__, sizeof(__pyx_k___name__), 1, 1, 1},
  {&__pyx_kp_id, __pyx_k_id, sizeof(__pyx_k_id), 1, 1, 1},
  {&__pyx_kp_replace, __pyx_k_replace, sizeof(__pyx_k_replace), 1, 1, 1},
  {&__pyx_kp_indent, __pyx_k_indent, sizeof(__pyx_k_indent), 1, 1, 1},
  {&__pyx_kp_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 1, 1, 1},
  {&__pyx_kp_min, __pyx_k_min, sizeof(__pyx_k_min), 1, 1, 1},
  {&__pyx_kp_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 1, 1, 1},
  {&__pyx_kp___iter__, __pyx_k___iter__, sizeof(__pyx_k___iter__), 1, 1, 1},
  {&__pyx_kp_typestr, __pyx_k_typestr, sizeof(__pyx_k_typestr), 1, 1, 1},
  {&__pyx_kp_uri, __pyx_k_uri, sizeof(__pyx_k_uri), 1, 1, 1},
  {&__pyx_kp_major, __pyx_k_major, sizeof(__pyx_k_major), 1, 1, 1},
  {&__pyx_kp_minor, __pyx_k_minor, sizeof(__pyx_k_minor), 1, 1, 1},
  {&__pyx_kp_remote_host, __pyx_k_remote_host, sizeof(__pyx_k_remote_host), 1, 1, 1},
  {&__pyx_kp_remote_port, __pyx_k_remote_port, sizeof(__pyx_k_remote_port), 1, 1, 1},
  {&__pyx_kp_response_code, __pyx_k_response_code, sizeof(__pyx_k_response_code), 1, 1, 1},
  {&__pyx_kp_input_buffer, __pyx_k_input_buffer, sizeof(__pyx_k_input_buffer), 1, 1, 1},
  {&__pyx_kp_output_buffer, __pyx_k_output_buffer, sizeof(__pyx_k_output_buffer), 1, 1, 1},
  {&__pyx_kp___class__, __pyx_k___class__, sizeof(__pyx_k___class__), 1, 1, 1},
  {&__pyx_kp_get, __pyx_k_get, sizeof(__pyx_k_get), 1, 1, 1},
  {&__pyx_kp_response_code_line, __pyx_k_response_code_line, sizeof(__pyx_k_response_code_line), 1, 1, 1},
  {&__pyx_kp_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 1, 1, 1},
  {&__pyx_kp_92, __pyx_k_92, sizeof(__pyx_k_92), 1, 1, 1},
  {&__pyx_kp_peer, __pyx_k_peer, sizeof(__pyx_k_peer), 1, 1, 1},
  {&__pyx_kp_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 0},
  {&__pyx_kp_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 0},
  {&__pyx_kp_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 0},
  {&__pyx_kp_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 0},
  {&__pyx_kp_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 0},
  {&__pyx_kp_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 0},
  {&__pyx_kp_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 0},
  {&__pyx_kp_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 0},
  {&__pyx_kp_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 0},
  {&__pyx_kp_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 0},
  {&__pyx_kp_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 0},
  {&__pyx_kp_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 0},
  {&__pyx_kp_60, __pyx_k_60, sizeof(__pyx_k_60), 0, 0, 0},
  {&__pyx_kp_61, __pyx_k_61, sizeof(__pyx_k_61), 0, 0, 0},
  {&__pyx_kp_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 0},
  {&__pyx_kp_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 0},
  {&__pyx_kp_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 0},
  {&__pyx_kp_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 0, 0},
  {&__pyx_kp_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 0, 0},
  {&__pyx_kp_67, __pyx_k_67, sizeof(__pyx_k_67), 0, 0, 0},
  {&__pyx_kp_68, __pyx_k_68, sizeof(__pyx_k_68), 0, 0, 0},
  {&__pyx_kp_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 0, 0},
  {&__pyx_kp_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 0, 0},
  {&__pyx_kp_71, __pyx_k_71, sizeof(__pyx_k_71), 0, 0, 0},
  {&__pyx_kp_73, __pyx_k_73, sizeof(__pyx_k_73), 0, 0, 0},
  {&__pyx_kp_72, __pyx_k_72, sizeof(__pyx_k_72), 0, 0, 0},
  {&__pyx_kp_74, __pyx_k_74, sizeof(__pyx_k_74), 0, 0, 0},
  {&__pyx_kp_75, __pyx_k_75, sizeof(__pyx_k_75), 0, 0, 0},
  {&__pyx_kp_76, __pyx_k_76, sizeof(__pyx_k_76), 0, 0, 0},
  {&__pyx_kp_77, __pyx_k_77, sizeof(__pyx_k_77), 0, 0, 0},
  {&__pyx_kp_78, __pyx_k_78, sizeof(__pyx_k_78), 0, 0, 0},
  {&__pyx_kp_79, __pyx_k_79, sizeof(__pyx_k_79), 0, 0, 0},
  {&__pyx_kp_80, __pyx_k_80, sizeof(__pyx_k_80), 0, 0, 0},
  {&__pyx_kp_81, __pyx_k_81, sizeof(__pyx_k_81), 0, 0, 0},
  {&__pyx_kp_82, __pyx_k_82, sizeof(__pyx_k_82), 0, 0, 0},
  {&__pyx_kp_83, __pyx_k_83, sizeof(__pyx_k_83), 0, 0, 0},
  {&__pyx_kp_84, __pyx_k_84, sizeof(__pyx_k_84), 0, 0, 0},
  {&__pyx_kp_85, __pyx_k_85, sizeof(__pyx_k_85), 0, 0, 0},
  {&__pyx_kp_86, __pyx_k_86, sizeof(__pyx_k_86), 0, 0, 0},
  {&__pyx_kp_87, __pyx_k_87, sizeof(__pyx_k_87), 0, 0, 0},
  {&__pyx_kp_88, __pyx_k_88, sizeof(__pyx_k_88), 0, 0, 0},
  {&__pyx_kp_89, __pyx_k_89, sizeof(__pyx_k_89), 0, 0, 0},
  {&__pyx_kp_90, __pyx_k_90, sizeof(__pyx_k_90), 0, 0, 0},
  {&__pyx_kp_91, __pyx_k_91, sizeof(__pyx_k_91), 0, 0, 0},
  {&__pyx_kp_93, __pyx_k_93, sizeof(__pyx_k_93), 0, 0, 0},
  {&__pyx_kp_94, __pyx_k_94, sizeof(__pyx_k_94), 0, 0, 0},
  {&__pyx_kp_95, __pyx_k_95, sizeof(__pyx_k_95), 0, 0, 0},
  {&__pyx_kp_96, __pyx_k_96, sizeof(__pyx_k_96), 0, 0, 0},
  {&__pyx_kp_97, __pyx_k_97, sizeof(__pyx_k_97), 0, 0, 0},
  {&__pyx_kp_98, __pyx_k_98, sizeof(__pyx_k_98), 0, 0, 0},
  {&__pyx_kp_101, __pyx_k_101, sizeof(__pyx_k_101), 0, 0, 0},
  {&__pyx_kp_102, __pyx_k_102, sizeof(__pyx_k_102), 0, 0, 0},
  {&__pyx_kp_103, __pyx_k_103, sizeof(__pyx_k_103), 0, 0, 0},
  {&__pyx_kp_104, __pyx_k_104, sizeof(__pyx_k_104), 0, 0, 0},
  {&__pyx_kp_105, __pyx_k_105, sizeof(__pyx_k_105), 0, 0, 0},
  {0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_UserWarning = __Pyx_GetName(__pyx_b, __pyx_kp_UserWarning); if (!__pyx_builtin_UserWarning) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AttributeError = __Pyx_GetName(__pyx_b, __pyx_kp_AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_hex = __Pyx_GetName(__pyx_b, __pyx_kp_hex); if (!__pyx_builtin_hex) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_kp_IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_id = __Pyx_GetName(__pyx_b, __pyx_kp_id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_kp_NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_min = __Pyx_GetName(__pyx_b, __pyx_kp_min); if (!__pyx_builtin_min) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_kp_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_kp_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitGlobals(void) {
  __pyx_int_0x01 = PyInt_FromLong(0x01); if (unlikely(!__pyx_int_0x01)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0x02 = PyInt_FromLong(0x02); if (unlikely(!__pyx_int_0x02)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0x04 = PyInt_FromLong(0x04); if (unlikely(!__pyx_int_0x04)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0x08 = PyInt_FromLong(0x08); if (unlikely(!__pyx_int_0x08)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0x10 = PyInt_FromLong(0x10); if (unlikely(!__pyx_int_0x10)) {__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_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_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;};
  __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;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initcore(void); /*proto*/
PyMODINIT_FUNC initcore(void)
#else
PyMODINIT_FUNC PyInit_core(void); /*proto*/
PyMODINIT_FUNC PyInit_core(void)
#endif
{
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  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;
  #ifdef CYTHON_REFNANNY
  void* __pyx_refchk = NULL;
  __Pyx_Refnanny = __Pyx_ImportRefcountAPI("refnanny");
  if (!__Pyx_Refnanny) {
      PyErr_Clear();
      __Pyx_Refnanny = __Pyx_ImportRefcountAPI("Cython.Runtime.refnanny");
      if (!__Pyx_Refnanny)
          Py_FatalError("failed to import refnanny module");
  }
  __pyx_refchk = __Pyx_Refnanny->NewContext("PyMODINIT_FUNC PyInit_core(void)", __LINE__, __FILE__);
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Library function declarations ---*/
  __pyx_init_filenames();
  /*--- 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
  /*--- 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;}
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("core"), __pyx_methods, __pyx_mdoc, 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;};
  if (__pyx_module_is_main_gevent__core) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_kp___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;}
  __pyx_skip_dispatch = 0;
  /*--- Global init code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  if (PyType_Ready(&__pyx_type_6gevent_4core_event) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __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 = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_event = &__pyx_type_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 = 286; __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 = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_read_event = &__pyx_type_6gevent_4core_read_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 = 294; __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 = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_write_event = &__pyx_type_6gevent_4core_write_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 = 318; __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 = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_timer = &__pyx_type_6gevent_4core_timer;
  __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 = 328; __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 = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6gevent_4core_signal = &__pyx_type_6gevent_4core_signal;
  __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 = 338; __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 = 338; __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 = 17; __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 = 17; __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 = 110; __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 = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __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 = 400; __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 = 400; __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 = 472; __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 = 472; __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',
 *                   'Copyright (c) 2003 Martin Murray' )
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_kp_6);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_6);
  __Pyx_GIVEREF(__pyx_kp_6);
  __Pyx_INCREF(__pyx_kp_7);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_7);
  __Pyx_GIVEREF(__pyx_kp_7);
  if (PyObject_SetAttr(__pyx_m, __pyx_kp___author__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":33
 *                'Martin Murray <mmurray@monkey.org>' )
 * __copyright__ = ( 'Copyright (c) 2004 Dug Song',
 *                   'Copyright (c) 2003 Martin Murray' )             # <<<<<<<<<<<<<<
 * __license__ = 'BSD'
 * __url__ = 'http://monkey.org/~dugsong/pyevent/'
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_kp_8);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_8);
  __Pyx_GIVEREF(__pyx_kp_8);
  __Pyx_INCREF(__pyx_kp_9);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_9);
  __Pyx_GIVEREF(__pyx_kp_9);
  if (PyObject_SetAttr(__pyx_m, __pyx_kp___copyright__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":34
 * __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_kp___license__, __pyx_kp_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":35
 *                   'Copyright (c) 2003 Martin Murray' )
 * __license__ = 'BSD'
 * __url__ = 'http://monkey.org/~dugsong/pyevent/'             # <<<<<<<<<<<<<<
 * __version__ = '0.4+'
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp___url__, __pyx_kp_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":36
 * __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_kp___version__, __pyx_kp_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":39
 * 
 * __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 = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_kp_13);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_13);
  __Pyx_GIVEREF(__pyx_kp_13);
  __Pyx_INCREF(__pyx_kp_14);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_kp_14);
  __Pyx_GIVEREF(__pyx_kp_14);
  __Pyx_INCREF(__pyx_kp_15);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_kp_15);
  __Pyx_GIVEREF(__pyx_kp_15);
  __Pyx_INCREF(__pyx_kp_16);
  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_kp_16);
  __Pyx_GIVEREF(__pyx_kp_16);
  __Pyx_INCREF(__pyx_kp_17);
  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_kp_17);
  __Pyx_GIVEREF(__pyx_kp_17);
  __Pyx_INCREF(__pyx_kp_18);
  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_kp_18);
  __Pyx_GIVEREF(__pyx_kp_18);
  __Pyx_INCREF(__pyx_kp_19);
  PyList_SET_ITEM(__pyx_t_1, 6, __pyx_kp_19);
  __Pyx_GIVEREF(__pyx_kp_19);
  __Pyx_INCREF(__pyx_kp_20);
  PyList_SET_ITEM(__pyx_t_1, 7, __pyx_kp_20);
  __Pyx_GIVEREF(__pyx_kp_20);
  __Pyx_INCREF(__pyx_kp_21);
  PyList_SET_ITEM(__pyx_t_1, 8, __pyx_kp_21);
  __Pyx_GIVEREF(__pyx_kp_21);
  __Pyx_INCREF(__pyx_kp_22);
  PyList_SET_ITEM(__pyx_t_1, 9, __pyx_kp_22);
  __Pyx_GIVEREF(__pyx_kp_22);
  __Pyx_INCREF(__pyx_kp_23);
  PyList_SET_ITEM(__pyx_t_1, 10, __pyx_kp_23);
  __Pyx_GIVEREF(__pyx_kp_23);
  __Pyx_INCREF(__pyx_kp_24);
  PyList_SET_ITEM(__pyx_t_1, 11, __pyx_kp_24);
  __Pyx_GIVEREF(__pyx_kp_24);
  if (PyObject_SetAttr(__pyx_m, __pyx_kp___all__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":42
 * # note, that .pxi files append stuff to __all__
 * 
 * import sys             # <<<<<<<<<<<<<<
 * import traceback
 * from pprint import pformat
 */
  __pyx_1 = __Pyx_Import(__pyx_kp_sys, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_sys, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":43
 * 
 * import sys
 * import traceback             # <<<<<<<<<<<<<<
 * from pprint import pformat
 * 
 */
  __pyx_1 = __Pyx_Import(__pyx_kp_traceback, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_traceback, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":44
 * import sys
 * import traceback
 * from pprint import pformat             # <<<<<<<<<<<<<<
 * 
 * DEF EVENT_INTERNAL_AVAILABLE = False
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_kp_pformat);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_pformat);
  __Pyx_GIVEREF(__pyx_kp_pformat);
  __pyx_1 = __Pyx_Import(__pyx_kp_pprint, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_pformat); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_pformat, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":125
 * 
 * 
 * EV_TIMEOUT = 0x01             # <<<<<<<<<<<<<<
 * EV_READ    = 0x02
 * EV_WRITE   = 0x04
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_EV_TIMEOUT, __pyx_int_0x01) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":126
 * 
 * EV_TIMEOUT = 0x01
 * EV_READ    = 0x02             # <<<<<<<<<<<<<<
 * EV_WRITE   = 0x04
 * EV_SIGNAL  = 0x08
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_EV_READ, __pyx_int_0x02) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":127
 * EV_TIMEOUT = 0x01
 * EV_READ    = 0x02
 * EV_WRITE   = 0x04             # <<<<<<<<<<<<<<
 * EV_SIGNAL  = 0x08
 * EV_PERSIST = 0x10
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_EV_WRITE, __pyx_int_0x04) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":128
 * EV_READ    = 0x02
 * EV_WRITE   = 0x04
 * EV_SIGNAL  = 0x08             # <<<<<<<<<<<<<<
 * EV_PERSIST = 0x10
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_EV_SIGNAL, __pyx_int_0x08) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":129
 * EV_WRITE   = 0x04
 * EV_SIGNAL  = 0x08
 * EV_PERSIST = 0x10             # <<<<<<<<<<<<<<
 * 
 * cdef void __event_handler(int fd, short evtype, void *arg) with gil:
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_EV_PERSIST, __pyx_int_0x10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":370
 * 
 * 
 * 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_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_k_25 = __pyx_t_1;
  __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_k_25);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":2
 * __all__ += ['dns_init', 'dns_shutdown', 'dns_resolve_ipv4', 'dns_resolve_ipv6',
 *             'dns_resolve_reverse', 'dns_resolve_reverse_ipv6', 'dns_shutdown']             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "netinet/in.h":
 */
  __pyx_t_1 = PyList_New(7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_kp_26);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_26);
  __Pyx_GIVEREF(__pyx_kp_26);
  __Pyx_INCREF(__pyx_kp_27);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_kp_27);
  __Pyx_GIVEREF(__pyx_kp_27);
  __Pyx_INCREF(__pyx_kp_28);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_kp_28);
  __Pyx_GIVEREF(__pyx_kp_28);
  __Pyx_INCREF(__pyx_kp_29);
  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_kp_29);
  __Pyx_GIVEREF(__pyx_kp_29);
  __Pyx_INCREF(__pyx_kp_30);
  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_kp_30);
  __Pyx_GIVEREF(__pyx_kp_30);
  __Pyx_INCREF(__pyx_kp_31);
  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_kp_31);
  __Pyx_GIVEREF(__pyx_kp_31);
  __Pyx_INCREF(__pyx_kp_32);
  PyList_SET_ITEM(__pyx_t_1, 6, __pyx_kp_32);
  __Pyx_GIVEREF(__pyx_kp_32);
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp___all__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_1 = PyNumber_InPlaceAdd(__pyx_2, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);

  /* "/home/denis/work/gevent/gevent/evdns.pxi":1
 * __all__ += ['dns_init', 'dns_shutdown', 'dns_resolve_ipv4', 'dns_resolve_ipv6',             # <<<<<<<<<<<<<<
 *             'dns_resolve_reverse', 'dns_resolve_reverse_ipv6', 'dns_shutdown']
 * 
 */
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp___all__, __pyx_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/denis/work/gevent/gevent/evdns.pxi":41
 * 
 * # Result codes
 * DNS_ERR_NONE		= 0             # <<<<<<<<<<<<<<
 * DNS_ERR_FORMAT		= 1
 * DNS_ERR_SERVERFAILED	= 2
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DNS_ERR_NONE, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":42
 * # Result codes
 * DNS_ERR_NONE		= 0
 * DNS_ERR_FORMAT		= 1             # <<<<<<<<<<<<<<
 * DNS_ERR_SERVERFAILED	= 2
 * DNS_ERR_NOTEXIST	= 3
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DNS_ERR_FORMAT, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":43
 * 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_kp_33, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":44
 * 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_kp_DNS_ERR_NOTEXIST, __pyx_int_3) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":45
 * 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_kp_DNS_ERR_NOTIMPL, __pyx_int_4) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":46
 * 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_kp_DNS_ERR_REFUSED, __pyx_int_5) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":47
 * 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_kp_DNS_ERR_TRUNCATED, __pyx_int_65) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":48
 * 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_kp_DNS_ERR_UNKNOWN, __pyx_int_66) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":49
 * DNS_ERR_TRUNCATED	= 65
 * DNS_ERR_UNKNOWN		= 66
 * DNS_ERR_TIMEOUT		= 67             # <<<<<<<<<<<<<<
 * DNS_ERR_SHUTDOWN	= 68
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DNS_ERR_TIMEOUT, __pyx_int_67) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":50
 * DNS_ERR_UNKNOWN		= 66
 * DNS_ERR_TIMEOUT		= 67
 * DNS_ERR_SHUTDOWN	= 68             # <<<<<<<<<<<<<<
 * 
 * # Types
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DNS_ERR_SHUTDOWN, __pyx_int_68) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":53
 * 
 * # Types
 * DNS_IPv4_A		= 1             # <<<<<<<<<<<<<<
 * DNS_PTR			= 2
 * DNS_IPv6_AAAA		= 3
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_34, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":54
 * # Types
 * DNS_IPv4_A		= 1
 * DNS_PTR			= 2             # <<<<<<<<<<<<<<
 * DNS_IPv6_AAAA		= 3
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DNS_PTR, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":55
 * DNS_IPv4_A		= 1
 * DNS_PTR			= 2
 * DNS_IPv6_AAAA		= 3             # <<<<<<<<<<<<<<
 * 
 * # Flags
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_35, __pyx_int_3) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/evdns.pxi":58
 * 
 * # Flags
 * DNS_QUERY_NO_SEARCH	= 1             # <<<<<<<<<<<<<<
 * 
 * def dns_init():
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DNS_QUERY_NO_SEARCH, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/denis/work/gevent/gevent/core.pyx":424
 * 
 * # XXX - make sure event queue is always initialized.
 * init()             # <<<<<<<<<<<<<<
 * 
 * if get_version() != get_header_version() and get_header_version() is not None:
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_init); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_1 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/denis/work/gevent/gevent/core.pyx":426
 * init()
 * 
 * if get_version() != get_header_version() and get_header_version() is not None:             # <<<<<<<<<<<<<<
 *     import warnings
 *     msg = "libevent version mismatch: system version is %r but this gevent is compiled against %r" % (get_version(), get_header_version())
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_get_version); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_1 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_get_header_version); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_2 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __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[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_get_header_version); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __pyx_t_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_t_5 = (__pyx_t_3 != Py_None);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __pyx_t_5;
  } else {
    __pyx_t_6 = __pyx_t_4;
  }
  if (__pyx_t_6) {

    /* "/home/denis/work/gevent/gevent/core.pyx":427
 * 
 * if get_version() != get_header_version() and get_header_version() is not None:
 *     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_2 = __Pyx_Import(__pyx_kp_warnings, 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_2);
    if (PyObject_SetAttr(__pyx_m, __pyx_kp_warnings, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/denis/work/gevent/gevent/core.pyx":428
 * if get_version() != get_header_version() and get_header_version() is not None:
 *     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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_get_version); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __pyx_t_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_get_header_version); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_2);
    __pyx_t_2 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(__pyx_kp_36, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (PyObject_SetAttr(__pyx_m, __pyx_kp_msg, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "/home/denis/work/gevent/gevent/core.pyx":429
 *     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_1 = __Pyx_GetName(__pyx_m, __pyx_kp_warnings); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_1);
    __pyx_t_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_warn); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_msg); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_2);
    __Pyx_GIVEREF(__pyx_2);
    __Pyx_INCREF(__pyx_builtin_UserWarning);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_builtin_UserWarning);
    __Pyx_GIVEREF(__pyx_builtin_UserWarning);
    __pyx_2 = 0;
    __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_1));
    if (PyDict_SetItem(__pyx_1, __pyx_kp_stacklevel, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":1
 * __all__ += ['buffer']             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "libevent.h":
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_kp_37);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_kp_37);
  __Pyx_GIVEREF(__pyx_kp_37);
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp___all__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_2 = PyNumber_InPlaceAdd(__pyx_1, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp___all__, __pyx_2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/denis/work/gevent/gevent/evbuffer.pxi":70
 *         return ''
 * 
 *     def readlines(self, hint=-1):             # <<<<<<<<<<<<<<
 *         return list(self.__iter__())
 * 
 */
  __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(__pyx_kp_38);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_kp_38);
  __Pyx_GIVEREF(__pyx_kp_38);
  __Pyx_INCREF(__pyx_kp_39);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_kp_39);
  __Pyx_GIVEREF(__pyx_kp_39);
  __Pyx_INCREF(__pyx_kp_40);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_kp_40);
  __Pyx_GIVEREF(__pyx_kp_40);
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp___all__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_1 = PyNumber_InPlaceAdd(__pyx_2, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_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_2); __pyx_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp___all__, __pyx_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_1); __pyx_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_kp_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_kp_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_kp_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_kp_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_kp_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_kp_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_kp_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_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_2));
  if (PyDict_SetItem(__pyx_2, __pyx_int_0, __pyx_kp_41) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_int_1, __pyx_kp_42) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_int_2, __pyx_kp_43) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_int_3, __pyx_kp_44) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_int_4, __pyx_kp_45) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_46, ((PyObject *)__pyx_2)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":100
 * 
 * 
 * class ObjectDeleted(AttributeError):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_1));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_builtin_AttributeError);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_builtin_AttributeError);
  __Pyx_GIVEREF(__pyx_builtin_AttributeError);
  __pyx_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_1), __pyx_kp_ObjectDeleted, "gevent.core"); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_ObjectDeleted, __pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":103
 *     pass
 * 
 * class HttpRequestDeleted(ObjectDeleted):             # <<<<<<<<<<<<<<
 *     """Raised when an attribute is accessed of http_request instance whose _obj is 0"""
 * 
 */
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_2));
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_ObjectDeleted); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_1);
  __Pyx_GIVEREF(__pyx_1);
  __pyx_1 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_2), "__doc__", __pyx_kp_47) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __Pyx_CreateClass(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_2), __pyx_kp_HttpRequestDeleted, "gevent.core"); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_HttpRequestDeleted, __pyx_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":106
 *     """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_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_1));
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ObjectDeleted); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_2);
  __Pyx_GIVEREF(__pyx_2);
  __pyx_2 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_1), "__doc__", __pyx_kp_49) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_1), __pyx_kp_48, "gevent.core"); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_48, __pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_2); __pyx_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;

  /* "/home/denis/work/gevent/gevent/evhttp.pxi":524
 *             raise RuntimeError('evhttp_set_cb(%r, %r) returned %s' % (path, callback, res))
 * 
 *     def set_gencb(self, callback):             # <<<<<<<<<<<<<<
 *         self._gencb = callback
 *         evhttp_set_gencb(self.__obj, _http_cb_handler, <void *>callback)
 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_1);
  __Pyx_XDECREF(__pyx_2);
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("gevent.core");
  Py_DECREF(__pyx_m); __pyx_m = 0;
  __pyx_L0:;
  __Pyx_FinishRefcountContext();
  #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 *tmp_type, *tmp_value, *tmp_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;
    PyErr_NormalizeException(type, value, tb);
    if (PyErr_Occurred())
        goto bad;
    Py_INCREF(*type);
    Py_INCREF(*value);
    Py_INCREF(*tb);
    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;
    /* 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:
    Py_XDECREF(*type);
    Py_XDECREF(*value);
    Py_XDECREF(*tb);
    return -1;
}


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

#if PY_MAJOR_VERSION >= 3
    /* Note: this is a temporary work-around to prevent crashes in Python 3.0 */
    if ((tstate->exc_type != NULL) & (tstate->exc_type != Py_None)) {
        tmp_type = tstate->exc_type;
        tmp_value = tstate->exc_value;
        tmp_tb = tstate->exc_traceback;
        PyErr_NormalizeException(&type, &value, &tb);
        PyErr_NormalizeException(&tmp_type, &tmp_value, &tmp_tb);
        tstate->exc_type = 0;
        tstate->exc_value = 0;
        tstate->exc_traceback = 0;
        PyException_SetContext(value, tmp_value);
        Py_DECREF(tmp_type);
        Py_XDECREF(tmp_tb);
    }
#endif

    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 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 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 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_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

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

static INLINE int __Pyx_StrEq(const char *s1, const char *s2) {
     while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
     return *s1 == *s2;
}

static INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    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()))
                return (unsigned char)-1;
            if (unlikely(val < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned char");
                return (unsigned char)-1;
            }
            PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to unsigned char");
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    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()))
                return (unsigned short)-1;
            if (unlikely(val < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned short");
                return (unsigned short)-1;
            }
            PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to unsigned short");
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    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()))
                return (unsigned int)-1;
            if (unlikely(val < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned int");
                return (unsigned int)-1;
            }
            PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to unsigned int");
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (unlikely(val == -1 && PyErr_Occurred()))
                return (char)-1;
            PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to char");
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (unlikely(val == -1 && PyErr_Occurred()))
                return (short)-1;
            PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to short");
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (unlikely(val == -1 && PyErr_Occurred()))
                return (int)-1;
            PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to int");
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    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()))
                return (signed char)-1;
            PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to signed char");
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    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()))
                return (signed short)-1;
            PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to signed short");
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    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()))
                return (signed int)-1;
            PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to signed int");
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_CheckExact(x) || PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (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_CheckExact(x) || PyLong_Check(x))) {
        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 {
        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 INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_CheckExact(x) || PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (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_CheckExact(x) || PyLong_Check(x))) {
        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 {
        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 INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_CheckExact(x) || PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        return (long)val;
    } else
#endif
    if (likely(PyLong_CheckExact(x) || PyLong_Check(x))) {
        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 INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_CheckExact(x) || PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_CheckExact(x) || PyLong_Check(x))) {
        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 INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_CheckExact(x) || PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_CheckExact(x) || PyLong_Check(x))) {
        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 INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_CheckExact(x) || PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_CheckExact(x) || PyLong_Check(x))) {
        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);
    }
}

#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;
    PyObject *empty_string = 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;
    #if PY_MAJOR_VERSION < 3
    empty_string = PyString_FromStringAndSize("", 0);
    #else
    empty_string = PyBytes_FromStringAndSize("", 0);
    #endif
    if (!empty_string) 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,*/
        empty_string, /*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,*/
        empty_string  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(empty_string);
    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->is_identifier)) {
            *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_identifier || (t->is_unicode && t->intern)) {
            *t->p = PyUnicode_InternFromString(t->s);
        } else if (t->is_unicode) {
            *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 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 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 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 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 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;
}


