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
d02441ea
Kaydet (Commit)
d02441ea
authored
Tem 08, 2010
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fix repr of complicated structseqs #9206
üst
8c567c54
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
test_structseq.py
Lib/test/test_structseq.py
+9
-1
structseq.c
Objects/structseq.c
+20
-2
No files found.
Lib/test/test_structseq.py
Dosyayı görüntüle @
d02441ea
import
os
import
time
import
unittest
from
test
import
support
import
time
class
StructSeqTest
(
unittest
.
TestCase
):
...
...
@@ -34,6 +35,13 @@ class StructSeqTest(unittest.TestCase):
self
.
assertEqual
(
repr
(
t
),
"time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, "
"tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)"
)
# os.stat() gives a complicated struct sequence.
st
=
os
.
stat
(
__file__
)
rep
=
repr
(
st
)
self
.
assertTrue
(
rep
.
startswith
(
"posix.stat_result"
))
self
.
assertIn
(
"st_mode="
,
rep
)
self
.
assertIn
(
"st_ino="
,
rep
)
self
.
assertIn
(
"st_dev="
,
rep
)
def
test_concat
(
self
):
t1
=
time
.
gmtime
()
...
...
Objects/structseq.c
Dosyayı görüntüle @
d02441ea
...
...
@@ -35,12 +35,27 @@ PyStructSequence_New(PyTypeObject *type)
obj
=
PyObject_GC_NewVar
(
PyStructSequence
,
type
,
size
);
if
(
obj
==
NULL
)
return
NULL
;
/* Hack the size of the variable object, so invisible fields don't appear
to Python code. */
Py_SIZE
(
obj
)
=
VISIBLE_SIZE_TP
(
type
);
for
(
i
=
0
;
i
<
size
;
i
++
)
obj
->
ob_item
[
i
]
=
NULL
;
return
(
PyObject
*
)
obj
;
}
static
void
structseq_dealloc
(
PyStructSequence
*
obj
)
{
Py_ssize_t
i
,
size
;
size
=
REAL_SIZE
(
obj
);
for
(
i
=
0
;
i
<
size
;
++
i
)
{
Py_XDECREF
(
obj
->
ob_item
[
i
]);
}
PyObject_GC_Del
(
obj
);
}
static
PyObject
*
structseq_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
{
...
...
@@ -154,8 +169,11 @@ structseq_repr(PyStructSequence *obj)
char
*
cname
,
*
crepr
;
cname
=
typ
->
tp_members
[
i
].
name
;
if
(
cname
==
NULL
)
if
(
cname
==
NULL
)
{
PyErr_Format
(
PyExc_SystemError
,
"In structseq_repr(), member %d name is NULL"
" for type %.500s"
,
i
,
typ
->
tp_name
);
return
NULL
;
}
val
=
PyStructSequence_GET_ITEM
(
obj
,
i
);
repr
=
PyObject_Repr
(
val
);
if
(
repr
==
NULL
)
...
...
@@ -249,7 +267,7 @@ static PyTypeObject _struct_sequence_template = {
NULL
,
/* tp_name */
sizeof
(
PyStructSequence
)
-
sizeof
(
PyObject
*
),
/* tp_basicsize */
sizeof
(
PyObject
*
),
/* tp_itemsize */
0
,
/* tp_dealloc */
(
destructor
)
structseq_dealloc
,
/* tp_dealloc */
0
,
/* tp_print */
0
,
/* tp_getattr */
0
,
/* tp_setattr */
...
...
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