Skip to content

Commit 4f384af

Browse files
DinoVYhg1s
authored andcommitted
bpo-38076: Make struct module PEP-384 compatible (#15805)
* PEP-384 _struct * More PEP-384 fixes for _struct Summary: Add a couple of more fixes for `_struct` that were previously missed such as removing `tp_*` accessors and using `PyBytesWriter` instead of calling `PyBytes_FromStringAndSize` with `NULL`. Also added a test to confirm that `iter_unpack` type is still uninstantiable. * 📜🤖 Added by blurb_it.
1 parent 43c9731 commit 4f384af

File tree

3 files changed

+177
-147
lines changed

3 files changed

+177
-147
lines changed

Lib/test/test_struct.py

+4
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,10 @@ def _check_iterator(it):
679679
with self.assertRaises(struct.error):
680680
s.iter_unpack(b"12")
681681

682+
def test_uninstantiable(self):
683+
iter_unpack_type = type(struct.Struct(">ibcp").iter_unpack(b""))
684+
self.assertRaises(TypeError, iter_unpack_type)
685+
682686
def test_iterate(self):
683687
s = struct.Struct('>IB')
684688
b = bytes(range(1, 16))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The struct module is now PEP-384 compatible

0 commit comments

Comments
 (0)