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
Gwenaël Samain
cython
Commits
db7d6bd2
Commit
db7d6bd2
authored
Jul 17, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support parsed directive values also inside of code, not only in the top-level module comment
parent
bca173d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+8
-2
tests/errors/parsed_directive.pyx
tests/errors/parsed_directive.pyx
+17
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
db7d6bd2
...
...
@@ -889,8 +889,8 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
'The %s directive takes one compile-time integer argument'
%
optname
)
return
(
optname
,
int
(
args
[
0
].
value
))
elif
directivetype
is
str
:
if
kwds
is
not
None
or
len
(
args
)
!=
1
or
not
isinstance
(
args
[
0
],
(
ExprNodes
.
StringNode
,
ExprNodes
.
UnicodeNode
)):
if
kwds
is
not
None
or
len
(
args
)
!=
1
or
not
isinstance
(
args
[
0
],
(
ExprNodes
.
StringNode
,
ExprNodes
.
UnicodeNode
)):
raise
PostParseError
(
pos
,
'The %s directive takes one compile-time string argument'
%
optname
)
return
(
optname
,
str
(
args
[
0
].
value
))
...
...
@@ -909,6 +909,12 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
raise
PostParseError
(
pos
,
'The %s directive takes no keyword arguments'
%
optname
)
return
optname
,
[
str
(
arg
.
value
)
for
arg
in
args
]
elif
callable
(
directivetype
):
if
kwds
is
not
None
or
len
(
args
)
!=
1
or
not
isinstance
(
args
[
0
],
(
ExprNodes
.
StringNode
,
ExprNodes
.
UnicodeNode
)):
raise
PostParseError
(
pos
,
'The %s directive takes one compile-time string argument'
%
optname
)
return
(
optname
,
directivetype
(
optname
,
args
[
0
].
value
))
else
:
assert
False
...
...
tests/errors/parsed_directive.pyx
0 → 100644
View file @
db7d6bd2
# mode: error
cimport
cython
cdef
class
TestClass
:
def
foo
(
self
):
with
cython
.
c_string_encoding
(
"ascii"
):
return
### FIXME: way to many errors for my taste...
_ERRORS
=
"""
7:13: The c_string_encoding compiler directive is not allowed in with statement scope
7:19: 'c_string_encoding' not a valid cython language construct
7:19: 'c_string_encoding' not a valid cython attribute or is being used incorrectly
"""
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