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
Boxiang Sun
cython
Commits
115ee21a
Commit
115ee21a
authored
Sep 12, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make sure Python strings (and other Python literals) do not loose their type during type analysis
parent
11f70a6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+7
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
115ee21a
...
@@ -579,12 +579,13 @@ class PyConstNode(AtomicExprNode):
...
@@ -579,12 +579,13 @@ class PyConstNode(AtomicExprNode):
# Abstract base class for constant Python values.
# Abstract base class for constant Python values.
is_literal
=
1
is_literal
=
1
type
=
py_object_type
def
is_simple
(
self
):
def
is_simple
(
self
):
return
1
return
1
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
self
.
type
=
py_object_type
pass
def
calculate_result_code
(
self
):
def
calculate_result_code
(
self
):
return
self
.
value
return
self
.
value
...
@@ -791,7 +792,11 @@ class StringNode(ConstNode):
...
@@ -791,7 +792,11 @@ class StringNode(ConstNode):
def
as_py_string_node
(
self
,
env
):
def
as_py_string_node
(
self
,
env
):
# Return a new StringNode with the same value as this node
# Return a new StringNode with the same value as this node
# but whose type is a Python type instead of a C type.
# but whose type is a Python type instead of a C type.
return
StringNode
(
self
.
pos
,
value
=
self
.
value
,
type
=
py_object_type
)
if
self
.
value
.
encoding
is
None
:
py_type
=
Builtin
.
unicode_type
else
:
py_type
=
Builtin
.
bytes_type
return
StringNode
(
self
.
pos
,
value
=
self
.
value
,
type
=
py_type
)
def
generate_evaluation_code
(
self
,
code
):
def
generate_evaluation_code
(
self
,
code
):
if
self
.
type
.
is_pyobject
:
if
self
.
type
.
is_pyobject
:
...
...
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