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
3b66ebe7
Commit
3b66ebe7
authored
Oct 24, 2017
by
Serhiy Storchaka
Committed by
GitHub
Oct 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-31847: Fix commented out tests in test_syntax. (#4084)
SyntaxError now is raised instead of SyntaxWarning.
parent
828ca592
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
18 deletions
+10
-18
Lib/test/test_syntax.py
Lib/test/test_syntax.py
+10
-18
No files found.
Lib/test/test_syntax.py
View file @
3b66ebe7
...
...
@@ -415,6 +415,15 @@ Misuse of the nonlocal and global statement can lead to a few unique syntax erro
...
SyntaxError: name 'x' is used prior to nonlocal declaration
>>> def f():
... x = 1
... def g():
... x = 2
... nonlocal x
Traceback (most recent call last):
...
SyntaxError: name 'x' is assigned to before nonlocal declaration
>>> def f(x):
... nonlocal x
Traceback (most recent call last):
...
...
@@ -440,24 +449,7 @@ From SF bug #1705365
...
SyntaxError: nonlocal declaration not allowed at module level
TODO(jhylton): Figure out how to test SyntaxWarning with doctest.
## >>> def f(x):
## ... def f():
## ... print(x)
## ... nonlocal x
## Traceback (most recent call last):
## ...
## SyntaxWarning: name 'x' is assigned to before nonlocal declaration
## >>> def f():
## ... x = 1
## ... nonlocal x
## Traceback (most recent call last):
## ...
## SyntaxWarning: name 'x' is assigned to before nonlocal declaration
From https://bugs.python.org/issue25973
From https://bugs.python.org/issue25973
>>> class A:
... def f(self):
... nonlocal __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