Commit 5f6667c7 authored by Mark Florisson's avatar Mark Florisson

Make tests compatible with py3k

parent 0da93240
...@@ -5,7 +5,7 @@ Test the 'with gil:' statement. ...@@ -5,7 +5,7 @@ Test the 'with gil:' statement.
cimport cython cimport cython
#from libc.stdio cimport printf, puts #from libc.stdio cimport printf, puts
from cpython.ref cimport PyObject, Py_INCREF from cpython cimport PyObject, Py_INCREF
import sys import sys
...@@ -22,7 +22,7 @@ cdef void puts(char *string) with gil: ...@@ -22,7 +22,7 @@ cdef void puts(char *string) with gil:
""" """
We need this for doctest, used from nogil sections. We need this for doctest, used from nogil sections.
""" """
print string print string.decode('ascii')
# Start with some normal Python functions # Start with some normal Python functions
...@@ -391,25 +391,19 @@ def test_nogil_try_finally_propagate_exception(): ...@@ -391,25 +391,19 @@ def test_nogil_try_finally_propagate_exception():
def test_nogil_try_finally_return_in_with_gil(x): def test_nogil_try_finally_return_in_with_gil(x):
""" """
>>> test_nogil_try_finally_return_in_with_gil(10) >>> test_nogil_try_finally_return_in_with_gil(10)
(None, None, None) print me
10 10
""" """
# For some reason, this exception is set, clear it first
# (<type 'exceptions.ImportError'>,
# ImportError('cannot import name _TextTestResult',),
# <traceback object at 0x10073c4d0>)
sys.exc_clear()
with nogil: with nogil:
try: try:
with gil: with gil:
raise Exception("Swallow me!") raise Exception("Swallow me!")
finally: finally:
with gil: with gil:
print sys.exc_info() print "print me"
return x return x
print "I am not executed", sys.exc_info() print "I am not executed"
cdef void nogil_try_finally_return() nogil: cdef void nogil_try_finally_return() nogil:
try: try:
...@@ -417,18 +411,17 @@ cdef void nogil_try_finally_return() nogil: ...@@ -417,18 +411,17 @@ cdef void nogil_try_finally_return() nogil:
raise Exception("I am swallowed in nogil code... right?") raise Exception("I am swallowed in nogil code... right?")
finally: finally:
with gil: with gil:
print sys.exc_info() print "print me first"
return return
with gil: with gil:
print "I am not executed", sys.exc_info() print "I am not executed"
def test_nogil_try_finally_return(): def test_nogil_try_finally_return():
""" """
>>> test_nogil_try_finally_return() >>> test_nogil_try_finally_return()
(None, None, None) print me first
""" """
sys.exc_clear()
with nogil: with nogil:
nogil_try_finally_return() nogil_try_finally_return()
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