Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c836a28

Browse files
Issue #17576: Removed deprecation warnings added in changeset 618cca51a27e.
1 parent 84d28b4 commit c836a28

6 files changed

Lines changed: 12 additions & 45 deletions

File tree

Lib/test/test_getargs2.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def test_b(self):
7575
self.assertEqual(99, getargs_b(Int()))
7676
self.assertEqual(0, getargs_b(IntSubclass()))
7777
self.assertRaises(TypeError, getargs_b, BadInt())
78-
with self.assertWarns(DeprecationWarning):
79-
self.assertEqual(1, getargs_b(BadInt2()))
78+
self.assertEqual(1, getargs_b(BadInt2()))
8079
self.assertEqual(0, getargs_b(BadInt3()))
8180

8281
self.assertRaises(OverflowError, getargs_b, -1)
@@ -94,8 +93,7 @@ def test_B(self):
9493
self.assertEqual(99, getargs_B(Int()))
9594
self.assertEqual(0, getargs_B(IntSubclass()))
9695
self.assertRaises(TypeError, getargs_B, BadInt())
97-
with self.assertWarns(DeprecationWarning):
98-
self.assertEqual(1, getargs_B(BadInt2()))
96+
self.assertEqual(1, getargs_B(BadInt2()))
9997
self.assertEqual(0, getargs_B(BadInt3()))
10098

10199
self.assertEqual(UCHAR_MAX, getargs_B(-1))
@@ -113,8 +111,7 @@ def test_H(self):
113111
self.assertEqual(99, getargs_H(Int()))
114112
self.assertEqual(0, getargs_H(IntSubclass()))
115113
self.assertRaises(TypeError, getargs_H, BadInt())
116-
with self.assertWarns(DeprecationWarning):
117-
self.assertEqual(1, getargs_H(BadInt2()))
114+
self.assertEqual(1, getargs_H(BadInt2()))
118115
self.assertEqual(0, getargs_H(BadInt3()))
119116

120117
self.assertEqual(USHRT_MAX, getargs_H(-1))
@@ -133,8 +130,7 @@ def test_I(self):
133130
self.assertEqual(99, getargs_I(Int()))
134131
self.assertEqual(0, getargs_I(IntSubclass()))
135132
self.assertRaises(TypeError, getargs_I, BadInt())
136-
with self.assertWarns(DeprecationWarning):
137-
self.assertEqual(1, getargs_I(BadInt2()))
133+
self.assertEqual(1, getargs_I(BadInt2()))
138134
self.assertEqual(0, getargs_I(BadInt3()))
139135

140136
self.assertEqual(UINT_MAX, getargs_I(-1))
@@ -174,8 +170,7 @@ def test_h(self):
174170
self.assertEqual(99, getargs_h(Int()))
175171
self.assertEqual(0, getargs_h(IntSubclass()))
176172
self.assertRaises(TypeError, getargs_h, BadInt())
177-
with self.assertWarns(DeprecationWarning):
178-
self.assertEqual(1, getargs_h(BadInt2()))
173+
self.assertEqual(1, getargs_h(BadInt2()))
179174
self.assertEqual(0, getargs_h(BadInt3()))
180175

181176
self.assertRaises(OverflowError, getargs_h, SHRT_MIN-1)
@@ -193,8 +188,7 @@ def test_i(self):
193188
self.assertEqual(99, getargs_i(Int()))
194189
self.assertEqual(0, getargs_i(IntSubclass()))
195190
self.assertRaises(TypeError, getargs_i, BadInt())
196-
with self.assertWarns(DeprecationWarning):
197-
self.assertEqual(1, getargs_i(BadInt2()))
191+
self.assertEqual(1, getargs_i(BadInt2()))
198192
self.assertEqual(0, getargs_i(BadInt3()))
199193

