Skip to content

Commit

Permalink
Add 'cpow' as a forward compatibility to 0.29.x (GH-5060)
Browse files Browse the repository at this point in the history
See #5016
  • Loading branch information
da-woods committed Dec 8, 2022
1 parent 8930130 commit 011c198
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Cython/Compiler/ExprNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11779,6 +11779,14 @@ def py_operation_function(self, code):
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:
Expand Down
2 changes: 2 additions & 0 deletions Cython/Compiler/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def get_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,
Expand Down Expand Up @@ -318,6 +319,7 @@ def normalise_encoding_name(option_name, encoding):
'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():
Expand Down

0 comments on commit 011c198

Please sign in to comment.