diff options
-rw-r--r-- | Cython/Compiler/ExprNodes.py | 8 | ||||
-rw-r--r-- | Cython/Compiler/Options.py | 2 |
2 files changed, 10 insertions, 0 deletions
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(): |