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
8e43cd79
Commit
8e43cd79
authored
Feb 28, 2001
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
verify that warnings are issued for bogus uses of global
parent
ff443a51
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
Lib/test/output/test_global
Lib/test/output/test_global
+4
-0
Lib/test/test_global.py
Lib/test/test_global.py
+40
-0
No files found.
Lib/test/output/test_global
0 → 100644
View file @
8e43cd79
test_global
got SyntaxWarning as expected
got SyntaxWarning as expected
got SyntaxWarning as expected
Lib/test/test_global.py
0 → 100644
View file @
8e43cd79
"""Verify that warnings are issued for global statements following use"""
from
test_support
import
check_syntax
import
warnings
warnings
.
filterwarnings
(
"error"
,
category
=
SyntaxWarning
,
module
=
__name__
)
def
compile_and_catch_warning
(
text
):
try
:
compile
(
text
,
"<test code>"
,
"exec"
)
except
SyntaxWarning
,
msg
:
print
"got SyntaxWarning as expected"
else
:
print
"expected SyntaxWarning"
prog_text_1
=
"""
def wrong1():
a = 1
b = 2
global a
global b
"""
compile_and_catch_warning
(
prog_text_1
)
prog_text_2
=
"""
def wrong2():
print x
global x
"""
compile_and_catch_warning
(
prog_text_2
)
prog_text_3
=
"""
def wrong3():
print x
x = 2
global x
"""
compile_and_catch_warning
(
prog_text_3
)
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