Commit cf33e0c7 authored by Denis Bilenko's avatar Denis Bilenko

Hub: store both type and value of exc_info; this fixes test__exc_info.py on Python2.4

parent 6c8789c9
...@@ -459,8 +459,7 @@ if get_version() != get_header_version() and get_header_version() is not None an ...@@ -459,8 +459,7 @@ if get_version() != get_header_version() and get_header_version() is not None an
include "evbuffer.pxi" include "evbuffer.pxi"
include "evhttp.pxi" include "evhttp.pxi"
def set_exc_info(object value): def set_exc_info(object type, object value):
cdef object typ
cdef PyThreadState* tstate = PyThreadState_GET() cdef PyThreadState* tstate = PyThreadState_GET()
if tstate.exc_type != NULL: if tstate.exc_type != NULL:
Py_DECREF(<object>tstate.exc_type) Py_DECREF(<object>tstate.exc_type)
...@@ -472,9 +471,8 @@ def set_exc_info(object value): ...@@ -472,9 +471,8 @@ def set_exc_info(object value):
tstate.exc_type = NULL tstate.exc_type = NULL
tstate.exc_value = NULL tstate.exc_value = NULL
else: else:
typ = type(value) Py_INCREF(type)
Py_INCREF(typ)
Py_INCREF(value) Py_INCREF(value)
tstate.exc_type = <void*>typ tstate.exc_type = <void*>type
tstate.exc_value = <void *>value tstate.exc_value = <void *>value
tstate.exc_traceback = NULL tstate.exc_traceback = NULL
...@@ -151,7 +151,7 @@ class Hub(greenlet): ...@@ -151,7 +151,7 @@ class Hub(greenlet):
def switch(self): def switch(self):
cur = getcurrent() cur = getcurrent()
assert cur is not self, 'Cannot switch to MAINLOOP from MAINLOOP' assert cur is not self, 'Cannot switch to MAINLOOP from MAINLOOP'
exception = sys.exc_info()[1] exc_type, exc_value = sys.exc_info()[:2]
try: try:
switch_out = getattr(cur, 'switch_out', None) switch_out = getattr(cur, 'switch_out', None)
if switch_out is not None: if switch_out is not None:
...@@ -162,7 +162,7 @@ class Hub(greenlet): ...@@ -162,7 +162,7 @@ class Hub(greenlet):
sys.exc_clear() sys.exc_clear()
return greenlet.switch(self) return greenlet.switch(self)
finally: finally:
core.set_exc_info(exception) core.set_exc_info(exc_type, exc_value)
def run(self): def run(self):
global _threadlocal global _threadlocal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment