Skip to content

Commit

Permalink
cython: Explicitely declare functions as noexcept.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Jul 22, 2023
1 parent e977a41 commit 3ade5f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion openage/convert/service/export/interface/visgrep.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright 2016-2023 the openage authors. See copying.md for legal info.
# cython: legacy_implicit_noexcept=True

# If you wanna boost speed even further:
# cython: profile=False
Expand Down
9 changes: 4 additions & 5 deletions openage/cppinterface/exctranslate.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright 2015-2023 the openage authors. See copying.md for legal info.
# cython: legacy_implicit_noexcept=True

"""
Provides the raise_py_exception and describe_py_exception callbacks for
Expand Down Expand Up @@ -48,7 +47,7 @@ cdef extern from "traceback.h":
void _PyTraceback_Add(const char *funcname, const char *filename, int lineno)


cdef void PyTraceback_Add(const char *functionname, const char *filename, int lineno) with gil:
cdef void PyTraceback_Add(const char *functionname, const char *filename, int lineno) noexcept with gil:
"""
Add a new traceback stack frame.
Redirects to Python's internal _PyTraceback_Add function.
Expand All @@ -72,7 +71,7 @@ class CPPException(Exception):
self.typename = typename


cdef void py_add_backtrace_frame_from_symbol(const backtrace_symbol *symbol) with gil: # noexcept
cdef void py_add_backtrace_frame_from_symbol(const backtrace_symbol *symbol) noexcept with gil:
"""
For use as a callback with Error->backtrace->get_symbols(), from within
raise_exception.
Expand All @@ -88,7 +87,7 @@ cdef Func1[void, const backtrace_symbol *] py_backtrace_adder
py_backtrace_adder.bind_noexcept0(py_add_backtrace_frame_from_symbol)


cdef void raise_cpp_error_common(Error *cpp_error_obj, object obj_to_raise):
cdef void raise_cpp_error_common(Error *cpp_error_obj, object obj_to_raise) noexcept:
"""
Common code that is used by both raise_cpp_error and raise_cpp_pyexception.
Expand Down Expand Up @@ -168,7 +167,7 @@ cdef void raise_cpp_pyexception(PyException *cpp_pyexception_obj) except * with
# No new data was added during its C++ life.


cdef cppbool check_exception() with gil:
cdef cppbool check_exception() noexcept with gil:
# see the doc of the function pointer in exctranslate.h
return (PyErr_Occurred() != NULL)

Expand Down
5 changes: 2 additions & 3 deletions openage/cppinterface/pyobject.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright 2015-2023 the openage authors. See copying.md for legal info.
# cython: legacy_implicit_noexcept=True

from libc.stdint cimport int64_t
from libcpp cimport bool as cppbool
Expand Down Expand Up @@ -58,11 +57,11 @@ import builtins
import importlib


cdef void xincref(PyObject *ptr) with gil:
cdef void xincref(PyObject *ptr) noexcept with gil:
Py_XINCREF(ptr)


cdef void xdecref(PyObject *ptr) with gil:
cdef void xdecref(PyObject *ptr) noexcept with gil:
Py_XDECREF(ptr)


Expand Down

0 comments on commit 3ade5f0

Please sign in to comment.