Skip to content

Commit f542173

Browse files
committed
revert deprecations (TBD: a separate pr)
1 parent b6c8bed commit f542173

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

Lib/test/test_struct.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import unittest
88
import struct
99
import sys
10-
import warnings
1110
import weakref
1211

1312
from test import support
@@ -576,11 +575,7 @@ def test_Struct_reinitialization(self):
576575
# Struct instance. This test can be used to detect the leak
577576
# when running with regrtest -L.
578577
s = struct.Struct('i')
579-
with self.assertWarns(DeprecationWarning):
580-
s.__init__('ii')
581-
with warnings.catch_warnings():
582-
warnings.simplefilter("error", DeprecationWarning)
583-
self.assertRaises(DeprecationWarning, s.__init__, 'ii')
578+
s.__init__('ii')
584579

585580
def check_sizeof(self, format_str, number_of_codes):
586581
# The size of 'PyStructObject'
@@ -788,8 +783,7 @@ class MyStruct(struct.Struct):
788783
def __init__(self):
789784
super().__init__('>h')
790785

791-
with self.assertWarns(DeprecationWarning):
792-
my_struct = MyStruct()
786+
my_struct = MyStruct()
793787
self.assertEqual(my_struct.pack(12345), b'\x30\x39')
794788

795789
def test_repr(self):
@@ -823,8 +817,7 @@ def test_endian_table_init_subinterpreters(self):
823817
self.assertListEqual(list(results), [None] * 5)
824818

825819
def test_operations_on_half_initialized_Struct(self):
826-
with self.assertWarns(DeprecationWarning):
827-
S = struct.Struct.__new__(struct.Struct)
820+
S = struct.Struct.__new__(struct.Struct)
828821

829822
spam = array.array('b', b' ')
830823
for attr in ['iter_unpack', 'pack', 'pack_into',

Modules/_struct.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,12 +1763,6 @@ s_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
17631763
{
17641764
PyObject *self;
17651765

1766-
if (PyTuple_GET_SIZE(args) != 1
1767-
&& PyErr_WarnEx(PyExc_DeprecationWarning,
1768-
"Struct().__new__() has one required argument", 1))
1769-
{
1770-
return NULL;
1771-
}
17721766
assert(type != NULL);
17731767
allocfunc alloc_func = PyType_GetSlot(type, Py_tp_alloc);
17741768
assert(alloc_func != NULL);
@@ -1802,13 +1796,6 @@ static int
18021796
Struct___init___impl(PyStructObject *self, PyObject *format)
18031797
/*[clinic end generated code: output=b8e80862444e92d0 input=192a4575a3dde802]*/
18041798
{
1805-
if (self->ready
1806-
&& PyErr_WarnEx(PyExc_DeprecationWarning,
1807-
("Explicit call of __init__() on "
1808-
"initialized Struct()"), 1))
1809-
{
1810-
return -1;
1811-
}
18121799
if (PyUnicode_Check(format)) {
18131800
format = PyUnicode_AsASCIIString(format);
18141801
if (format == NULL)

0 commit comments

Comments
 (0)