Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
245edd4d
Kaydet (Commit)
245edd4d
authored
Tem 29, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge 3.5 (ctypes)
üst
34a0105b
5ef6fde9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
+32
-0
test_bitfields.py
Lib/ctypes/test/test_bitfields.py
+28
-0
NEWS
Misc/NEWS
+3
-0
cfield.c
Modules/_ctypes/cfield.c
+1
-0
No files found.
Lib/ctypes/test/test_bitfields.py
Dosyayı görüntüle @
245edd4d
...
...
@@ -259,5 +259,33 @@ class BitFieldTest(unittest.TestCase):
x
.
a
=
0xFEDCBA9876543211
self
.
assertEqual
(
x
.
a
,
0xFEDCBA9876543211
)
@need_symbol
(
'c_uint32'
)
def
test_uint32_swap_little_endian
(
self
):
# Issue #23319
class
Little
(
LittleEndianStructure
):
_fields_
=
[(
"a"
,
c_uint32
,
24
),
(
"b"
,
c_uint32
,
4
),
(
"c"
,
c_uint32
,
4
)]
b
=
bytearray
(
4
)
x
=
Little
.
from_buffer
(
b
)
x
.
a
=
0xabcdef
x
.
b
=
1
x
.
c
=
2
self
.
assertEqual
(
b
,
b
'
\xef\xcd\xab\x21
'
)
@need_symbol
(
'c_uint32'
)
def
test_uint32_swap_big_endian
(
self
):
# Issue #23319
class
Big
(
BigEndianStructure
):
_fields_
=
[(
"a"
,
c_uint32
,
24
),
(
"b"
,
c_uint32
,
4
),
(
"c"
,
c_uint32
,
4
)]
b
=
bytearray
(
4
)
x
=
Big
.
from_buffer
(
b
)
x
.
a
=
0xabcdef
x
.
b
=
1
x
.
c
=
2
self
.
assertEqual
(
b
,
b
'
\xab\xcd\xef\x12
'
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Misc/NEWS
Dosyayı görüntüle @
245edd4d
...
...
@@ -13,6 +13,9 @@ Core and Builtins
Library
-------
- Issue #23319: Fix ctypes.BigEndianStructure, swap correctly bytes. Patch
written by Matthieu Gautier.
- Issue #19450: Update Windows and OS X installer builds to use SQLite 3.8.11.
- Issue #23254: Document how to close the TCPServer listening socket.
...
...
Modules/_ctypes/cfield.c
Dosyayı görüntüle @
245edd4d
...
...
@@ -765,6 +765,7 @@ I_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
if
(
get_ulong
(
value
,
&
val
)
<
0
)
return
NULL
;
memcpy
(
&
field
,
ptr
,
sizeof
(
field
));
field
=
SWAP_INT
(
field
);
field
=
SET
(
unsigned
int
,
field
,
(
unsigned
int
)
val
,
size
);
field
=
SWAP_INT
(
field
);
memcpy
(
ptr
,
&
field
,
sizeof
(
field
));
...
...
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