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
f3bc9466
Kaydet (Commit)
f3bc9466
authored
Nis 20, 2013
tarafından
Alexandre Vassalotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge 3.3
üst
a6d67e6c
1f7492c2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
6 deletions
+65
-6
pickle.py
Lib/pickle.py
+8
-2
pickletester.py
Lib/test/pickletester.py
+54
-4
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/pickle.py
Dosyayı görüntüle @
f3bc9466
...
...
@@ -1156,8 +1156,14 @@ class _Unpickler:
def
load_appends
(
self
):
stack
=
self
.
stack
mark
=
self
.
marker
()
list
=
stack
[
mark
-
1
]
list
.
extend
(
stack
[
mark
+
1
:])
list_obj
=
stack
[
mark
-
1
]
items
=
stack
[
mark
+
1
:]
if
isinstance
(
list_obj
,
list
):
list_obj
.
extend
(
items
)
else
:
append
=
list_obj
.
append
for
item
in
items
:
append
(
item
)
del
stack
[
mark
:]
dispatch
[
APPENDS
[
0
]]
=
load_appends
...
...
Lib/test/pickletester.py
Dosyayı görüntüle @
f3bc9466
...
...
@@ -1219,6 +1219,29 @@ class AbstractPickleTests(unittest.TestCase):
for
p
,
expected
in
goodpickles
:
self
.
assertEqual
(
self
.
loads
(
p
),
expected
)
def
_check_pickling_with_opcode
(
self
,
obj
,
opcode
,
proto
):
pickled
=
self
.
dumps
(
obj
,
proto
)
self
.
assertTrue
(
opcode_in_pickle
(
opcode
,
pickled
))
unpickled
=
self
.
loads
(
pickled
)
self
.
assertEqual
(
obj
,
unpickled
)
def
test_appends_on_non_lists
(
self
):
# Issue #17720
obj
=
REX_six
([
1
,
2
,
3
])
for
proto
in
protocols
:
if
proto
==
0
:
self
.
_check_pickling_with_opcode
(
obj
,
pickle
.
APPEND
,
proto
)
else
:
self
.
_check_pickling_with_opcode
(
obj
,
pickle
.
APPENDS
,
proto
)
def
test_setitems_on_non_dicts
(
self
):
obj
=
REX_seven
({
1
:
-
1
,
2
:
-
2
,
3
:
-
3
})
for
proto
in
protocols
:
if
proto
==
0
:
self
.
_check_pickling_with_opcode
(
obj
,
pickle
.
SETITEM
,
proto
)
else
:
self
.
_check_pickling_with_opcode
(
obj
,
pickle
.
SETITEMS
,
proto
)
class
BigmemPickleTests
(
unittest
.
TestCase
):
...
...
@@ -1304,18 +1327,18 @@ class BigmemPickleTests(unittest.TestCase):
# Test classes for reduce_ex
class
REX_one
(
object
):
"""No __reduce_ex__ here, but inheriting it from object"""
_reduce_called
=
0
def
__reduce__
(
self
):
self
.
_reduce_called
=
1
return
REX_one
,
()
# No __reduce_ex__ here, but inheriting it from object
class
REX_two
(
object
):
"""No __reduce__ here, but inheriting it from object"""
_proto
=
None
def
__reduce_ex__
(
self
,
proto
):
self
.
_proto
=
proto
return
REX_two
,
()
# No __reduce__ here, but inheriting it from object
class
REX_three
(
object
):
_proto
=
None
...
...
@@ -1326,18 +1349,45 @@ class REX_three(object):
raise
TestFailed
(
"This __reduce__ shouldn't be called"
)
class
REX_four
(
object
):
"""Calling base class method should succeed"""
_proto
=
None
def
__reduce_ex__
(
self
,
proto
):
self
.
_proto
=
proto
return
object
.
__reduce_ex__
(
self
,
proto
)
# Calling base class method should succeed
class
REX_five
(
object
):
"""This one used to fail with infinite recursion"""
_reduce_called
=
0
def
__reduce__
(
self
):
self
.
_reduce_called
=
1
return
object
.
__reduce__
(
self
)
# This one used to fail with infinite recursion
class
REX_six
(
object
):
"""This class is used to check the 4th argument (list iterator) of the reduce
protocol.
"""
def
__init__
(
self
,
items
=
None
):
self
.
items
=
items
if
items
is
not
None
else
[]
def
__eq__
(
self
,
other
):
return
type
(
self
)
is
type
(
other
)
and
self
.
items
==
self
.
items
def
append
(
self
,
item
):
self
.
items
.
append
(
item
)
def
__reduce__
(
self
):
return
type
(
self
),
(),
None
,
iter
(
self
.
items
),
None
class
REX_seven
(
object
):
"""This class is used to check the 5th argument (dict iterator) of the reduce
protocol.
"""
def
__init__
(
self
,
table
=
None
):
self
.
table
=
table
if
table
is
not
None
else
{}
def
__eq__
(
self
,
other
):
return
type
(
self
)
is
type
(
other
)
and
self
.
table
==
self
.
table
def
__setitem__
(
self
,
key
,
value
):
self
.
table
[
key
]
=
value
def
__reduce__
(
self
):
return
type
(
self
),
(),
None
,
None
,
iter
(
self
.
table
.
items
())
# Test classes for newobj
...
...
Misc/NEWS
Dosyayı görüntüle @
f3bc9466
...
...
@@ -64,6 +64,9 @@ Library
- Issue #17707: multiprocessing.Queue'
s
get
()
method
does
not
block
for
short
timeouts
.
-
Isuse
#
17720
:
Fix
the
Python
implementation
of
pickle
.
Unpickler
to
correctly
process
the
APPENDS
opcode
when
it
is
used
on
non
-
list
objects
.
-
Issue
#
17012
:
shutil
.
which
()
no
longer
fallbacks
to
the
PATH
environment
variable
if
empty
path
argument
is
specified
.
Patch
by
Serhiy
Storchaka
.
...
...
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