Skip to content

Commit

Permalink
bpo-38076: Make struct module PEP-384 compatible (#15805)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
DinoV authored and Yhg1s committed Sep 10, 2019
1 parent 43c9731 commit 4f384af
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 147 deletions.
4 changes: 4 additions & 0 deletions Lib/test/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,10 @@ def _check_iterator(it):
with self.assertRaises(struct.error):
s.iter_unpack(b"12")

def test_uninstantiable(self):
iter_unpack_type = type(struct.Struct(">ibcp").iter_unpack(b""))
self.assertRaises(TypeError, iter_unpack_type)

def test_iterate(self):
s = struct.Struct('>IB')
b = bytes(range(1, 16))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The struct module is now PEP-384 compatible
Loading

0 comments on commit 4f384af

Please sign in to comment.