Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
54bad41c
Commit
54bad41c
authored
May 27, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.29.x'
parents
d720eb47
4ac64ddf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
85 deletions
+17
-85
CHANGES.rst
CHANGES.rst
+4
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+4
-0
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+9
-0
tests/run/binop_reverse_methods_GH2056.pyx
tests/run/binop_reverse_methods_GH2056.pyx
+0
-85
No files found.
CHANGES.rst
View file @
54bad41c
...
...
@@ -454,6 +454,10 @@ Other changes
Bugs
fixed
----------
*
Now
uses
``
Py_SET_SIZE
()``
and
``
Py_SET_REFCNT
()``
in
Py3
.9
+
to
avoid
low
-
level
write
access
to
these
object
fields
.
Patch
by
Victor
Stinner
.
(
Github
issue
#
3639
)
*
The
built
-
in
``
abs
()``
function
could
lead
to
undefined
behaviour
when
used
on
the
negative
-
most
value
of
a
signed
C
integer
type
.
Patch
by
Serge
Guelton
.
(
Github
issue
#
1911
)
...
...
Cython/Compiler/ModuleNode.py
View file @
54bad41c
...
...
@@ -2040,6 +2040,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if
scope
.
directives
[
'c_api_binop_methods'
]:
code
.
putln
(
'#define %s %s'
%
(
func_name
,
slot
.
left_slot
.
slot_code
(
scope
)))
return
else
:
error
(
self
.
pos
,
"The 'c_api_binop_methods' directive is only supported for forward compatibility"
" and must be True."
)
code
.
putln
()
preprocessor_guard
=
slot
.
preprocessor_guard_code
()
...
...
Cython/Utility/ModuleSetupCode.c
View file @
54bad41c
...
...
@@ -830,6 +830,15 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict,
#endif
#if PY_VERSION_HEX >= 0x030900A4
#define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
#define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
#define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
#define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if PY_VERSION_HEX >= 0x030900A4
#define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
#define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
...
...
tests/run/binop_reverse_methods_GH2056.pyx
deleted
100644 → 0
View file @
d720eb47
cimport
cython
@
cython
.
c_api_binop_methods
(
False
)
@
cython
.
cclass
class
Base
(
object
):
"""
>>> Base() + 2
'Base.__add__(Base(), 2)'
>>> 2 + Base()
'Base.__radd__(Base(), 2)'
>>> Base() ** 2
'Base.__pow__(Base(), 2, None)'
>>> 2 ** Base()
'Base.__rpow__(Base(), 2, None)'
>>> pow(Base(), 2, 100)
'Base.__pow__(Base(), 2, 100)'
"""
def
__add__
(
self
,
other
):
return
"Base.__add__(%s, %s)"
%
(
self
,
other
)
def
__radd__
(
self
,
other
):
return
"Base.__radd__(%s, %s)"
%
(
self
,
other
)
def
__pow__
(
self
,
other
,
mod
):
return
"Base.__pow__(%s, %s, %s)"
%
(
self
,
other
,
mod
)
def
__rpow__
(
self
,
other
,
mod
):
return
"Base.__rpow__(%s, %s, %s)"
%
(
self
,
other
,
mod
)
def
__repr__
(
self
):
return
"%s()"
%
(
self
.
__class__
.
__name__
)
@
cython
.
c_api_binop_methods
(
False
)
@
cython
.
cclass
class
OverloadLeft
(
Base
):
"""
>>> OverloadLeft() + 2
'OverloadLeft.__add__(OverloadLeft(), 2)'
>>> 2 + OverloadLeft()
'Base.__radd__(OverloadLeft(), 2)'
>>> OverloadLeft() + Base()
'OverloadLeft.__add__(OverloadLeft(), Base())'
>>> Base() + OverloadLeft()
'Base.__add__(Base(), OverloadLeft())'
"""
def
__add__
(
self
,
other
):
return
"OverloadLeft.__add__(%s, %s)"
%
(
self
,
other
)
@
cython
.
c_api_binop_methods
(
False
)
@
cython
.
cclass
class
OverloadRight
(
Base
):
"""
>>> OverloadRight() + 2
'Base.__add__(OverloadRight(), 2)'
>>> 2 + OverloadRight()
'OverloadRight.__radd__(OverloadRight(), 2)'
>>> OverloadRight() + Base()
'Base.__add__(OverloadRight(), Base())'
>>> Base() + OverloadRight()
'OverloadRight.__radd__(OverloadRight(), Base())'
"""
def
__radd__
(
self
,
other
):
return
"OverloadRight.__radd__(%s, %s)"
%
(
self
,
other
)
@
cython
.
c_api_binop_methods
(
True
)
@
cython
.
cclass
class
OverloadCApi
(
Base
):
"""
>>> OverloadCApi() + 2
'OverloadCApi.__add__(OverloadCApi(), 2)'
>>> 2 + OverloadCApi()
'OverloadCApi.__add__(2, OverloadCApi())'
>>> OverloadCApi() + Base()
'OverloadCApi.__add__(OverloadCApi(), Base())'
>>> Base() + OverloadCApi()
'OverloadCApi.__add__(Base(), OverloadCApi())'
"""
def
__add__
(
self
,
other
):
return
"OverloadCApi.__add__(%s, %s)"
%
(
self
,
other
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment