This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add support for BigEndianUnion and LittleEndianUnion in ctypes
Type: enhancement Stage: resolved
Components: ctypes Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: amaury.forgeotdarc, belopolsky, dpg, emezh, gregory.p.smith, meador.inge, theller, tohyland
Priority: normal Keywords: patch

Created on 2018-03-29 13:48 by emezh, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25480 merged dpg, 2021-04-20 11:28
Messages (7)
msg314647 - (view) Author: emezh (emezh) Date: 2018-03-29 13:48
Python documentation says that "To build structures with non-native byte order, you can use one of the BigEndianStructure, LittleEndianStructure, BigEndianUnion, and LittleEndianUnion base classes"

However, BigEndianUnion ad LittleEndianUnion are not implemented

>>> from ctypes import *
>>> BigEndianStructure
<class 'ctypes._endian.BigEndianStructure'>
>>> BigEndianUnion
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'BigEndianUnion' is not defined

Is that something that can be added?

See also https://bugs.python.org/issue19023
msg314649 - (view) Author: emezh (emezh) Date: 2018-03-29 13:52
updated nosy list
msg355937 - (view) Author: Tomas Hyland (tohyland) * Date: 2019-11-04 11:10
Hi there, I'm taking part in 'EnHackathon' spending several days over the next few weeks working on issues. I think this could be a good issue for a small team of first-time contributors with experience in C to work on.
Would anyone be able to offer guidance if we encounter problems?
msg397291 - (view) Author: David Goncalves (dpg) * Date: 2021-07-12 09:37
PR 25480 passes checks and awaits core review. All comments thus far have been addressed.
msg410574 - (view) Author: David Goncalves (dpg) * Date: 2022-01-14 17:44
Any core developers available to review this PR?
msg416296 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2022-03-29 21:26
New changeset dc2d8404a3ab6288ce112c71da8c65c34cd3087e by Dave Goncalves in branch 'main':
bpo-33178: Add BigEndianUnion, LittleEndianUnion classes to ctypes (GH-25480)
https://github.com/python/cpython/commit/dc2d8404a3ab6288ce112c71da8c65c34cd3087e
msg416297 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2022-03-29 21:27
Thanks for the contribution!

(our attention spans can be scattered and random, apologies for the delay)
History
Date User Action Args
2022-04-11 14:58:59adminsetgithub: 77359
2022-03-29 21:27:51gregory.p.smithsetstatus: open -> closed
resolution: fixed
messages: + msg416297

stage: patch review -> resolved
2022-03-29 21:26:36gregory.p.smithsetmessages: + msg416296
2022-02-03 23:56:01gregory.p.smithsetassignee: gregory.p.smith

nosy: + gregory.p.smith
versions: + Python 3.11, - Python 2.7, Python 3.6
2022-01-14 17:44:36dpgsetmessages: + msg410574
2021-07-12 09:37:24dpgsetmessages: + msg397291
2021-04-20 11:28:04dpgsetkeywords: + patch
nosy: + dpg

pull_requests: + pull_request24204
stage: patch review
2019-11-04 11:10:04tohylandsetnosy: + tohyland
messages: + msg355937
2018-03-29 13:52:51emezhsetnosy: + theller, amaury.forgeotdarc, belopolsky, meador.inge
messages: + msg314649
2018-03-29 13:48:23emezhcreate