From 39ee651a45e45e31805aa94d5c119f0283637f94 Mon Sep 17 00:00:00 2001 From: da-woods Date: Sat, 10 Dec 2022 10:53:37 +0000 Subject: Fix error from combination of two Complex.c changes (#5167) Essentially SoftComplexToPy required another bit of utility code that has now become tempita. I've just skipped using this utility code --- Cython/Utility/Complex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Cython/Utility/Complex.c b/Cython/Utility/Complex.c index 6bd846033..642184486 100644 --- a/Cython/Utility/Complex.c +++ b/Cython/Utility/Complex.c @@ -349,12 +349,11 @@ static double __Pyx_SoftComplexToDouble(__pyx_t_double_complex value) { static PyObject *__pyx_Py_FromSoftComplex(__pyx_t_double_complex value); /* proto */ //////// SoftComplexToPy //////////////// -//@requires: ToPy //@requires: RealImag static PyObject *__pyx_Py_FromSoftComplex(__pyx_t_double_complex value) { if (__Pyx_CIMAG(value)) { - return __pyx_PyComplex_FromComplex(value); + return PyComplex_FromDoubles(__Pyx_CREAL(value), __Pyx_CIMAG(value)); } else { return PyFloat_FromDouble(__Pyx_CREAL(value)); } -- cgit v1.2.1 From f109a57212c5078757b0ea0f847f01b86eb19912 Mon Sep 17 00:00:00 2001 From: Matus Valo Date: Sun, 11 Dec 2022 15:05:04 +0100 Subject: Docs: Document type qualifiers (#5165) --- docs/src/userguide/language_basics.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/src/userguide/language_basics.rst b/docs/src/userguide/language_basics.rst index ff7007760..191cb32b2 100644 --- a/docs/src/userguide/language_basics.rst +++ b/docs/src/userguide/language_basics.rst @@ -317,6 +317,34 @@ and is typically what one wants). If you want to use these numeric Python types simply omit the type declaration and let them be objects. + +Type qualifiers +--------------- + +Cython supports ``const`` and ``volatile`` `C type qualifiers `_:: + + cdef volatile int i = 5 + + cdef const int sum(const int a, const int b): + return a + b + + cdef void print_const_pointer(const int *value): + print(value[0]) + + cdef void print_pointer_to_const_value(int * const value): + print(value[0]) + + cdef void print_const_pointer_to_const_value(const int * const value): + print(value[0]) + +.. Note:: + + Both type qualifiers are not supported by pure python mode. Moreover, the ``const`` modifier is unusable + in a lot of contexts since Cython needs to generate definitions and their assignments separately. Therefore + we suggest using it mainly for function argument and pointer types where ``const`` is necessary to + work with an existing C/C++ interface. + + Extension Types --------------- -- cgit v1.2.1 From cbcda04523900612ef543ac7f99d70f5bfd0ca88 Mon Sep 17 00:00:00 2001 From: AnyLeftovers <37920527+yudonglin@users.noreply.github.com> Date: Mon, 12 Dec 2022 00:28:29 -0800 Subject: Fix module struct C syntax error on windows (#5171) The module struct was being initialized with `= {}` which isn't valid C until C23 so MSVC was rejecting it --- Cython/Compiler/ModuleNode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 0a7308562..635dcd543 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -2787,7 +2787,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): env.module_cname, Naming.pymoduledef_cname)) module_state.putln("#else") - module_state.putln('static %s %s_static = {};' % ( + module_state.putln('static %s %s_static = {0};' % ( Naming.modulestate_cname, Naming.modulestateglobal_cname )) -- cgit v1.2.1