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
327311c0
Commit
327311c0
authored
Feb 13, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support None as compile time constant expression
parent
108982d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
2 deletions
+10
-2
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+3
-1
tests/errors/nonconst_def_tuple.pyx
tests/errors/nonconst_def_tuple.pyx
+0
-1
tests/run/ct_DEF.pyx
tests/run/ct_DEF.pyx
+7
-0
No files found.
Cython/Compiler/Parsing.py
View file @
327311c0
...
...
@@ -691,7 +691,9 @@ def p_name(s, name):
def
wrap_compile_time_constant
(
pos
,
value
):
rep
=
repr
(
value
)
if
isinstance
(
value
,
bool
):
if
value
is
None
:
return
ExprNodes
.
NoneNode
(
pos
)
elif
isinstance
(
value
,
bool
):
return
ExprNodes
.
BoolNode
(
pos
,
value
=
value
)
elif
isinstance
(
value
,
int
):
return
ExprNodes
.
IntNode
(
pos
,
value
=
rep
)
...
...
tests/errors/nonconst_def_tuple.pyx
View file @
327311c0
...
...
@@ -8,6 +8,5 @@ x = t_non_const
_ERRORS
=
u"""
5:32: Error in compile-time expression: IndexError: tuple index out of range
7:15: Invalid type for compile-time constant: None (type NoneType)
7:15: Invalid type for compile-time constant: [1, 2, 3] (type list)
"""
tests/run/ct_DEF.pyx
View file @
327311c0
...
...
@@ -13,6 +13,7 @@ if sys.version_info[0] < 3:
DEF
TUPLE
=
(
1
,
2
,
u"buckle my shoe"
)
DEF
TRUE_FALSE
=
(
True
,
False
)
DEF
NONE
=
None
DEF
CHAR
=
c
'x'
DEF
INT0
=
-
1
...
...
@@ -156,3 +157,9 @@ def expression():
"""
cdef
int
i
=
EXPRESSION
return
i
def
none
():
"""
>>> none()
"""
return
NONE
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