Commit 7ac25eea authored by Robert Bradshaw's avatar Robert Bradshaw Committed by GitHub

Change the default of the "c_api_binop_methods" directive to False. (GH-3644)

This is a backwards incompatible change that enables Python semantics for special methods by default, while the directive allows users to opt out of it and go back to the previous C-ish Cython semantics.

See https://github.com/cython/cython/issues/2056
parent 4a6a6363
......@@ -177,7 +177,7 @@ _directive_defaults = {
'auto_pickle': None,
'cdivision': False, # was True before 0.12
'cdivision_warnings': False,
'c_api_binop_methods': True, # Change for 3.0
'c_api_binop_methods': False, # was True before 3.0
'overflowcheck': False,
'overflowcheck.fold': True,
'always_allow_keywords': True,
......
......@@ -38,21 +38,21 @@ def mix_format(a, int b, list c):
class PySubtype(unicode):
def __rmod__(self, other):
return f'PyRMOD({other})'
return f'PyRMOD({self}, {other})'
cdef class ExtSubtype(unicode):
def __mod__(one, other):
return f'ExtMOD({one}, {other})'
def __rmod__(self, other):
return f'ExtRMOD({self}, {other})'
def subtypes():
"""
>>> py, ext = subtypes()
>>> print(py)
PyRMOD(-%s-)
PyRMOD(PySub, -%s-)
>>> print(ext)
ExtMOD(-%s-, ExtSub)
ExtRMOD(ExtSub, -%s-)
"""
return [
'-%s-' % PySubtype("PySub"),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment