8000 bpo-33178: Add BigEndianUnion, LittleEndianUnion classes to ctypes by ringof · Pull Request #25480 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-33178: Add BigEndianUnion, LittleEndianUnion classes to ctypes #25480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
condensed base class selection for unsupported byte order tests
  • Loading branch information
ringof committed Mar 17, 2022
commit 3e4f8c82ca732c60f32009f6adce1d3353f173b3
18 changes: 2 additions & 16 deletions Lib/ctypes/test/test_byteswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,6 @@ def test_endian_other(self):
self.assertIs(c_char.__ctype_be__, c_char)

def test_struct_fields_unsupported_byte_order(self):
if sys.byteorder == "little":
base = BigEndianStructure
else:
base = LittleEndianStructure

class T(base):
pass

fields = [
("a", c_ubyte),
Expand All @@ -202,7 +195,7 @@ class T(base):
# these fields do not support different byte order:
for typ in c_wchar, c_void_p, POINTER(c_int):
with self.assertRaises(TypeError):
class T(base):
class T(BigEndianStructure if sys.byteorder == "little" else LittleEndianStructure):
_fields_ = fields + [("x", typ)]


Expand Down Expand Up @@ -312,13 +305,6 @@ class S(Structure):
self.assertEqual(bin(s1), bin(s2))

def test_union_fields_unsupported_byte_order(self):
if sys.byteorder == "little":
base = BigEndianUnion
else:
base = LittleEndianUnion

class T(base):
pass

fields = [
("a", c_ubyte),
Expand All @@ -343,7 +329,7 @@ class T(base):
# these fields do not support different byte order:
for typ in c_wchar, c_void_p, POINTER(c_int):
with self.assertRaises(TypeError):
class T(base):
class T(BigEndianUnion if sys.byteorder == "little" else LittleEndianUnion):
_fields_ = fields + [("x", typ)]

def test_union_struct(self):
Expand Down
0