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
552e7a7e
Commit
552e7a7e
authored
Jun 28, 2009
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return locals and cells in get_locals() not bound globals, though
parent
8f7b94ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
Lib/symtable.py
Lib/symtable.py
+4
-2
Lib/test/test_symtable.py
Lib/test/test_symtable.py
+1
-1
No files found.
Lib/symtable.py
View file @
552e7a7e
...
...
@@ -3,7 +3,7 @@
import
_symtable
from
_symtable
import
(
USE
,
DEF_GLOBAL
,
DEF_LOCAL
,
DEF_PARAM
,
DEF_IMPORT
,
DEF_BOUND
,
OPT_IMPORT_STAR
,
OPT_EXEC
,
OPT_BARE_EXEC
,
SCOPE_OFF
,
SCOPE_MASK
,
FREE
,
GLOBAL_IMPLICIT
,
GLOBAL_EXPLICIT
)
SCOPE_OFF
,
SCOPE_MASK
,
FREE
,
GLOBAL_IMPLICIT
,
GLOBAL_EXPLICIT
,
CELL
,
LOCAL
)
import
weakref
...
...
@@ -137,7 +137,9 @@ class Function(SymbolTable):
def
get_locals
(
self
):
if
self
.
__locals
is
None
:
self
.
__locals
=
self
.
__idents_matching
(
lambda
x
:
x
&
DEF_BOUND
)
locs
=
(
LOCAL
,
CELL
)
test
=
lambda
x
:
((
x
>>
SCOPE_OFF
)
&
SCOPE_MASK
)
in
locs
self
.
__locals
=
self
.
__idents_matching
(
test
)
return
self
.
__locals
def
get_globals
(
self
):
...
...
Lib/test/test_symtable.py
View file @
552e7a7e
...
...
@@ -92,7 +92,7 @@ class SymtableTest(unittest.TestCase):
func
=
self
.
spam
self
.
assertEqual
(
func
.
get_parameters
(),
(
"a"
,
"b"
,
"kw"
,
"var"
))
self
.
assertEqual
(
func
.
get_locals
(),
(
"a"
,
"b"
,
"
bar"
,
"
internal"
,
"kw"
,
"var"
,
"x"
))
(
"a"
,
"b"
,
"internal"
,
"kw"
,
"var"
,
"x"
))
self
.
assertEqual
(
func
.
get_globals
(),
(
"bar"
,
"glob"
))
self
.
assertEqual
(
self
.
internal
.
get_frees
(),
(
"x"
,))
...
...
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