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
0722bb26
Commit
0722bb26
authored
Oct 30, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow decorators on classes in the parser, just disable them on cdef classes later on
parent
305e7ba8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+7
-5
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+2
-2
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
0722bb26
...
@@ -929,9 +929,8 @@ class DecoratorTransform(CythonTransform, SkipDeclarations):
...
@@ -929,9 +929,8 @@ class DecoratorTransform(CythonTransform, SkipDeclarations):
return
self
.
_handle_decorators
(
return
self
.
_handle_decorators
(
func_node
,
func_node
.
name
)
func_node
,
func_node
.
name
)
def
_visit_CClassDefNode
(
self
,
class_node
):
def
visit_CClassDefNode
(
self
,
class_node
):
# This doesn't currently work, so it's disabled (also in the
# This doesn't currently work, so it's disabled.
# parser).
#
#
# Problem: assignments to cdef class names do not work. They
# Problem: assignments to cdef class names do not work. They
# would require an additional check anyway, as the extension
# would require an additional check anyway, as the extension
...
@@ -941,8 +940,11 @@ class DecoratorTransform(CythonTransform, SkipDeclarations):
...
@@ -941,8 +940,11 @@ class DecoratorTransform(CythonTransform, SkipDeclarations):
self
.
visitchildren
(
class_node
)
self
.
visitchildren
(
class_node
)
if
not
class_node
.
decorators
:
if
not
class_node
.
decorators
:
return
class_node
return
class_node
return
self
.
_handle_decorators
(
error
(
class_node
.
pos
,
class_node
,
class_node
.
class_name
)
"Decorators not allowed on cdef classes (used on type '%s')"
%
class_node
.
class_name
)
return
class_node
#return self._handle_decorators(
# class_node, class_node.class_name)
def
visit_ClassDefNode
(
self
,
class_node
):
def
visit_ClassDefNode
(
self
,
class_node
):
self
.
visitchildren
(
class_node
)
self
.
visitchildren
(
class_node
)
...
...
Cython/Compiler/Parsing.py
View file @
0722bb26
...
@@ -1681,8 +1681,8 @@ def p_statement(s, ctx, first_statement = 0):
...
@@ -1681,8 +1681,8 @@ def p_statement(s, ctx, first_statement = 0):
s
.
level
=
ctx
.
level
s
.
level
=
ctx
.
level
node
=
p_cdef_statement
(
s
,
ctx
(
overridable
=
overridable
))
node
=
p_cdef_statement
(
s
,
ctx
(
overridable
=
overridable
))
if
decorators
is
not
None
:
if
decorators
is
not
None
:
if
not
isinstance
(
node
,
(
Nodes
.
CFuncDefNode
,
Nodes
.
CVarDefNode
)):
if
not
isinstance
(
node
,
(
Nodes
.
CFuncDefNode
,
Nodes
.
CVarDefNode
,
Nodes
.
CClassDefNode
)):
s
.
error
(
"Decorators can only be followed by functions or
Python
classes"
)
s
.
error
(
"Decorators can only be followed by functions or classes"
)
node
.
decorators
=
decorators
node
.
decorators
=
decorators
return
node
return
node
else
:
else
:
...
...
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