mirror of https://github.com/python/cpython
Issue #28376: Creating instances of range_iterator by calling range_iterator
type now is deprecated. Patch by Oren Milman.
This commit is contained in:
parent
639098c591
commit
c7f490c8b1
|
@ -499,6 +499,9 @@ class RangeTest(unittest.TestCase):
|
|||
import _testcapi
|
||||
rangeiter_type = type(iter(range(0)))
|
||||
|
||||
self.assertWarns(DeprecationWarning, rangeiter_type, 1, 3, 1)
|
||||
|
||||
with test.support.check_warnings(('', DeprecationWarning)):
|
||||
# rangeiter_new doesn't take keyword arguments
|
||||
with self.assertRaises(TypeError):
|
||||
rangeiter_type(a=1)
|
||||
|
|
|
@ -10,6 +10,9 @@ What's New in Python 3.6.0 beta 2
|
|||
Core and Builtins
|
||||
-----------------
|
||||
|
||||
- Issue #28376: Creating instances of range_iterator by calling range_iterator
|
||||
type now is deprecated. Patch by Oren Milman.
|
||||
|
||||
- Issue #28376: The constructor of range_iterator now checks that step is not 0.
|
||||
Patch by Oren Milman.
|
||||
|
||||
|
|
|
@ -930,6 +930,13 @@ rangeiter_new(PyTypeObject *type, PyObject *args, PyObject *kw)
|
|||
{
|
||||
long start, stop, step;
|
||||
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"range_iterator(): creating instances of range_iterator "
|
||||
"by calling range_iterator type is deprecated",
|
||||
1)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoKeywords("range_iterator()", kw)) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue