diff options
author | da-woods <dw-git@d-woods.co.uk> | 2022-12-08 08:19:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-08 09:19:04 +0100 |
commit | 011c19875b68ea79c583b6d6c238694777cddd0c (patch) | |
tree | ce70bf6a2a5bef5b6523930590b5c6725234c235 | |
parent | 8930130481f27502ecfc48b21d8eb13f49ba1353 (diff) | |
download | cython-011c19875b68ea79c583b6d6c238694777cddd0c.tar.gz |
Add 'cpow' as a forward compatibility to 0.29.x (GH-5060)
See https://github.com/cython/cython/pull/5016
-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(): |