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
5493d5ea
Kaydet (Commit)
5493d5ea
authored
Ara 08, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19099: The struct module now supports Unicode format strings.
üst
337c50b8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
4 deletions
+33
-4
test_struct.py
Lib/test/test_struct.py
+12
-0
NEWS
Misc/NEWS
+2
-0
_struct.c
Modules/_struct.c
+19
-4
No files found.
Lib/test/test_struct.py
Dosyayı görüntüle @
5493d5ea
...
@@ -574,6 +574,18 @@ class StructTest(unittest.TestCase):
...
@@ -574,6 +574,18 @@ class StructTest(unittest.TestCase):
self
.
check_sizeof
(
'0s'
,
1
)
self
.
check_sizeof
(
'0s'
,
1
)
self
.
check_sizeof
(
'0c'
,
0
)
self
.
check_sizeof
(
'0c'
,
0
)
def
test_unicode_format
(
self
):
try
:
unicode
except
NameError
:
self
.
skipTest
(
'no unicode support'
)
# Issue #19099
s
=
struct
.
Struct
(
unichr
(
ord
(
'I'
)))
self
.
assertEqual
(
s
.
format
,
'I'
)
self
.
assertIs
(
type
(
s
.
format
),
str
)
self
.
assertRaises
(
ValueError
,
struct
.
Struct
,
unichr
(
0x80
))
def
test_main
():
def
test_main
():
support
.
run_unittest
(
StructTest
)
support
.
run_unittest
(
StructTest
)
...
...
Misc/NEWS
Dosyayı görüntüle @
5493d5ea
...
@@ -15,6 +15,8 @@ Core and Builtins
...
@@ -15,6 +15,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #19099: The struct module now supports Unicode format strings.
- Issue #19878: Fix segfault in bz2 module after calling __init__ twice with
- Issue #19878: Fix segfault in bz2 module after calling __init__ twice with
non-existent filename. Initial patch by Vajrasky Kok.
non-existent filename. Initial patch by Vajrasky Kok.
...
...
Modules/_struct.c
Dosyayı görüntüle @
5493d5ea
...
@@ -1371,13 +1371,28 @@ s_init(PyObject *self, PyObject *args, PyObject *kwds)
...
@@ -1371,13 +1371,28 @@ s_init(PyObject *self, PyObject *args, PyObject *kwds)
assert
(
PyStruct_Check
(
self
));
assert
(
PyStruct_Check
(
self
));
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"
S
:Struct"
,
kwlist
,
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"
O
:Struct"
,
kwlist
,
&
o_format
))
&
o_format
))
return
-
1
;
return
-
1
;
Py_INCREF
(
o_format
);
if
(
PyString_Check
(
o_format
))
{
Py_CLEAR
(
soself
->
s_format
);
Py_INCREF
(
o_format
);
soself
->
s_format
=
o_format
;
Py_CLEAR
(
soself
->
s_format
);
soself
->
s_format
=
o_format
;
}
else
if
(
PyUnicode_Check
(
o_format
))
{
PyObject
*
str
=
PyUnicode_AsEncodedString
(
o_format
,
"ascii"
,
NULL
);
if
(
str
==
NULL
)
return
-
1
;
Py_CLEAR
(
soself
->
s_format
);
soself
->
s_format
=
str
;
}
else
{
PyErr_Format
(
PyExc_TypeError
,
"Struct() argument 1 must be string, not %s"
,
Py_TYPE
(
o_format
)
->
tp_name
);
return
-
1
;
}
ret
=
prepare_s
(
soself
);
ret
=
prepare_s
(
soself
);
return
ret
;
return
ret
;
...
...
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