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
6cd5eda0
Kaydet (Commit)
6cd5eda0
authored
Ara 01, 2014
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix uninitialized variable after #22676.
üst
6f3eb399
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
7 deletions
+38
-7
pickletester.py
Lib/test/pickletester.py
+21
-0
_pickle.c
Modules/_pickle.c
+17
-7
No files found.
Lib/test/pickletester.py
Dosyayı görüntüle @
6cd5eda0
...
@@ -1636,6 +1636,27 @@ class AbstractPickleTests(unittest.TestCase):
...
@@ -1636,6 +1636,27 @@ class AbstractPickleTests(unittest.TestCase):
unpickled
=
self
.
loads
(
self
.
dumps
(
method
,
proto
))
unpickled
=
self
.
loads
(
self
.
dumps
(
method
,
proto
))
self
.
assertEqual
(
method
(
*
args
),
unpickled
(
*
args
))
self
.
assertEqual
(
method
(
*
args
),
unpickled
(
*
args
))
def
test_local_lookup_error
(
self
):
# Test that whichmodule() errors out cleanly when looking up
# an assumed globally-reachable object fails.
def
f
():
pass
# Since the function is local, lookup will fail
for
proto
in
range
(
0
,
pickle
.
HIGHEST_PROTOCOL
+
1
):
with
self
.
assertRaises
((
AttributeError
,
pickle
.
PicklingError
)):
pickletools
.
dis
(
self
.
dumps
(
f
,
proto
))
# Same without a __module__ attribute (exercises a different path
# in _pickle.c).
del
f
.
__module__
for
proto
in
range
(
0
,
pickle
.
HIGHEST_PROTOCOL
+
1
):
with
self
.
assertRaises
((
AttributeError
,
pickle
.
PicklingError
)):
pickletools
.
dis
(
self
.
dumps
(
f
,
proto
))
# Yet a different path.
f
.
__name__
=
f
.
__qualname__
for
proto
in
range
(
0
,
pickle
.
HIGHEST_PROTOCOL
+
1
):
with
self
.
assertRaises
((
AttributeError
,
pickle
.
PicklingError
)):
pickletools
.
dis
(
self
.
dumps
(
f
,
proto
))
class
BigmemPickleTests
(
unittest
.
TestCase
):
class
BigmemPickleTests
(
unittest
.
TestCase
):
...
...
Modules/_pickle.c
Dosyayı görüntüle @
6cd5eda0
...
@@ -1547,10 +1547,16 @@ get_dotted_path(PyObject *obj, PyObject *name, int allow_qualname) {
...
@@ -1547,10 +1547,16 @@ get_dotted_path(PyObject *obj, PyObject *name, int allow_qualname) {
n
=
PyList_GET_SIZE
(
dotted_path
);
n
=
PyList_GET_SIZE
(
dotted_path
);
assert
(
n
>=
1
);
assert
(
n
>=
1
);
if
(
!
allow_qualname
&&
n
>
1
)
{
if
(
!
allow_qualname
&&
n
>
1
)
{
PyErr_Format
(
PyExc_AttributeError
,
if
(
obj
==
NULL
)
"Can't get qualified attribute %R on %R;"
PyErr_Format
(
PyExc_AttributeError
,
"use protocols >= 4 to enable support"
,
"Can't pickle qualified object %R; "
name
,
obj
);
"use protocols >= 4 to enable support"
,
name
);
else
PyErr_Format
(
PyExc_AttributeError
,
"Can't pickle qualified attribute %R on %R; "
"use protocols >= 4 to enable support"
,
name
,
obj
);
Py_DECREF
(
dotted_path
);
Py_DECREF
(
dotted_path
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1562,8 +1568,12 @@ get_dotted_path(PyObject *obj, PyObject *name, int allow_qualname) {
...
@@ -1562,8 +1568,12 @@ get_dotted_path(PyObject *obj, PyObject *name, int allow_qualname) {
assert
(
PyBool_Check
(
result
));
assert
(
PyBool_Check
(
result
));
Py_DECREF
(
result
);
Py_DECREF
(
result
);
if
(
is_equal
)
{
if
(
is_equal
)
{
PyErr_Format
(
PyExc_AttributeError
,
if
(
obj
==
NULL
)
"Can't get local attribute %R on %R"
,
name
,
obj
);
PyErr_Format
(
PyExc_AttributeError
,
"Can't pickle local object %R"
,
name
);
else
PyErr_Format
(
PyExc_AttributeError
,
"Can't pickle local attribute %R on %R"
,
name
,
obj
);
Py_DECREF
(
dotted_path
);
Py_DECREF
(
dotted_path
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1653,7 +1663,7 @@ whichmodule(PyObject *global, PyObject *global_name, int allow_qualname)
...
@@ -1653,7 +1663,7 @@ whichmodule(PyObject *global, PyObject *global_name, int allow_qualname)
return
NULL
;
return
NULL
;
}
}
dotted_path
=
get_dotted_path
(
module
,
global_name
,
allow_qualname
);
dotted_path
=
get_dotted_path
(
NULL
,
global_name
,
allow_qualname
);
if
(
dotted_path
==
NULL
)
if
(
dotted_path
==
NULL
)
return
NULL
;
return
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