Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a85c95d5
Commit
a85c95d5
authored
Sep 24, 2008
by
Thomas Heller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue #3547: ctypes is confused by bitfields of varying integer types
Reviewed by Fredrik Lundh and Skip Montanaro.
parent
8798c90d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
Lib/ctypes/test/test_bitfields.py
Lib/ctypes/test/test_bitfields.py
+15
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_ctypes/cfield.c
Modules/_ctypes/cfield.c
+1
-1
No files found.
Lib/ctypes/test/test_bitfields.py
View file @
a85c95d5
...
@@ -215,6 +215,21 @@ class BitFieldTest(unittest.TestCase):
...
@@ -215,6 +215,21 @@ class BitFieldTest(unittest.TestCase):
(
"b"
,
c_ubyte
,
4
)]
(
"b"
,
c_ubyte
,
4
)]
self
.
failUnlessEqual
(
sizeof
(
X
),
sizeof
(
c_byte
))
self
.
failUnlessEqual
(
sizeof
(
X
),
sizeof
(
c_byte
))
def
test_mixed_4
(
self
):
class
X
(
Structure
):
_fields_
=
[(
"a"
,
c_short
,
4
),
(
"b"
,
c_short
,
4
),
(
"c"
,
c_int
,
24
),
(
"d"
,
c_short
,
4
),
(
"e"
,
c_short
,
4
),
(
"f"
,
c_int
,
24
)]
# MS compilers do NOT combine c_short and c_int into
# one field, gcc does.
if
os
.
name
in
(
"nt"
,
"ce"
):
self
.
failUnlessEqual
(
sizeof
(
X
),
sizeof
(
c_int
)
*
4
)
else
:
self
.
failUnlessEqual
(
sizeof
(
X
),
sizeof
(
c_int
)
*
2
)
def
test_anon_bitfields
(
self
):
def
test_anon_bitfields
(
self
):
# anonymous bit-fields gave a strange error message
# anonymous bit-fields gave a strange error message
class
X
(
Structure
):
class
X
(
Structure
):
...
...
Misc/NEWS
View file @
a85c95d5
...
@@ -15,6 +15,9 @@ Core and Builtins
...
@@ -15,6 +15,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #3547: Fixed ctypes structures bitfields of varying integer
sizes.
- Issue #3879: A regression in urllib.getproxies_enviroment was fixed.
- Issue #3879: A regression in urllib.getproxies_enviroment was fixed.
Build
Build
...
...
Modules/_ctypes/cfield.c
View file @
a85c95d5
...
@@ -163,7 +163,7 @@ CField_FromDesc(PyObject *desc, Py_ssize_t index,
...
@@ -163,7 +163,7 @@ CField_FromDesc(PyObject *desc, Py_ssize_t index,
break
;
break
;
case
EXPAND_BITFIELD
:
case
EXPAND_BITFIELD
:
/* XXX needs more */
*
poffset
+=
dict
->
size
-
*
pfield_size
/
8
;
*
psize
+=
dict
->
size
-
*
pfield_size
/
8
;
*
psize
+=
dict
->
size
-
*
pfield_size
/
8
;
*
pfield_size
=
dict
->
size
*
8
;
*
pfield_size
=
dict
->
size
*
8
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment