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
65746da8
Commit
65746da8
authored
Mar 19, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove c_class_nogil context level in parsing
parent
06d306d9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
12 deletions
+6
-12
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+6
-12
No files found.
Cython/Compiler/Parsing.py
View file @
65746da8
...
@@ -2235,7 +2235,7 @@ def p_statement(s, ctx, first_statement = 0):
...
@@ -2235,7 +2235,7 @@ def p_statement(s, ctx, first_statement = 0):
elif
s
.
sy
==
'IF'
:
elif
s
.
sy
==
'IF'
:
return
p_IF_statement
(
s
,
ctx
)
return
p_IF_statement
(
s
,
ctx
)
elif
s
.
sy
==
'@'
:
elif
s
.
sy
==
'@'
:
if
ctx
.
level
not
in
(
'module'
,
'class'
,
'c_class'
,
'
class_nogil'
,
'
function'
,
'property'
,
'module_pxd'
,
'c_class_pxd'
,
'other'
):
if
ctx
.
level
not
in
(
'module'
,
'class'
,
'c_class'
,
'function'
,
'property'
,
'module_pxd'
,
'c_class_pxd'
,
'other'
):
s
.
error
(
'decorator not allowed here'
)
s
.
error
(
'decorator not allowed here'
)
s
.
level
=
ctx
.
level
s
.
level
=
ctx
.
level
decorators
=
p_decorators
(
s
)
decorators
=
p_decorators
(
s
)
...
@@ -2260,14 +2260,12 @@ def p_statement(s, ctx, first_statement = 0):
...
@@ -2260,14 +2260,12 @@ def p_statement(s, ctx, first_statement = 0):
if
s
.
sy
!=
"class"
:
if
s
.
sy
!=
"class"
:
s
.
error
(
'ccdef statement only allowed for extension type'
)
s
.
error
(
'ccdef statement only allowed for extension type'
)
elif
s
.
sy
==
'cpdef'
:
elif
s
.
sy
==
'cpdef'
:
if
ctx
.
level
==
'c_class_nogil'
:
s
.
error
(
'cpdef statement not allowed in nogil extension type'
)
s
.
level
=
ctx
.
level
s
.
level
=
ctx
.
level
cdef_flag
=
1
cdef_flag
=
1
overridable
=
1
overridable
=
1
s
.
next
()
s
.
next
()
if
cdef_flag
:
if
cdef_flag
:
if
ctx
.
level
not
in
(
'module'
,
'module_pxd'
,
'function'
,
'c_class'
,
'c_class_
nogil'
,
'c_class_
pxd'
):
if
ctx
.
level
not
in
(
'module'
,
'module_pxd'
,
'function'
,
'c_class'
,
'c_class_pxd'
):
s
.
error
(
'cdef statement not allowed here'
)
s
.
error
(
'cdef statement not allowed here'
)
s
.
level
=
ctx
.
level
s
.
level
=
ctx
.
level
node
=
p_cdef_statement
(
s
,
ctx
(
overridable
=
overridable
,
nogil
=
nogil_flag
))
node
=
p_cdef_statement
(
s
,
ctx
(
overridable
=
overridable
,
nogil
=
nogil_flag
))
...
@@ -2287,8 +2285,6 @@ def p_statement(s, ctx, first_statement = 0):
...
@@ -2287,8 +2285,6 @@ def p_statement(s, ctx, first_statement = 0):
# as part of a cdef class
# as part of a cdef class
if
(
'pxd'
in
ctx
.
level
)
and
(
ctx
.
level
!=
'c_class_pxd'
):
if
(
'pxd'
in
ctx
.
level
)
and
(
ctx
.
level
!=
'c_class_pxd'
):
s
.
error
(
'def statement not allowed here'
)
s
.
error
(
'def statement not allowed here'
)
if
ctx
.
level
==
'c_class_nogil'
:
s
.
error
(
'def statement not allowed in nogil extension type, only cdef with nogil is allowed'
)
s
.
level
=
ctx
.
level
s
.
level
=
ctx
.
level
return
p_def_statement
(
s
,
decorators
)
return
p_def_statement
(
s
,
decorators
)
elif
s
.
sy
==
'class'
:
elif
s
.
sy
==
'class'
:
...
@@ -2299,7 +2295,7 @@ def p_statement(s, ctx, first_statement = 0):
...
@@ -2299,7 +2295,7 @@ def p_statement(s, ctx, first_statement = 0):
if
ctx
.
level
not
in
(
'module'
,
'module_pxd'
):
if
ctx
.
level
not
in
(
'module'
,
'module_pxd'
):
s
.
error
(
"include statement not allowed here"
)
s
.
error
(
"include statement not allowed here"
)
return
p_include_statement
(
s
,
ctx
)
return
p_include_statement
(
s
,
ctx
)
elif
ctx
.
level
in
(
'c_class'
,
'c_class_nogil'
)
and
s
.
sy
==
'IDENT'
and
s
.
systring
==
'property'
:
elif
ctx
.
level
==
'c_class'
and
s
.
sy
==
'IDENT'
and
s
.
systring
==
'property'
:
return
p_property_decl
(
s
)
return
p_property_decl
(
s
)
elif
s
.
sy
==
'pass'
and
ctx
.
level
!=
'property'
:
elif
s
.
sy
==
'pass'
and
ctx
.
level
!=
'property'
:
return
p_pass_statement
(
s
,
with_newline
=
True
)
return
p_pass_statement
(
s
,
with_newline
=
True
)
...
@@ -3285,7 +3281,7 @@ def p_c_modifiers(s):
...
@@ -3285,7 +3281,7 @@ def p_c_modifiers(s):
return
[]
return
[]
def
p_c_func_or_var_declaration
(
s
,
pos
,
ctx
):
def
p_c_func_or_var_declaration
(
s
,
pos
,
ctx
):
cmethod_flag
=
ctx
.
level
in
(
'c_class'
,
'c_class_pxd'
,
'c_class_nogil'
)
cmethod_flag
=
ctx
.
level
in
(
'c_class'
,
'c_class_pxd'
)
modifiers
=
p_c_modifiers
(
s
)
modifiers
=
p_c_modifiers
(
s
)
base_type
=
p_c_base_type
(
s
,
nonempty
=
1
,
templates
=
ctx
.
templates
)
base_type
=
p_c_base_type
(
s
,
nonempty
=
1
,
templates
=
ctx
.
templates
)
declarator
=
p_c_declarator
(
s
,
ctx
(
modifiers
=
modifiers
),
cmethod_flag
=
cmethod_flag
,
declarator
=
p_c_declarator
(
s
,
ctx
(
modifiers
=
modifiers
),
cmethod_flag
=
cmethod_flag
,
...
@@ -3313,7 +3309,7 @@ def p_c_func_or_var_declaration(s, pos, ctx):
...
@@ -3313,7 +3309,7 @@ def p_c_func_or_var_declaration(s, pos, ctx):
if
s
.
sy
==
':'
:
if
s
.
sy
==
':'
:
#if ctx.level == 'c_class_nogil' and not ctx.nogil:
#if ctx.level == 'c_class_nogil' and not ctx.nogil:
# s.error("Only C function declared with ccdef allowed in nogil extension")
# s.error("Only C function declared with ccdef allowed in nogil extension")
if
ctx
.
level
not
in
(
'module'
,
'c_class'
,
'module_pxd'
,
'c_class_pxd'
,
'cpp_class'
,
'c_class_nogil'
)
and
not
ctx
.
templates
:
if
ctx
.
level
not
in
(
'module'
,
'c_class'
,
'module_pxd'
,
'c_class_pxd'
,
'cpp_class'
)
and
not
ctx
.
templates
:
s
.
error
(
"C function definition not allowed here"
)
s
.
error
(
"C function definition not allowed here"
)
doc
,
suite
=
p_suite_with_docstring
(
s
,
Ctx
(
level
=
'function'
))
doc
,
suite
=
p_suite_with_docstring
(
s
,
Ctx
(
level
=
'function'
))
result
=
Nodes
.
CFuncDefNode
(
pos
,
result
=
Nodes
.
CFuncDefNode
(
pos
,
...
@@ -3341,7 +3337,7 @@ def p_c_func_or_var_declaration(s, pos, ctx):
...
@@ -3341,7 +3337,7 @@ def p_c_func_or_var_declaration(s, pos, ctx):
declarators
.
append
(
declarator
)
declarators
.
append
(
declarator
)
doc_line
=
s
.
start_line
+
1
doc_line
=
s
.
start_line
+
1
s
.
expect_newline
(
"Syntax error in C variable declaration"
,
ignore_semicolon
=
True
)
s
.
expect_newline
(
"Syntax error in C variable declaration"
,
ignore_semicolon
=
True
)
if
ctx
.
level
in
(
'c_class'
,
'c_class_pxd'
,
'c_class_nogil'
)
and
s
.
start_line
==
doc_line
:
if
ctx
.
level
in
(
'c_class'
,
'c_class_pxd'
)
and
s
.
start_line
==
doc_line
:
doc
=
p_doc_string
(
s
)
doc
=
p_doc_string
(
s
)
else
:
else
:
doc
=
None
doc
=
None
...
@@ -3547,8 +3543,6 @@ def p_c_class_definition(s, pos, ctx):
...
@@ -3547,8 +3543,6 @@ def p_c_class_definition(s, pos, ctx):
if
s
.
sy
==
':'
:
if
s
.
sy
==
':'
:
if
ctx
.
level
==
'module_pxd'
:
if
ctx
.
level
==
'module_pxd'
:
body_level
=
'c_class_pxd'
body_level
=
'c_class_pxd'
elif
nogil
:
body_level
=
'c_class_nogil'
else
:
else
:
body_level
=
'c_class'
body_level
=
'c_class'
doc
,
body
=
p_suite_with_docstring
(
s
,
Ctx
(
level
=
body_level
,
nogil
=
nogil
))
doc
,
body
=
p_suite_with_docstring
(
s
,
Ctx
(
level
=
body_level
,
nogil
=
nogil
))
...
...
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