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
3c67d795
Kaydet (Commit)
3c67d795
authored
Şub 02, 2003
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Implemented proto 2 NEWTRUE and NEWFALSE in cPickle.
üst
d156c2d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
2 deletions
+40
-2
pickletester.py
Lib/test/pickletester.py
+6
-0
cPickle.c
Modules/cPickle.c
+34
-2
No files found.
Lib/test/pickletester.py
Dosyayı görüntüle @
3c67d795
...
...
@@ -502,6 +502,12 @@ class AbstractPickleTests(unittest.TestCase):
y
=
self
.
loads
(
s
)
self
.
assert_
(
x
is
y
,
(
proto
,
x
,
s
,
y
))
# Test that proto >= 2 really uses the bool opcodes.
if
proto
>=
2
and
x
in
(
False
,
True
):
expected
=
x
and
pickle
.
NEWTRUE
or
pickle
.
NEWFALSE
# Skip the PROTO opcode at the start.
self
.
assertEqual
(
s
[
2
],
expected
)
def
test_newobj_tuple
(
self
):
x
=
MyTuple
([
1
,
2
,
3
])
x
.
foo
=
42
...
...
Modules/cPickle.c
Dosyayı görüntüle @
3c67d795
...
...
@@ -963,9 +963,13 @@ save_bool(Picklerobject *self, PyObject *args)
static
char
len
[
2
]
=
{
sizeof
(
FALSE
)
-
1
,
sizeof
(
TRUE
)
-
1
};
long
l
=
PyInt_AS_LONG
((
PyIntObject
*
)
args
);
if
((
*
self
->
write_func
)(
self
,
buf
[
l
],
len
[
l
])
<
0
)
if
(
self
->
proto
>=
2
)
{
char
opcode
=
l
?
NEWTRUE
:
NEWFALSE
;
if
(
self
->
write_func
(
self
,
&
opcode
,
1
)
<
0
)
return
-
1
;
}
else
if
(
self
->
write_func
(
self
,
buf
[
l
],
len
[
l
])
<
0
)
return
-
1
;
return
0
;
}
...
...
@@ -2789,6 +2793,15 @@ load_int(Unpicklerobject *self)
return
res
;
}
static
int
load_bool
(
Unpicklerobject
*
self
,
PyObject
*
boolean
)
{
assert
(
boolean
==
Py_True
||
boolean
==
Py_False
);
Py_INCREF
(
boolean
);
PDATA_PUSH
(
self
->
stack
,
boolean
,
-
1
);
return
0
;
}
/* s contains x bytes of a little-endian integer. Return its value as a
* C int. Obscure: when x is 1 or 2, this is an unsigned little-endian
* int, but when x is 4 it's a signed one. This is an historical source
...
...
@@ -4144,6 +4157,16 @@ load(Unpicklerobject *self)
break
;
continue
;
case
NEWTRUE
:
if
(
load_bool
(
self
,
Py_True
)
<
0
)
break
;
continue
;
case
NEWFALSE
:
if
(
load_bool
(
self
,
Py_False
)
<
0
)
break
;
continue
;
case
'\0'
:
/* end of file */
PyErr_SetNone
(
PyExc_EOFError
);
...
...
@@ -4462,6 +4485,15 @@ noload(Unpicklerobject *self)
break
;
continue
;
case
NEWTRUE
:
if
(
load_bool
(
self
,
Py_True
)
<
0
)
break
;
continue
;
case
NEWFALSE
:
if
(
load_bool
(
self
,
Py_False
)
<
0
)
break
;
continue
;
default:
cPickle_ErrFormat
(
UnpicklingError
,
"invalid load key, '%s'."
,
...
...
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