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
7e3a91a5
Commit
7e3a91a5
authored
Feb 10, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #26136: Upgrade the generator_stop warning to DeprecationWarning
Patch by Anish Shah.
parent
b0cb42df
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
7 deletions
+19
-7
Doc/whatsnew/3.6.rst
Doc/whatsnew/3.6.rst
+8
-0
Lib/test/test_contextlib.py
Lib/test/test_contextlib.py
+1
-1
Lib/test/test_generators.py
Lib/test/test_generators.py
+3
-3
Lib/test/test_with.py
Lib/test/test_with.py
+2
-2
Misc/NEWS
Misc/NEWS
+4
-0
Objects/genobject.c
Objects/genobject.c
+1
-1
No files found.
Doc/whatsnew/3.6.rst
View file @
7e3a91a5
...
...
@@ -234,6 +234,14 @@ Deprecated features
(Contributed by Rose Ames in :issue:`25791`.)
Deprecated Python behavior
--------------------------
* Raising the :exc:`StopIteration` exception inside a generator will now generate a
:exc:`DeprecationWarning`, and will trigger a :exc:`RuntimeError` in Python 3.7.
See :ref:`whatsnew-pep-479` for details.
Removed
=======
...
...
Lib/test/test_contextlib.py
View file @
7e3a91a5
...
...
@@ -89,7 +89,7 @@ class ContextManagerTestCase(unittest.TestCase):
def
woohoo
():
yield
try
:
with
self
.
assertWarnsRegex
(
Pending
DeprecationWarning
,
with
self
.
assertWarnsRegex
(
DeprecationWarning
,
"StopIteration"
):
with
woohoo
():
raise
stop_exc
...
...
Lib/test/test_generators.py
View file @
7e3a91a5
...
...
@@ -245,11 +245,11 @@ class ExceptionTest(unittest.TestCase):
yield
with
self
.
assertRaises
(
StopIteration
),
\
self
.
assertWarnsRegex
(
Pending
DeprecationWarning
,
"StopIteration"
):
self
.
assertWarnsRegex
(
DeprecationWarning
,
"StopIteration"
):
next
(
gen
())
with
self
.
assertRaisesRegex
(
Pending
DeprecationWarning
,
with
self
.
assertRaisesRegex
(
DeprecationWarning
,
"generator .* raised StopIteration"
),
\
warnings
.
catch_warnings
():
...
...
@@ -268,7 +268,7 @@ class ExceptionTest(unittest.TestCase):
g
=
f
()
self
.
assertEqual
(
next
(
g
),
1
)
with
self
.
assertWarnsRegex
(
Pending
DeprecationWarning
,
"StopIteration"
):
with
self
.
assertWarnsRegex
(
DeprecationWarning
,
"StopIteration"
):
with
self
.
assertRaises
(
StopIteration
):
next
(
g
)
...
...
Lib/test/test_with.py
View file @
7e3a91a5
...
...
@@ -454,7 +454,7 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
with
cm
():
raise
StopIteration
(
"from with"
)
with
self
.
assertWarnsRegex
(
Pending
DeprecationWarning
,
"StopIteration"
):
with
self
.
assertWarnsRegex
(
DeprecationWarning
,
"StopIteration"
):
self
.
assertRaises
(
StopIteration
,
shouldThrow
)
def
testRaisedStopIteration2
(
self
):
...
...
@@ -482,7 +482,7 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
with
cm
():
raise
next
(
iter
([]))
with
self
.
assertWarnsRegex
(
Pending
DeprecationWarning
,
"StopIteration"
):
with
self
.
assertWarnsRegex
(
DeprecationWarning
,
"StopIteration"
):
self
.
assertRaises
(
StopIteration
,
shouldThrow
)
def
testRaisedGeneratorExit1
(
self
):
...
...
Misc/NEWS
View file @
7e3a91a5
...
...
@@ -10,6 +10,10 @@ Release date: tba
Core and Builtins
-----------------
- Issue #26136: Upgrade the warning when a generator raises StopIteration
from PendingDeprecationWarning to DeprecationWarning. Patch by Anish
Shah.
- Issue #26204: The compiler now ignores all constant statements: bytes, str,
int, float, complex, name constants (None, False, True), Ellipsis
and ast.Constant; not only str and int. For example, ``1.0`` is now ignored
...
...
Objects/genobject.c
View file @
7e3a91a5
...
...
@@ -178,7 +178,7 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc)
/* Pop the exception before issuing a warning. */
PyErr_Fetch
(
&
exc
,
&
val
,
&
tb
);
if
(
PyErr_WarnFormat
(
PyExc_
Pending
DeprecationWarning
,
1
,
if
(
PyErr_WarnFormat
(
PyExc_DeprecationWarning
,
1
,
"generator '%.50S' raised StopIteration"
,
gen
->
gi_qualname
))
{
/* Warning was converted to an error. */
...
...
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