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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
66acbe44
Commit
66acbe44
authored
Feb 18, 2020
by
da-woods
Committed by
GitHub
Feb 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug with C++ comparison operators (GH-3361)
They'd generate two calls - one exception checked and one not
parent
65d5bc4a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-1
tests/run/cpp_operator_exc_handling.pyx
tests/run/cpp_operator_exc_handling.pyx
+14
-0
tests/run/cpp_operator_exc_handling_helper.hpp
tests/run/cpp_operator_exc_handling_helper.hpp
+13
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
66acbe44
...
...
@@ -12472,7 +12472,8 @@ class CmpNode(object):
result_code
if
self
.
type
.
is_pyobject
else
None
,
self
.
exception_value
,
self
.
in_nogil_context
)
code
.
putln
(
statement
)
else
:
code
.
putln
(
statement
)
def
c_operator
(
self
,
op
):
if
op
==
'is'
:
...
...
tests/run/cpp_operator_exc_handling.pyx
View file @
66acbe44
...
...
@@ -42,6 +42,10 @@ cdef extern from "cpp_operator_exc_handling_helper.hpp" nogil:
wrapped_int
&
operator
=
(
const
wrapped_int
&
other
)
except
+
ArithmeticError
wrapped_int
&
operator
=
(
const
long
long
&
vao
)
except
+
cdef
cppclass
second_call_is_different
:
second_call_is_different
()
bool
operator
<
(
const
second_call_is_different
&
)
except
+
def
assert_raised
(
f
,
*
args
,
**
kwargs
):
err
=
kwargs
.
get
(
'err'
,
None
)
...
...
@@ -268,3 +272,13 @@ def test_operator_exception_handling():
assert_raised
(
separate_exceptions
,
4
,
1
,
1
,
1
,
3
,
err
=
ArithmeticError
)
assert_raised
(
call_temp_separation
,
2
,
1
,
4
,
err
=
AttributeError
)
assert_raised
(
call_temp_separation
,
2
,
4
,
1
,
err
=
IndexError
)
def
test_only_single_call
():
"""
Previous version of the operator handling code called the operator twice
(Resulting in a crash)
>>> test_only_single_call()
False
"""
cdef
second_call_is_different
inst
return
inst
<
inst
tests/run/cpp_operator_exc_handling_helper.hpp
View file @
66acbe44
...
...
@@ -201,3 +201,16 @@ public:
return
*
this
;
}
};
class
second_call_is_different
{
int
count
;
public:
second_call_is_different
()
:
count
(
0
)
{}
bool
operator
<
(
const
second_call_is_different
&
lhs
)
{
if
(
count
>
0
)
{
return
true
;
}
++
count
;
return
false
;
}
};
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