Commit afb84985 authored by Robert Bradshaw's avatar Robert Bradshaw

Allow cpdef void-returning functions.

parent 8a2ea03d
...@@ -11182,7 +11182,7 @@ class CoerceToPyTypeNode(CoercionNode): ...@@ -11182,7 +11182,7 @@ class CoerceToPyTypeNode(CoercionNode):
func = func.replace("Object", self.type.name.title(), 1) func = func.replace("Object", self.type.name.title(), 1)
elif self.type is bytearray_type: elif self.type is bytearray_type:
func = func.replace("Object", "ByteArray", 1) func = func.replace("Object", "ByteArray", 1)
funccall = "%s(%s)" % (func, self.arg.result()) funccall = "%s(%s)" % (func, self.arg.result() or 'NULL')
code.putln('%s = %s; %s' % ( code.putln('%s = %s; %s' % (
self.result(), self.result(),
......
...@@ -1307,6 +1307,7 @@ class CVoidType(CType): ...@@ -1307,6 +1307,7 @@ class CVoidType(CType):
# #
is_void = 1 is_void = 1
to_py_function = "__Pyx_void_to_None"
def __repr__(self): def __repr__(self):
return "<CVoidType>" return "<CVoidType>"
......
...@@ -215,6 +215,8 @@ static CYTHON_INLINE float __PYX_NAN() { ...@@ -215,6 +215,8 @@ static CYTHON_INLINE float __PYX_NAN() {
} }
#endif #endif
#define __Pyx_void_to_None(void_result) (void_result, Py_INCREF(Py_None), Py_None)
// Work around clang bug http://stackoverflow.com/questions/21847816/c-invoke-nested-template-class-destructor // Work around clang bug http://stackoverflow.com/questions/21847816/c-invoke-nested-template-class-destructor
#ifdef __cplusplus #ifdef __cplusplus
template<typename T> template<typename T>
......
cpdef void unraisable():
"""
>>> unraisable()
here
"""
print('here')
raise RuntimeError()
cpdef void raisable() except *:
"""
>>> raisable()
Traceback (most recent call last):
...
RuntimeError
"""
print('here')
raise RuntimeError()
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