200194
self.assertRaises(OverflowError, getargs_i, INT_MIN-1)
@@ -212,8 +206,7 @@ def test_l(self):
212206
self.assertEqual(99, getargs_l(Int()))
213207
self.assertEqual(0, getargs_l(IntSubclass()))
214208
self.assertRaises(TypeError, getargs_l, BadInt())
215-
with self.assertWarns(DeprecationWarning):
216-
self.assertEqual(1, getargs_l(BadInt2()))
209+
self.assertEqual(1, getargs_l(BadInt2()))
217210
self.assertEqual(0, getargs_l(BadInt3()))
218211

219212
self.assertRaises(OverflowError, getargs_l, LONG_MIN-1)
@@ -254,8 +247,7 @@ def test_L(self):
254247
self.assertEqual(99, getargs_L(Int()))
255248
self.assertEqual(0, getargs_L(IntSubclass()))
256249
self.assertRaises(TypeError, getargs_L, BadInt())
257-
with self.assertWarns(DeprecationWarning):
258-
self.assertEqual(1, getargs_L(BadInt2()))
250+
self.assertEqual(1, getargs_L(BadInt2()))
259251
self.assertEqual(0, getargs_L(BadInt3()))
260252

261253
self.assertRaises(OverflowError, getargs_L, LLONG_MIN-1)

Lib/test/test_index.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ def __index__(self):
8181
return True
8282

8383
bad_int = BadInt()
84-
with self.assertWarns(DeprecationWarning):
85-
n = operator.index(bad_int)
84+
n = operator.index(bad_int)
8685
self.assertEqual(n, 1)
8786

8887
bad_int = BadInt2()

Lib/test/test_int.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,18 +359,15 @@ def __trunc__(self):
359359
return True
360360

361361
bad_int = BadInt()
362-
with self.assertWarns(DeprecationWarning):
363-
n = int(bad_int)
362+
n = int(bad_int)
364363
self.assertEqual(n, 1)
365364

366365
bad_int = BadInt2()
367-
with self.assertWarns(DeprecationWarning):
368-
n = int(bad_int)
366+
n = int(bad_int)
369367
self.assertEqual(n, 1)
370368

371369
bad_int = TruncReturnsBadInt()
372-
with self.assertWarns(DeprecationWarning):
373-
n = int(bad_int)
370+
n = int(bad_int)
374371
self.assertEqual(n, 1)
375372

376373
good_int = TruncReturnsIntSubclass()

Misc/NEWS

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ Core and Builtins
1919
contains a frame, and the frame kept a reference to the Python state of the
2020
destroyed C thread. The crash occurs when a trace function is setup.
2121

22-
- Issue #17576: Deprecation warning emitted now when __int__() or __index__()
23-
return not int instance.
24-
2522
- Issue #19932: Fix typo in import.h, missing whitespaces in function prototypes.
2623

2724
- Issue #19729: In str.format(), fix recursive expansion in format spec.

Objects/abstract.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,15 +1162,6 @@ PyNumber_Index(PyObject *item)
11621162
Py_DECREF(result);
11631163
return NULL;
11641164
}
1165-
/* Issue #17576: warn if 'result' not of exact type int. */
1166-
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
1167-
"__index__ returned non-int (type %.200s). "
1168-
"The ability to return an instance of a strict subclass of int "
1169-
"is deprecated, and may be removed in a future version of Python.",
1170-
result->ob_type->tp_name)) {
1171-
Py_DECREF(result);
1172-
return NULL;
1173-
}
11741165
return result;
11751166
}
11761167

Objects/longobject.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,6 @@ _PyLong_FromNbInt(PyObject *integral)
153153
Py_DECREF(result);
154154
return NULL;
155155
}
156-
/* Issue #17576: warn if 'result' not of exact type int. */
157-
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
158-
"__int__ returned non-int (type %.200s). "
159-
"The ability to return an instance of a strict subclass of int "
160-
"is deprecated, and may be removed in a future version of Python.",
161-
result->ob_type->tp_name)) {
162-
Py_DECREF(result);
163-
return NULL;
164-
}
165156
return (PyLongObject *)result;
166157
}
167158

0 commit comments

Comments
 (0)