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
fda33559
Commit
fda33559
authored
Mar 16, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ctypes test alignment assumptions (closes #20946)
Patch by Andreas Schwab.
parent
790bf0db
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
12 deletions
+14
-12
Lib/ctypes/test/test_bitfields.py
Lib/ctypes/test/test_bitfields.py
+1
-1
Lib/ctypes/test/test_structures.py
Lib/ctypes/test/test_structures.py
+8
-8
Misc/NEWS
Misc/NEWS
+2
-0
Modules/_ctypes/cfield.c
Modules/_ctypes/cfield.c
+3
-3
No files found.
Lib/ctypes/test/test_bitfields.py
View file @
fda33559
...
@@ -207,7 +207,7 @@ class BitFieldTest(unittest.TestCase):
...
@@ -207,7 +207,7 @@ class BitFieldTest(unittest.TestCase):
class
X
(
Structure
):
class
X
(
Structure
):
_fields_
=
[(
"a"
,
c_byte
,
4
),
_fields_
=
[(
"a"
,
c_byte
,
4
),
(
"b"
,
c_int
,
32
)]
(
"b"
,
c_int
,
32
)]
self
.
assertEqual
(
sizeof
(
X
),
sizeof
(
c_int
)
*
2
)
self
.
assertEqual
(
sizeof
(
X
),
alignment
(
c_int
)
+
sizeof
(
c_int
)
)
def
test_mixed_3
(
self
):
def
test_mixed_3
(
self
):
class
X
(
Structure
):
class
X
(
Structure
):
...
...
Lib/ctypes/test/test_structures.py
View file @
fda33559
...
@@ -83,7 +83,7 @@ class StructureTestCase(unittest.TestCase):
...
@@ -83,7 +83,7 @@ class StructureTestCase(unittest.TestCase):
class
Y
(
Structure
):
class
Y
(
Structure
):
_fields_
=
[(
"x"
,
c_char
*
3
),
_fields_
=
[(
"x"
,
c_char
*
3
),
(
"y"
,
c_int
)]
(
"y"
,
c_int
)]
self
.
assertEqual
(
alignment
(
Y
),
calcsize
(
"i"
))
self
.
assertEqual
(
alignment
(
Y
),
alignment
(
c_int
))
self
.
assertEqual
(
sizeof
(
Y
),
calcsize
(
"3si"
))
self
.
assertEqual
(
sizeof
(
Y
),
calcsize
(
"3si"
))
class
SI
(
Structure
):
class
SI
(
Structure
):
...
@@ -175,23 +175,23 @@ class StructureTestCase(unittest.TestCase):
...
@@ -175,23 +175,23 @@ class StructureTestCase(unittest.TestCase):
self
.
assertEqual
(
sizeof
(
X
),
10
)
self
.
assertEqual
(
sizeof
(
X
),
10
)
self
.
assertEqual
(
X
.
b
.
offset
,
2
)
self
.
assertEqual
(
X
.
b
.
offset
,
2
)
import
struct
longlong_size
=
struct
.
calcsize
(
"q"
)
longlong_align
=
struct
.
calcsize
(
"bq"
)
-
longlong_size
class
X
(
Structure
):
class
X
(
Structure
):
_fields_
=
[(
"a"
,
c_byte
),
_fields_
=
[(
"a"
,
c_byte
),
(
"b"
,
c_longlong
)]
(
"b"
,
c_longlong
)]
_pack_
=
4
_pack_
=
4
self
.
assertEqual
(
sizeof
(
X
),
12
)
self
.
assertEqual
(
sizeof
(
X
),
min
(
4
,
longlong_align
)
+
longlong_size
)
self
.
assertEqual
(
X
.
b
.
offset
,
4
)
self
.
assertEqual
(
X
.
b
.
offset
,
min
(
4
,
longlong_align
))
import
struct
longlong_size
=
struct
.
calcsize
(
"q"
)
longlong_align
=
struct
.
calcsize
(
"bq"
)
-
longlong_size
class
X
(
Structure
):
class
X
(
Structure
):
_fields_
=
[(
"a"
,
c_byte
),
_fields_
=
[(
"a"
,
c_byte
),
(
"b"
,
c_longlong
)]
(
"b"
,
c_longlong
)]
_pack_
=
8
_pack_
=
8
self
.
assertEqual
(
sizeof
(
X
),
longlong_align
+
longlong_size
)
self
.
assertEqual
(
sizeof
(
X
),
min
(
8
,
longlong_align
)
+
longlong_size
)
self
.
assertEqual
(
X
.
b
.
offset
,
min
(
8
,
longlong_align
))
self
.
assertEqual
(
X
.
b
.
offset
,
min
(
8
,
longlong_align
))
...
...
Misc/NEWS
View file @
fda33559
...
@@ -30,6 +30,8 @@ Library
...
@@ -30,6 +30,8 @@ Library
Tests
Tests
-----
-----
- Issue #20946: Correct alignment assumptions of some ctypes tests.
- Issue #20939: Fix test_geturl failure in test_urllibnet due to
- Issue #20939: Fix test_geturl failure in test_urllibnet due to
new redirect of http://www.python.org/ to https://www.python.org.
new redirect of http://www.python.org/ to https://www.python.org.
...
...
Modules/_ctypes/cfield.c
View file @
fda33559
...
@@ -1640,9 +1640,9 @@ typedef struct { char c; void *x; } s_void_p;
...
@@ -1640,9 +1640,9 @@ typedef struct { char c; void *x; } s_void_p;
/*
/*
#define CHAR_ALIGN (sizeof(s_char) - sizeof(char))
#define CHAR_ALIGN (sizeof(s_char) - sizeof(char))
#define SHORT_ALIGN (sizeof(s_short) - sizeof(short))
#define SHORT_ALIGN (sizeof(s_short) - sizeof(short))
#define INT_ALIGN (sizeof(s_int) - sizeof(int))
#define LONG_ALIGN (sizeof(s_long) - sizeof(long))
#define LONG_ALIGN (sizeof(s_long) - sizeof(long))
*/
*/
#define INT_ALIGN (sizeof(s_int) - sizeof(int))
#define FLOAT_ALIGN (sizeof(s_float) - sizeof(float))
#define FLOAT_ALIGN (sizeof(s_float) - sizeof(float))
#define DOUBLE_ALIGN (sizeof(s_double) - sizeof(double))
#define DOUBLE_ALIGN (sizeof(s_double) - sizeof(double))
#define LONGDOUBLE_ALIGN (sizeof(s_long_double) - sizeof(long double))
#define LONGDOUBLE_ALIGN (sizeof(s_long_double) - sizeof(long double))
...
@@ -1684,8 +1684,8 @@ ffi_type ffi_type_sint8 = { 1, 1, FFI_TYPE_SINT8 };
...
@@ -1684,8 +1684,8 @@ ffi_type ffi_type_sint8 = { 1, 1, FFI_TYPE_SINT8 };
ffi_type
ffi_type_uint16
=
{
2
,
2
,
FFI_TYPE_UINT16
};
ffi_type
ffi_type_uint16
=
{
2
,
2
,
FFI_TYPE_UINT16
};
ffi_type
ffi_type_sint16
=
{
2
,
2
,
FFI_TYPE_SINT16
};
ffi_type
ffi_type_sint16
=
{
2
,
2
,
FFI_TYPE_SINT16
};
ffi_type
ffi_type_uint32
=
{
4
,
4
,
FFI_TYPE_UINT32
};
ffi_type
ffi_type_uint32
=
{
4
,
INT_ALIGN
,
FFI_TYPE_UINT32
};
ffi_type
ffi_type_sint32
=
{
4
,
4
,
FFI_TYPE_SINT32
};
ffi_type
ffi_type_sint32
=
{
4
,
INT_ALIGN
,
FFI_TYPE_SINT32
};
ffi_type
ffi_type_uint64
=
{
8
,
LONG_LONG_ALIGN
,
FFI_TYPE_UINT64
};
ffi_type
ffi_type_uint64
=
{
8
,
LONG_LONG_ALIGN
,
FFI_TYPE_UINT64
};
ffi_type
ffi_type_sint64
=
{
8
,
LONG_LONG_ALIGN
,
FFI_TYPE_SINT64
};
ffi_type
ffi_type_sint64
=
{
8
,
LONG_LONG_ALIGN
,
FFI_TYPE_SINT64
};
...
...
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