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
13936697
Kaydet (Commit)
13936697
authored
Nis 11, 2007
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF 1191699: Make slices picklable
üst
c02e1312
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
test_slice.py
Lib/test/test_slice.py
+8
-0
NEWS
Misc/NEWS
+2
-0
sliceobject.c
Objects/sliceobject.c
+10
-0
No files found.
Lib/test/test_slice.py
Dosyayı görüntüle @
13936697
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
unittest
import
unittest
from
test
import
test_support
from
test
import
test_support
from
cPickle
import
loads
,
dumps
import
sys
import
sys
...
@@ -102,6 +103,13 @@ class SliceTest(unittest.TestCase):
...
@@ -102,6 +103,13 @@ class SliceTest(unittest.TestCase):
x
[
1
:
2
]
=
42
x
[
1
:
2
]
=
42
self
.
assertEquals
(
tmp
,
[(
1
,
2
,
42
)])
self
.
assertEquals
(
tmp
,
[(
1
,
2
,
42
)])
def
test_pickle
(
self
):
s
=
slice
(
10
,
20
,
3
)
for
protocol
in
(
0
,
1
,
2
):
t
=
loads
(
dumps
(
s
,
protocol
))
self
.
assertEqual
(
s
,
t
)
self
.
assertEqual
(
s
.
indices
(
15
),
t
.
indices
(
15
))
self
.
assertNotEqual
(
id
(
s
),
id
(
t
))
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
SliceTest
)
test_support
.
run_unittest
(
SliceTest
)
...
...
Misc/NEWS
Dosyayı görüntüle @
13936697
...
@@ -12,6 +12,8 @@ What's New in Python 2.6 alpha 1?
...
@@ -12,6 +12,8 @@ What's New in Python 2.6 alpha 1?
Core and builtins
Core and builtins
-----------------
-----------------
- Request #1191699: Slices can now be pickled.
- Patch #1682205: a TypeError while unpacking an iterable is no longer
- Patch #1682205: a TypeError while unpacking an iterable is no longer
masked by a generic one with the message "unpack non-sequence".
masked by a generic one with the message "unpack non-sequence".
...
...
Objects/sliceobject.c
Dosyayı görüntüle @
13936697
...
@@ -274,9 +274,19 @@ indices, and the stride length of the extended slice described by\n\
...
@@ -274,9 +274,19 @@ indices, and the stride length of the extended slice described by\n\
S. Out of bounds indices are clipped in a manner consistent with the
\n
\
S. Out of bounds indices are clipped in a manner consistent with the
\n
\
handling of normal slices."
);
handling of normal slices."
);
static
PyObject
*
slice_reduce
(
PySliceObject
*
self
)
{
return
Py_BuildValue
(
"O(OOO)"
,
self
->
ob_type
,
self
->
start
,
self
->
stop
,
self
->
step
);
}
PyDoc_STRVAR
(
reduce_doc
,
"Return state information for pickling."
);
static
PyMethodDef
slice_methods
[]
=
{
static
PyMethodDef
slice_methods
[]
=
{
{
"indices"
,
(
PyCFunction
)
slice_indices
,
{
"indices"
,
(
PyCFunction
)
slice_indices
,
METH_O
,
slice_indices_doc
},
METH_O
,
slice_indices_doc
},
{
"__reduce__"
,
(
PyCFunction
)
slice_reduce
,
METH_NOARGS
,
reduce_doc
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
...
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