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
b289b87a
Kaydet (Commit)
b289b87a
authored
Şub 19, 2003
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use __reduce_ex__.
üst
9c9cf41a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
45 deletions
+36
-45
cPickle.c
Modules/cPickle.c
+36
-45
No files found.
Modules/cPickle.c
Dosyayı görüntüle @
b289b87a
...
...
@@ -119,14 +119,9 @@ static PyObject *extension_cache;
/* For looking up name pairs in copy_reg._extension_registry. */
static
PyObject
*
two_tuple
;
/* object.__reduce__, the default reduce callable. */
static
PyObject
*
object_reduce
;
/* copy_reg._better_reduce, the protocol 2 reduction function. */
static
PyObject
*
better_reduce
;
static
PyObject
*
__class___str
,
*
__getinitargs___str
,
*
__dict___str
,
*
__getstate___str
,
*
__setstate___str
,
*
__name___str
,
*
__reduce___str
,
*
__reduce_ex___str
,
*
write_str
,
*
append_str
,
*
read_str
,
*
readline_str
,
*
__main___str
,
*
__basicnew___str
,
*
copy_reg_str
,
*
dispatch_table_str
;
...
...
@@ -2505,48 +2500,50 @@ save(Picklerobject *self, PyObject *args, int pers_save)
goto
finally
;
}
/* Get a reduction callable. This may come from
* copy_reg.dispatch_table, the object's __reduce__ method,
*
the default object.__reduce__, or copy_reg._better_reduce
.
/* Get a reduction callable
, and call it
. This may come from
* copy_reg.dispatch_table, the object's __reduce_
ex_
_ method,
*
or the object's __reduce__ method
.
*/
__reduce__
=
PyDict_GetItem
(
dispatch_table
,
(
PyObject
*
)
type
);
if
(
__reduce__
!=
NULL
)
{
Py_INCREF
(
__reduce__
);
Py_INCREF
(
args
);
ARG_TUP
(
self
,
args
);
if
(
self
->
arg
)
{
t
=
PyObject_Call
(
__reduce__
,
self
->
arg
,
NULL
);
FREE_ARG_TUP
(
self
);
}
}
else
{
/* Check for a __reduce__ method.
* Subtle: get the unbound method from the class, so that
* protocol 2 can override the default __reduce__ that all
* classes inherit from object.
* XXX object.__reduce__ should really be rewritten so that
* XXX we don't need to call back into Python code here
* XXX (better_reduce), but no time to do that.
*/
__reduce__
=
PyObject_GetAttr
((
PyObject
*
)
type
,
__reduce___str
);
if
(
__reduce__
==
NULL
)
{
PyErr_Clear
();
PyErr_SetObject
(
UnpickleableError
,
args
);
goto
finally
;
/* Check for a __reduce_ex__ method. */
__reduce__
=
PyObject_GetAttr
(
args
,
__reduce_ex___str
);
if
(
__reduce__
!=
NULL
)
{
t
=
PyInt_FromLong
(
self
->
proto
);
if
(
t
!=
NULL
)
{
ARG_TUP
(
self
,
t
);
t
=
NULL
;
if
(
self
->
arg
)
{
t
=
PyObject_Call
(
__reduce__
,
self
->
arg
,
NULL
);
FREE_ARG_TUP
(
self
);
}
}
}
if
(
self
->
proto
>=
2
&&
__reduce__
==
object_reduce
)
{
/* Proto 2 can do better than the default. */
Py_DECREF
(
__reduce__
);
Py_INCREF
(
better_reduce
);
__reduce__
=
better_reduce
;
else
{
PyErr_Clear
();
/* Check for a __reduce__ method. */
__reduce__
=
PyObject_GetAttr
(
args
,
__reduce___str
);
if
(
__reduce__
!=
NULL
)
{
t
=
PyObject_Call
(
__reduce__
,
empty_tuple
,
NULL
);
}
else
{
PyErr_SetObject
(
UnpickleableError
,
args
);
goto
finally
;
}
}
}
/* Call the reduction callable, setting t to the result. */
assert
(
__reduce__
!=
NULL
);
assert
(
t
==
NULL
);
Py_INCREF
(
args
);
ARG_TUP
(
self
,
args
);
if
(
self
->
arg
)
{
t
=
PyObject_Call
(
__reduce__
,
self
->
arg
,
NULL
);
FREE_ARG_TUP
(
self
);
}
if
(
t
==
NULL
)
goto
finally
;
...
...
@@ -5590,6 +5587,7 @@ init_stuff(PyObject *module_dict)
INIT_STR
(
__name__
);
INIT_STR
(
__main__
);
INIT_STR
(
__reduce__
);
INIT_STR
(
__reduce_ex__
);
INIT_STR
(
write
);
INIT_STR
(
append
);
INIT_STR
(
read
);
...
...
@@ -5618,15 +5616,8 @@ init_stuff(PyObject *module_dict)
"_extension_cache"
);
if
(
!
extension_cache
)
return
-
1
;
better_reduce
=
PyObject_GetAttrString
(
copy_reg
,
"_better_reduce"
);
if
(
!
better_reduce
)
return
-
1
;
Py_DECREF
(
copy_reg
);
object_reduce
=
PyObject_GetAttrString
((
PyObject
*
)
&
PyBaseObject_Type
,
"__reduce__"
);
if
(
object_reduce
==
NULL
)
return
-
1
;
if
(
!
(
empty_tuple
=
PyTuple_New
(
0
)))
return
-
1
;
...
...
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