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
c2386524
Commit
c2386524
authored
Sep 03, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Plain Diff
Merge from stable
parents
7539be67
112e74e4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
19 deletions
+28
-19
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-0
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+19
-17
tests/errors/e_cdefassign.pyx
tests/errors/e_cdefassign.pyx
+6
-1
tests/errors/extclassattrsetting.pyx
tests/errors/extclassattrsetting.pyx
+1
-1
No files found.
Cython/Compiler/Nodes.py
View file @
c2386524
...
@@ -919,6 +919,8 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -919,6 +919,8 @@ class FuncDefNode(StatNode, BlockNode):
for
entry
in
lenv
.
var_entries
:
for
entry
in
lenv
.
var_entries
:
if
entry
.
type
.
is_pyobject
and
entry
.
init_to_none
and
entry
.
used
:
if
entry
.
type
.
is_pyobject
and
entry
.
init_to_none
and
entry
.
used
:
code
.
put_init_var_to_py_none
(
entry
)
code
.
put_init_var_to_py_none
(
entry
)
# ----- Initialise local buffer auxiliary variables
for
entry
in
lenv
.
var_entries
+
lenv
.
arg_entries
:
if
entry
.
type
.
is_buffer
and
entry
.
buffer_aux
.
buffer_info_var
.
used
:
if
entry
.
type
.
is_buffer
and
entry
.
buffer_aux
.
buffer_info_var
.
used
:
code
.
putln
(
"%s.buf = NULL;"
%
entry
.
buffer_aux
.
buffer_info_var
.
cname
)
code
.
putln
(
"%s.buf = NULL;"
%
entry
.
buffer_aux
.
buffer_info_var
.
cname
)
# ----- Check and convert arguments
# ----- Check and convert arguments
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
c2386524
...
@@ -80,7 +80,7 @@ class NormalizeTree(CythonTransform):
...
@@ -80,7 +80,7 @@ class NormalizeTree(CythonTransform):
class
PostParseError
(
CompileError
):
pass
class
PostParseError
(
CompileError
):
pass
# error strings checked by unit tests, so define them
# error strings checked by unit tests, so define them
ERR_CDEF_INCLASS
=
'Cannot assign default value to
cdef class attribute
s'
ERR_CDEF_INCLASS
=
'Cannot assign default value to
fields in cdef classes, structs or union
s'
ERR_BUF_LOCALONLY
=
'Buffer types only allowed as function local variables'
ERR_BUF_LOCALONLY
=
'Buffer types only allowed as function local variables'
ERR_BUF_DEFAULTS
=
'Invalid buffer defaults specification (see docs)'
ERR_BUF_DEFAULTS
=
'Invalid buffer defaults specification (see docs)'
ERR_INVALID_SPECIALATTR_TYPE
=
'Special attributes must not have a type declared'
ERR_INVALID_SPECIALATTR_TYPE
=
'Special attributes must not have a type declared'
...
@@ -130,31 +130,33 @@ class PostParse(CythonTransform):
...
@@ -130,31 +130,33 @@ class PostParse(CythonTransform):
def
visit_ModuleNode
(
self
,
node
):
def
visit_ModuleNode
(
self
,
node
):
self
.
scope_type
=
'module'
self
.
scope_type
=
'module'
self
.
scope_node
=
node
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
return
node
return
node
def
visit_
ClassDefNode
(
self
,
nod
e
):
def
visit_
scope
(
self
,
node
,
scope_typ
e
):
prev
=
self
.
scope_type
prev
=
self
.
scope_type
,
self
.
scope_node
self
.
scope_type
=
'class'
self
.
scope_type
=
scope_type
self
.
class
node
=
node
self
.
scope_
node
=
node
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
self
.
scope_type
=
prev
self
.
scope_type
,
self
.
scope_node
=
prev
del
self
.
classnode
return
node
return
node
def
visit_ClassDefNode
(
self
,
node
):
return
self
.
visit_scope
(
node
,
'class'
)
def
visit_FuncDefNode
(
self
,
node
):
def
visit_FuncDefNode
(
self
,
node
):
prev
=
self
.
scope_type
return
self
.
visit_scope
(
node
,
'function'
)
self
.
scope_type
=
'function'
self
.
visitchildren
(
node
)
def
visit_CStructOrUnionDefNode
(
self
,
node
):
self
.
scope_type
=
prev
return
self
.
visit_scope
(
node
,
'struct'
)
return
node
# cdef variables
# cdef variables
def
handle_bufferdefaults
(
self
,
decl
):
def
handle_bufferdefaults
(
self
,
decl
):
if
not
isinstance
(
decl
.
default
,
DictNode
):
if
not
isinstance
(
decl
.
default
,
DictNode
):
raise
PostParseError
(
decl
.
pos
,
ERR_BUF_DEFAULTS
)
raise
PostParseError
(
decl
.
pos
,
ERR_BUF_DEFAULTS
)
self
.
class
node
.
buffer_defaults_node
=
decl
.
default
self
.
scope_
node
.
buffer_defaults_node
=
decl
.
default
self
.
class
node
.
buffer_defaults_pos
=
decl
.
pos
self
.
scope_
node
.
buffer_defaults_pos
=
decl
.
pos
def
visit_CVarDefNode
(
self
,
node
):
def
visit_CVarDefNode
(
self
,
node
):
# This assumes only plain names and pointers are assignable on
# This assumes only plain names and pointers are assignable on
...
@@ -171,8 +173,8 @@ class PostParse(CythonTransform):
...
@@ -171,8 +173,8 @@ class PostParse(CythonTransform):
declbase
=
declbase
.
base
declbase
=
declbase
.
base
if
isinstance
(
declbase
,
CNameDeclaratorNode
):
if
isinstance
(
declbase
,
CNameDeclaratorNode
):
if
declbase
.
default
is
not
None
:
if
declbase
.
default
is
not
None
:
if
self
.
scope_type
==
'class'
:
if
self
.
scope_type
in
(
'class'
,
'struct'
)
:
if
isinstance
(
self
.
class
node
,
CClassDefNode
):
if
isinstance
(
self
.
scope_
node
,
CClassDefNode
):
handler
=
self
.
specialattribute_handlers
.
get
(
decl
.
name
)
handler
=
self
.
specialattribute_handlers
.
get
(
decl
.
name
)
if
handler
:
if
handler
:
if
decl
is
not
declbase
:
if
decl
is
not
declbase
:
...
...
tests/errors/e_cdefassign.pyx
View file @
c2386524
cdef
class
A
:
cdef
class
A
:
cdef
int
value
=
3
cdef
int
value
=
3
cdef
extern
from
*
:
cdef
struct
B
:
int
value
=
3
_ERRORS
=
u"""
_ERRORS
=
u"""
2:13: Cannot assign default value to cdef class attributes
2:13: Cannot assign default value to fields in cdef classes, structs or unions
6:12: Cannot assign default value to fields in cdef classes, structs or unions
"""
"""
tests/errors/extclassattrsetting.pyx
View file @
c2386524
...
@@ -13,5 +13,5 @@ cdef class ExtClass:
...
@@ -13,5 +13,5 @@ cdef class ExtClass:
_attribute
=
5
# FIXME: this is not currently handled!!!
_attribute
=
5
# FIXME: this is not currently handled!!!
_ERRORS
=
u"""
_ERRORS
=
u"""
8:13: Cannot assign default value to
cdef class attribute
s
8:13: Cannot assign default value to
fields in cdef classes, structs or union
s
"""
"""
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