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
f9483650
Commit
f9483650
authored
Nov 30, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CF fix for defnodes and classes
parent
5ba30c45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
7 deletions
+57
-7
Cython/Compiler/FlowControl.py
Cython/Compiler/FlowControl.py
+12
-7
tests/errors/w_uninitialized.pyx
tests/errors/w_uninitialized.pyx
+45
-0
No files found.
Cython/Compiler/FlowControl.py
View file @
f9483650
...
@@ -583,6 +583,10 @@ class CreateControlFlowGraph(CythonTransform):
...
@@ -583,6 +583,10 @@ class CreateControlFlowGraph(CythonTransform):
return
node
return
node
def
visit_FuncDefNode
(
self
,
node
):
def
visit_FuncDefNode
(
self
,
node
):
for
arg
in
node
.
args
:
if
arg
.
default
:
self
.
visitchildren
(
arg
)
self
.
visitchildren
(
node
,
attrs
=
(
'decorators'
,))
self
.
env_stack
.
append
(
self
.
env
)
self
.
env_stack
.
append
(
self
.
env
)
self
.
env
=
node
.
local_scope
self
.
env
=
node
.
local_scope
self
.
stack
.
append
(
self
.
flow
)
self
.
stack
.
append
(
self
.
flow
)
...
@@ -597,6 +601,8 @@ class CreateControlFlowGraph(CythonTransform):
...
@@ -597,6 +601,8 @@ class CreateControlFlowGraph(CythonTransform):
# Function body block
# Function body block
self
.
flow
.
nextblock
()
self
.
flow
.
nextblock
()
for
arg
in
node
.
args
:
self
.
visit
(
arg
)
if
node
.
star_arg
:
if
node
.
star_arg
:
self
.
flow
.
mark_argument
(
node
.
star_arg
,
self
.
flow
.
mark_argument
(
node
.
star_arg
,
TypedExprNode
(
Builtin
.
tuple_type
,
TypedExprNode
(
Builtin
.
tuple_type
,
...
@@ -607,7 +613,7 @@ class CreateControlFlowGraph(CythonTransform):
...
@@ -607,7 +613,7 @@ class CreateControlFlowGraph(CythonTransform):
TypedExprNode
(
Builtin
.
dict_type
,
TypedExprNode
(
Builtin
.
dict_type
,
may_be_none
=
False
),
may_be_none
=
False
),
node
.
starstar_arg
.
entry
)
node
.
starstar_arg
.
entry
)
self
.
visit
children
(
node
)
self
.
visit
(
node
.
body
)
# Workaround for generators
# Workaround for generators
if
node
.
is_generator
:
if
node
.
is_generator
:
self
.
visit
(
node
.
gbody
.
body
)
self
.
visit
(
node
.
gbody
.
body
)
...
@@ -1105,15 +1111,14 @@ class CreateControlFlowGraph(CythonTransform):
...
@@ -1105,15 +1111,14 @@ class CreateControlFlowGraph(CythonTransform):
return
node
return
node
def
visit_PyClassDefNode
(
self
,
node
):
def
visit_PyClassDefNode
(
self
,
node
):
self
.
flow
.
mark_assignment
(
node
.
target
,
self
.
visitchildren
(
node
,
attrs
=
(
'dict'
,
'metaclass'
,
object_expr_not_none
,
self
.
env
.
lookup
(
node
.
name
))
'mkw'
,
'bases'
,
'class_result'
))
# TODO: add negative attribute list to "visitchildren"?
self
.
flow
.
mark_assignment
(
node
.
target
,
object_expr_not_none
,
self
.
visitchildren
(
node
,
attrs
=
[
'dict'
,
'metaclass'
,
self
.
env
.
lookup
(
node
.
name
))
'mkw'
,
'bases'
,
'classobj'
])
self
.
env_stack
.
append
(
self
.
env
)
self
.
env_stack
.
append
(
self
.
env
)
self
.
env
=
node
.
scope
self
.
env
=
node
.
scope
self
.
flow
.
nextblock
()
self
.
flow
.
nextblock
()
self
.
visitchildren
(
node
,
attrs
=
[
'body'
]
)
self
.
visitchildren
(
node
,
attrs
=
(
'body'
,)
)
self
.
flow
.
nextblock
()
self
.
flow
.
nextblock
()
self
.
env
=
self
.
env_stack
.
pop
()
self
.
env
=
self
.
env_stack
.
pop
()
return
node
return
node
...
...
tests/errors/w_uninitialized.pyx
View file @
f9483650
...
@@ -74,6 +74,44 @@ def raise_stat():
...
@@ -74,6 +74,44 @@ def raise_stat():
exc
=
ValueError
exc
=
ValueError
msg
=
'dummy'
msg
=
'dummy'
def
defnode_decorator
():
@
decorator
def
foo
():
pass
def
decorator
():
pass
def
defnode_default
():
def
foo
(
arg
=
default
()):
pass
def
default
():
pass
def
class_bases
():
class
foo
(
bar
):
pass
class
bar
(
object
):
pass
def
class_decorators
():
@
decorator
class
foo
(
object
):
pass
def
decorator
(
cls
):
return
cls
def
class_py3k_metaclass
():
class
foo
(
metaclass
=
Meta
):
pass
class
Meta
(
object
):
pass
def
class_py3k_args
():
class
foo
(
*
args
,
**
kwargs
):
pass
args
=
[]
kwargs
=
{}
_ERRORS
=
"""
_ERRORS
=
"""
6:11: local variable 'a' referenced before assignment
6:11: local variable 'a' referenced before assignment
12:12: local variable 'a' might be referenced before assignment
12:12: local variable 'a' might be referenced before assignment
...
@@ -85,4 +123,11 @@ _ERRORS = """
...
@@ -85,4 +123,11 @@ _ERRORS = """
66:13: local variable 'foo' referenced before assignment
66:13: local variable 'foo' referenced before assignment
71:17: local variable 'exc' referenced before assignment
71:17: local variable 'exc' referenced before assignment
71:22: local variable 'msg' referenced before assignment
71:22: local variable 'msg' referenced before assignment
78:4: local variable 'decorator' referenced before assignment
85:23: local variable 'default' referenced before assignment
91:17: local variable 'bar' referenced before assignment
97:4: local variable 'decorator' referenced before assignment
104:28: local variable 'Meta' referenced before assignment
110:19: local variable 'args' referenced before assignment
110:29: local variable 'kwargs' referenced before assignment
"""
"""
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