mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Issue #17576: Removed deprecation warnings added in changeset 618cca51a27e.
This commit is contained in:
parent
84d28b4ee5
commit
c836a28cc1
6 changed files with 12 additions and 45 deletions
|
|
@ -75,7 +75,6 @@ class Unsigned_TestCase(unittest.TestCase):
|
|||
self.assertEqual(99, getargs_b(Int()))
|
||||
self.assertEqual(0, getargs_b(IntSubclass()))
|
||||
self.assertRaises(TypeError, getargs_b, BadInt())
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(1, getargs_b(BadInt2()))
|
||||
self.assertEqual(0, getargs_b(BadInt3()))
|
||||
|
||||
|
|
@ -94,7 +93,6 @@ class Unsigned_TestCase(unittest.TestCase):
|
|||
self.assertEqual(99, getargs_B(Int()))
|
||||
self.assertEqual(0, getargs_B(IntSubclass()))
|
||||
self.assertRaises(TypeError, getargs_B, BadInt())
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(1, getargs_B(BadInt2()))
|
||||
self.assertEqual(0, getargs_B(BadInt3()))
|
||||
|
||||
|
|
@ -113,7 +111,6 @@ class Unsigned_TestCase(unittest.TestCase):
|
|||
self.assertEqual(99, getargs_H(Int()))
|
||||
self.assertEqual(0, getargs_H(IntSubclass()))
|
||||
self.assertRaises(TypeError, getargs_H, BadInt())
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(1, getargs_H(BadInt2()))
|
||||
self.assertEqual(0, getargs_H(BadInt3()))
|
||||
|
||||
|
|
@ -133,7 +130,6 @@ class Unsigned_TestCase(unittest.TestCase):
|
|||
self.assertEqual(99, getargs_I(Int()))
|
||||
self.assertEqual(0, getargs_I(IntSubclass()))
|
||||
self.assertRaises(TypeError, getargs_I, BadInt())
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(1, getargs_I(BadInt2()))
|
||||
self.assertEqual(0, getargs_I(BadInt3()))
|
||||
|
||||
|
|
@ -174,7 +170,6 @@ class Signed_TestCase(unittest.TestCase):
|
|||
self.assertEqual(99, getargs_h(Int()))
|
||||
self.assertEqual(0, getargs_h(IntSubclass()))
|
||||
self.assertRaises(TypeError, getargs_h, BadInt())
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(1, getargs_h(BadInt2()))
|
||||
self.assertEqual(0, getargs_h(BadInt3()))
|
||||
|
||||
|
|
@ -193,7 +188,6 @@ class Signed_TestCase(unittest.TestCase):
|
|||
self.assertEqual(99, getargs_i(Int()))
|
||||
self.assertEqual(0, getargs_i(IntSubclass()))
|
||||
self.assertRaises(TypeError, getargs_i, BadInt())
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(1, getargs_i(BadInt2()))
|
||||
self.assertEqual(0, getargs_i(BadInt3()))
|
||||
|
||||
|
|
@ -212,7 +206,6 @@ class Signed_TestCase(unittest.TestCase):
|
|||
self.assertEqual(99, getargs_l(Int()))
|
||||
self.assertEqual(0, getargs_l(IntSubclass()))
|
||||
self.assertRaises(TypeError, getargs_l, BadInt())
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(1, getargs_l(BadInt2()))
|
||||
self.assertEqual(0, getargs_l(BadInt3()))
|
||||
|
||||
|
|
@ -254,7 +247,6 @@ class LongLong_TestCase(unittest.TestCase):
|
|||
self.assertEqual(99, getargs_L(Int()))
|
||||
self.assertEqual(0, getargs_L(IntSubclass()))
|
||||
self.assertRaises(TypeError, getargs_L, BadInt())
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(1, getargs_L(BadInt2()))
|
||||
self.assertEqual(0, getargs_L(BadInt3()))
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ class BaseTestCase(unittest.TestCase):
|
|||
return True
|
||||
|
||||
bad_int = BadInt()
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
n = operator.index(bad_int)
|
||||
self.assertEqual(n, 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -359,17 +359,14 @@ class IntTestCases(unittest.TestCase):
|
|||
return True
|
||||
|
||||
bad_int = BadInt()
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
n = int(bad_int)
|
||||
self.assertEqual(n, 1)
|
||||
|
||||
bad_int = BadInt2()
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
n = int(bad_int)
|
||||
self.assertEqual(n, 1)
|
||||
|
||||
bad_int = TruncReturnsBadInt()
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
n = int(bad_int)
|
||||
self.assertEqual(n, 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ Core and Builtins
|
|||
contains a frame, and the frame kept a reference to the Python state of the
|
||||
destroyed C thread. The crash occurs when a trace function is setup.
|
||||
|
||||
- Issue #17576: Deprecation warning emitted now when __int__() or __index__()
|
||||
return not int instance.
|
||||
|
||||
- Issue #19932: Fix typo in import.h, missing whitespaces in function prototypes.
|
||||
|
||||
- Issue #19729: In str.format(), fix recursive expansion in format spec.
|
||||
|
|
|
|||
|
|
@ -1162,15 +1162,6 @@ PyNumber_Index(PyObject *item)
|
|||
Py_DECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
/* Issue #17576: warn if 'result' not of exact type int. */
|
||||
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
|
||||
"__index__ returned non-int (type %.200s). "
|
||||
"The ability to return an instance of a strict subclass of int "
|
||||
"is deprecated, and may be removed in a future version of Python.",
|
||||
result->ob_type->tp_name)) {
|
||||
Py_DECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,15 +153,6 @@ _PyLong_FromNbInt(PyObject *integral)
|
|||
Py_DECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
/* Issue #17576: warn if 'result' not of exact type int. */
|
||||
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
|
||||
"__int__ returned non-int (type %.200s). "
|
||||
"The ability to return an instance of a strict subclass of int "
|
||||
"is deprecated, and may be removed in a future version of Python.",
|
||||
result->ob_type->tp_name)) {
|
||||
Py_DECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
return (PyLongObject *)result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue