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
3baf2bfd
Commit
3baf2bfd
authored
Feb 11, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor fix and extension to type inference for builtin type operations
parent
a59eab52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+5
-3
tests/run/type_inference.pyx
tests/run/type_inference.pyx
+2
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
3baf2bfd
...
...
@@ -4766,10 +4766,12 @@ class BinopNode(ExprNode):
return
type1
# multiplication of containers/numbers with an
# integer value always (?) returns the same type
if
type1
.
is_int
:
return
type2
elif
type2
.
is_int
:
if
type2
.
is_int
:
return
type1
elif
type2
.
is_builtin_type
and
type1
.
is_int
and
self
.
operator
==
'*'
:
# multiplication of containers/numbers with an
# integer value always (?) returns the same type
return
type2
return
py_object_type
else
:
return
self
.
compute_c_result_type
(
type1
,
type2
)
...
...
tests/run/type_inference.pyx
View file @
3baf2bfd
...
...
@@ -104,10 +104,12 @@ def builtin_type_operations():
>>> builtin_type_operations()
"""
b1
=
b'a'
*
10
b1
=
10
*
b'a'
assert
typeof
(
b1
)
==
"bytes object"
,
typeof
(
b1
)
b2
=
b'a'
+
b'b'
assert
typeof
(
b2
)
==
"bytes object"
,
typeof
(
b2
)
u1
=
u'a'
*
10
u1
=
10
*
u'a'
assert
typeof
(
u1
)
==
"unicode object"
,
typeof
(
u1
)
u2
=
u'a'
+
u'b'
assert
typeof
(
u2
)
==
"unicode object"
,
typeof
(
u2
)
...
...
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