Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0e07b60a
Commit
0e07b60a
authored
Jul 09, 2006
by
Neil Schemenauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix AST compiler bug #1501934: incorrect LOAD/STORE_GLOBAL generation.
parent
63597f12
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
4 deletions
+20
-4
Lib/test/test_ast.py
Lib/test/test_ast.py
+1
-1
Lib/test/test_scope.py
Lib/test/test_scope.py
+11
-0
Misc/NEWS
Misc/NEWS
+3
-0
Python/ast.c
Python/ast.c
+3
-2
Python/compile.c
Python/compile.c
+2
-1
No files found.
Lib/test/test_ast.py
View file @
0e07b60a
...
@@ -160,7 +160,7 @@ exec_results = [
...
@@ -160,7 +160,7 @@ exec_results = [
(
'Module'
,
[(
'FunctionDef'
,
(
1
,
0
),
'f'
,
(
'arguments'
,
[],
None
,
None
,
[]),
[(
'Return'
,
(
1
,
8
),
(
'Num'
,
(
1
,
15
),
1
))],
[])]),
(
'Module'
,
[(
'FunctionDef'
,
(
1
,
0
),
'f'
,
(
'arguments'
,
[],
None
,
None
,
[]),
[(
'Return'
,
(
1
,
8
),
(
'Num'
,
(
1
,
15
),
1
))],
[])]),
(
'Module'
,
[(
'Delete'
,
(
1
,
0
),
[(
'Name'
,
(
1
,
4
),
'v'
,
(
'Del'
,))])]),
(
'Module'
,
[(
'Delete'
,
(
1
,
0
),
[(
'Name'
,
(
1
,
4
),
'v'
,
(
'Del'
,))])]),
(
'Module'
,
[(
'Assign'
,
(
1
,
0
),
[(
'Name'
,
(
1
,
0
),
'v'
,
(
'Store'
,))],
(
'Num'
,
(
1
,
4
),
1
))]),
(
'Module'
,
[(
'Assign'
,
(
1
,
0
),
[(
'Name'
,
(
1
,
0
),
'v'
,
(
'Store'
,))],
(
'Num'
,
(
1
,
4
),
1
))]),
(
'Module'
,
[(
'AugAssign'
,
(
1
,
0
),
(
'Name'
,
(
1
,
0
),
'v'
,
(
'
Load
'
,)),
(
'Add'
,),
(
'Num'
,
(
1
,
5
),
1
))]),
(
'Module'
,
[(
'AugAssign'
,
(
1
,
0
),
(
'Name'
,
(
1
,
0
),
'v'
,
(
'
Store
'
,)),
(
'Add'
,),
(
'Num'
,
(
1
,
5
),
1
))]),
(
'Module'
,
[(
'Print'
,
(
1
,
0
),
(
'Name'
,
(
1
,
8
),
'f'
,
(
'Load'
,)),
[(
'Num'
,
(
1
,
11
),
1
)],
False
)]),
(
'Module'
,
[(
'Print'
,
(
1
,
0
),
(
'Name'
,
(
1
,
8
),
'f'
,
(
'Load'
,)),
[(
'Num'
,
(
1
,
11
),
1
)],
False
)]),
(
'Module'
,
[(
'For'
,
(
1
,
0
),
(
'Name'
,
(
1
,
4
),
'v'
,
(
'Store'
,)),
(
'Name'
,
(
1
,
9
),
'v'
,
(
'Load'
,)),
[(
'Pass'
,
(
1
,
11
))],
[])]),
(
'Module'
,
[(
'For'
,
(
1
,
0
),
(
'Name'
,
(
1
,
4
),
'v'
,
(
'Store'
,)),
(
'Name'
,
(
1
,
9
),
'v'
,
(
'Load'
,)),
[(
'Pass'
,
(
1
,
11
))],
[])]),
(
'Module'
,
[(
'While'
,
(
1
,
0
),
(
'Name'
,
(
1
,
6
),
'v'
,
(
'Load'
,)),
[(
'Pass'
,
(
1
,
8
))],
[])]),
(
'Module'
,
[(
'While'
,
(
1
,
0
),
(
'Name'
,
(
1
,
6
),
'v'
,
(
'Load'
,)),
[(
'Pass'
,
(
1
,
8
))],
[])]),
...
...
Lib/test/test_scope.py
View file @
0e07b60a
...
@@ -299,6 +299,17 @@ except NameError:
...
@@ -299,6 +299,17 @@ except NameError:
else:
else:
raise TestFailed
raise TestFailed
# test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation
global_x = 1
def f():
global_x += 1
try:
f()
except UnboundLocalError:
pass
else:
raise TestFailed, 'scope of global_x not correctly determined'
print "
14.
complex
definitions
"
print "
14.
complex
definitions
"
def makeReturner(*lst):
def makeReturner(*lst):
...
...
Misc/NEWS
View file @
0e07b60a
...
@@ -12,6 +12,9 @@ What's New in Python 2.5 beta 2?
...
@@ -12,6 +12,9 @@ What's New in Python 2.5 beta 2?
Core and builtins
Core and builtins
-----------------
-----------------
- Bug #1501934: The scope of global variables that are locally assigned
using augmented assignment is now correctly determined.
- Bug #927248: Recursive method-wrapper objects can now safely
- Bug #927248: Recursive method-wrapper objects can now safely
be released.
be released.
...
...
Python/ast.c
View file @
0e07b60a
...
@@ -339,7 +339,7 @@ set_context(expr_ty e, expr_context_ty ctx, const node *n)
...
@@ -339,7 +339,7 @@ set_context(expr_ty e, expr_context_ty ctx, const node *n)
/* The ast defines augmented store and load contexts, but the
/* The ast defines augmented store and load contexts, but the
implementation here doesn't actually use them. The code may be
implementation here doesn't actually use them. The code may be
a little more complex than necessary as a result. It also means
a little more complex than necessary as a result. It also means
that expressions in an augmented assignment have
no
context.
that expressions in an augmented assignment have
a Store
context.
Consider restructuring so that augmented assignment uses
Consider restructuring so that augmented assignment uses
set_context(), too.
set_context(), too.
*/
*/
...
@@ -1901,7 +1901,7 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
...
@@ -1901,7 +1901,7 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
if
(
!
expr1
)
if
(
!
expr1
)
return
NULL
;
return
NULL
;
/* TODO(
jhylton): Figure out why set_context() can't be used here.
*/
/* TODO(
nas): Remove duplicated error checks (set_context does it)
*/
switch
(
expr1
->
kind
)
{
switch
(
expr1
->
kind
)
{
case
GeneratorExp_kind
:
case
GeneratorExp_kind
:
ast_error
(
ch
,
"augmented assignment to generator "
ast_error
(
ch
,
"augmented assignment to generator "
...
@@ -1923,6 +1923,7 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
...
@@ -1923,6 +1923,7 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
"assignment"
);
"assignment"
);
return
NULL
;
return
NULL
;
}
}
set_context
(
expr1
,
Store
,
ch
);
ch
=
CHILD
(
n
,
2
);
ch
=
CHILD
(
n
,
2
);
if
(
TYPE
(
ch
)
==
testlist
)
if
(
TYPE
(
ch
)
==
testlist
)
...
...
Python/compile.c
View file @
0e07b60a
...
@@ -3688,7 +3688,8 @@ compiler_augassign(struct compiler *c, stmt_ty s)
...
@@ -3688,7 +3688,8 @@ compiler_augassign(struct compiler *c, stmt_ty s)
VISIT
(
c
,
expr
,
auge
);
VISIT
(
c
,
expr
,
auge
);
break
;
break
;
case
Name_kind
:
case
Name_kind
:
VISIT
(
c
,
expr
,
s
->
v
.
AugAssign
.
target
);
if
(
!
compiler_nameop
(
c
,
e
->
v
.
Name
.
id
,
Load
))
return
0
;
VISIT
(
c
,
expr
,
s
->
v
.
AugAssign
.
value
);
VISIT
(
c
,
expr
,
s
->
v
.
AugAssign
.
value
);
ADDOP
(
c
,
inplace_binop
(
c
,
s
->
v
.
AugAssign
.
op
));
ADDOP
(
c
,
inplace_binop
(
c
,
s
->
v
.
AugAssign
.
op
));
return
compiler_nameop
(
c
,
e
->
v
.
Name
.
id
,
Store
);
return
compiler_nameop
(
c
,
e
->
v
.
Name
.
id
,
Store
);
...
...
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