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
72f826ca
Commit
72f826ca
authored
Aug 20, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix rich eq/ne comparisons with string literals if they return non-boolean values
parent
a3ace265
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
tests/run/richcmp_str_equals.py
tests/run/richcmp_str_equals.py
+22
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
72f826ca
...
...
@@ -8723,7 +8723,7 @@ class CmpNode(object):
# note: currently operand1 must get coerced to a Python object if we succeed here!
if
self
.
operator
in
(
'=='
,
'!='
):
type1
,
type2
=
operand1
.
type
,
self
.
operand2
.
type
if
type1
.
is_
pyobject
and
type2
.
is_pyobject
:
if
type1
.
is_
builtin_type
and
type2
.
is_builtin_type
:
if
type1
is
Builtin
.
unicode_type
or
type2
is
Builtin
.
unicode_type
:
self
.
special_bool_cmp_utility_code
=
UtilityCode
.
load_cached
(
"UnicodeEquals"
,
"StringTools.c"
)
self
.
special_bool_cmp_function
=
"__Pyx_PyUnicode_Equals"
...
...
tests/run/richcmp_str_equals.py
0 → 100644
View file @
72f826ca
# mode: run
class
plop
(
object
):
def
__init__
(
self
):
pass
class
testobj
(
object
):
def
__init__
(
self
):
pass
def
__eq__
(
self
,
other
):
return
plop
()
def
test_equals
():
"""
>>> result = test_equals()
>>> isinstance(result, plop)
True
"""
blah
=
testobj
()
eq
=
blah
==
'coucou'
# not every str equals returns a bool ...
return
eq
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