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):
return
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
=
node
.
local_scope
self
.
stack
.
append
(
self
.
flow
)
...
...
@@ -597,6 +601,8 @@ class CreateControlFlowGraph(CythonTransform):
# Function body block
self
.
flow
.
nextblock
()
for
arg
in
node
.
args
:
self
.
visit
(
arg
)
if
node
.
star_arg
:
self
.
flow
.
mark_argument
(
node
.
star_arg
,
TypedExprNode
(
Builtin
.
tuple_type
,
...
...
@@ -607,7 +613,7 @@ class CreateControlFlowGraph(CythonTransform):
TypedExprNode
(
Builtin
.
dict_type
,
may_be_none
=
False
),
node
.
starstar_arg
.
entry
)
self
.
visit
children
(
node
)
self
.
visit
(
node
.
body
)
# Workaround for generators
if
node
.
is_generator
:
self
.
visit
(
node
.
gbody
.
body
)
...
...
@@ -1105,15 +1111,14 @@ class CreateControlFlowGraph(CythonTransform):
return
node
def
visit_PyClassDefNode
(
self
,
node
):
self
.
flow
.
mark_assignment
(
node
.
target
,
object_expr_not_none
,
self
.
env
.
lookup
(
node
.
name
))
# TODO: add negative attribute list to "visitchildren"?
self
.
visitchildren
(
node
,
attrs
=
[
'dict'
,
'metaclass'
,
'mkw'
,
'bases'
,
'classobj'
])
self
.
visitchildren
(
node
,
attrs
=
(
'dict'
,
'metaclass'
,
'mkw'
,
'bases'
,
'class_result'
))
self
.
flow
.
mark_assignment
(
node
.
target
,
object_expr_not_none
,
self
.
env
.
lookup
(
node
.
name
))
self
.
env_stack
.
append
(
self
.
env
)
self
.
env
=
node
.
scope
self
.
flow
.
nextblock
()
self
.
visitchildren
(
node
,
attrs
=
[
'body'
]
)
self
.
visitchildren
(
node
,
attrs
=
(
'body'
,)
)
self
.
flow
.
nextblock
()
self
.
env
=
self
.
env_stack
.
pop
()
return
node
...
...
tests/errors/w_uninitialized.pyx
View file @
f9483650
...
...
@@ -74,6 +74,44 @@ def raise_stat():
exc
=
ValueError
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
=
"""
6:11: local variable 'a' referenced before assignment
12:12: local variable 'a' might be referenced before assignment
...
...
@@ -85,4 +123,11 @@ _ERRORS = """
66:13: local variable 'foo' referenced before assignment
71:17: local variable 'exc' 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