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
e6d3904c
Kaydet (Commit)
e6d3904c
authored
May 09, 2007
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make test_marshal pass. Not my best work. :-(
üst
bc14efbd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
10 deletions
+43
-10
test_marshal.py
Lib/test/test_marshal.py
+5
-5
marshal.c
Python/marshal.c
+38
-5
No files found.
Lib/test/test_marshal.py
Dosyayı görüntüle @
e6d3904c
...
...
@@ -27,18 +27,18 @@ class IntTestCase(unittest.TestCase):
# we're running the test on a 32-bit box, of course.
def
to_little_endian_string
(
value
,
nbytes
):
b
ytes
=
[]
b
=
bytes
()
for
i
in
range
(
nbytes
):
b
ytes
.
append
(
chr
(
value
&
0xff
)
)
b
.
append
(
value
&
0xff
)
value
>>=
8
return
''
.
join
(
bytes
)
return
b
maxint64
=
(
1
<<
63
)
-
1
minint64
=
-
maxint64
-
1
for
base
in
maxint64
,
minint64
,
-
maxint64
,
-
(
minint64
>>
1
):
while
base
:
s
=
'I'
+
to_little_endian_string
(
base
,
8
)
s
=
b
'I'
+
to_little_endian_string
(
base
,
8
)
got
=
marshal
.
loads
(
s
)
self
.
assertEqual
(
base
,
got
)
if
base
==
-
1
:
# a fixed-point for shifting right 1
...
...
@@ -128,7 +128,7 @@ class StringTestCase(unittest.TestCase):
os
.
unlink
(
test_support
.
TESTFN
)
def
test_buffer
(
self
):
for
s
in
[
""
,
"Andr Previn"
,
"abc"
,
"
"
*
10000
]:
for
s
in
[
b
""
,
b
"Andr
\xe8
Previn"
,
b
"abc"
,
b
" "
*
10000
]:
b
=
buffer
(
s
)
new
=
marshal
.
loads
(
marshal
.
dumps
(
b
))
self
.
assertEqual
(
s
,
new
)
...
...
Python/marshal.c
Dosyayı görüntüle @
e6d3904c
...
...
@@ -1014,6 +1014,8 @@ PyObject *
PyMarshal_WriteObjectToString
(
PyObject
*
x
,
int
version
)
{
WFILE
wf
;
PyObject
*
res
=
NULL
;
wf
.
fp
=
NULL
;
wf
.
str
=
PyString_FromStringAndSize
((
char
*
)
NULL
,
50
);
if
(
wf
.
str
==
NULL
)
...
...
@@ -1034,7 +1036,8 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
"too much marshal data for a string"
);
return
NULL
;
}
_PyString_Resize
(
&
wf
.
str
,
(
Py_ssize_t
)(
wf
.
ptr
-
base
));
if
(
_PyString_Resize
(
&
wf
.
str
,
(
Py_ssize_t
)(
wf
.
ptr
-
base
))
<
0
)
return
NULL
;
}
if
(
wf
.
error
)
{
Py_XDECREF
(
wf
.
str
);
...
...
@@ -1043,7 +1046,12 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
:
"object too deeply nested to marshal"
);
return
NULL
;
}
return
wf
.
str
;
if
(
wf
.
str
!=
NULL
)
{
/* XXX Quick hack -- need to do this differently */
res
=
PyBytes_FromObject
(
wf
.
str
);
Py_DECREF
(
wf
.
str
);
}
return
res
;
}
/* And an interface for Python programs... */
...
...
@@ -1092,9 +1100,34 @@ marshal_load(PyObject *self, PyObject *f)
RFILE
rf
;
PyObject
*
result
;
if
(
!
PyFile_Check
(
f
))
{
PyErr_SetString
(
PyExc_TypeError
,
"marshal.load() arg must be file"
);
return
NULL
;
/* XXX Quick hack -- need to do this differently */
PyObject
*
data
,
*
result
;
RFILE
rf
;
data
=
PyObject_CallMethod
(
f
,
"read"
,
""
);
if
(
data
==
NULL
)
return
NULL
;
rf
.
fp
=
NULL
;
if
(
PyString_Check
(
data
))
{
rf
.
ptr
=
PyString_AS_STRING
(
data
);
rf
.
end
=
rf
.
ptr
+
PyString_GET_SIZE
(
data
);
}
else
if
(
PyBytes_Check
(
data
))
{
rf
.
ptr
=
PyBytes_AS_STRING
(
data
);
rf
.
end
=
rf
.
ptr
+
PyBytes_GET_SIZE
(
data
);
}
else
{
PyErr_Format
(
PyExc_TypeError
,
"f.read() returned neither string "
"nor bytes but %.100s"
,
data
->
ob_type
->
tp_name
);
Py_DECREF
(
data
);
return
NULL
;
}
rf
.
strings
=
PyList_New
(
0
);
result
=
read_object
(
&
rf
);
Py_DECREF
(
rf
.
strings
);
Py_DECREF
(
data
);
return
result
;
}
rf
.
fp
=
PyFile_AsFile
(
f
);
rf
.
strings
=
PyList_New
(
0
);
...
...
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