From 011c19875b68ea79c583b6d6c238694777cddd0c Mon Sep 17 00:00:00 2001 From: da-woods Date: Thu, 8 Dec 2022 08:19:04 +0000 Subject: Add 'cpow' as a forward compatibility to 0.29.x (GH-5060) See https://github.com/cython/cython/pull/5016 --- Cython/Compiler/ExprNodes.py | 8 ++++++++ Cython/Compiler/Options.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 2c5d70936..746e1772b 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -11779,6 +11779,14 @@ class ModNode(DivNode): class PowNode(NumBinopNode): # '**' operator. + def analyse_types(self, env): + if not env.directives['cpow']: + # Note - the check here won't catch cpow directives that don't use '**' + # but that's probably OK for a placeholder forward compatibility directive + error(self.pos, "The 'cpow' directive is provided for forward compatibility " + "and must be True") + return super(PowNode, self).analyse_types(env) + def analyse_c_operation(self, env): NumBinopNode.analyse_c_operation(self, env) if self.type.is_complex: diff --git a/Cython/Compiler/Options.py b/Cython/Compiler/Options.py index 48695dbfc..d03119fca 100644 --- a/Cython/Compiler/Options.py +++ b/Cython/Compiler/Options.py @@ -179,6 +179,7 @@ _directive_defaults = { 'cdivision': False, # was True before 0.12 'cdivision_warnings': False, 'c_api_binop_methods': True, + 'cpow': True, 'overflowcheck': False, 'overflowcheck.fold': True, 'always_allow_keywords': False, @@ -318,6 +319,7 @@ directive_types = { 'freelist': int, 'c_string_type': one_of('bytes', 'bytearray', 'str', 'unicode'), 'c_string_encoding': normalise_encoding_name, + 'cpow': bool } for key, val in _directive_defaults.items(): -- cgit v1.2.1