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
b62ff6eb
Kaydet (Commit)
b62ff6eb
authored
Haz 12, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #25455: Fixed a crash in repr of recursive functools.partial objects.
üst
c3905442
179f960d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
18 deletions
+61
-18
test_functools.py
Lib/test/test_functools.py
+37
-0
NEWS
Misc/NEWS
+2
-1
_functoolsmodule.c
Modules/_functoolsmodule.c
+22
-17
No files found.
Lib/test/test_functools.py
Dosyayı görüntüle @
b62ff6eb
...
@@ -217,6 +217,24 @@ class TestPartialC(TestPartial, unittest.TestCase):
...
@@ -217,6 +217,24 @@ class TestPartialC(TestPartial, unittest.TestCase):
[
'{}({!r}, {}, {})'
.
format
(
name
,
capture
,
args_repr
,
kwargs_repr
)
[
'{}({!r}, {}, {})'
.
format
(
name
,
capture
,
args_repr
,
kwargs_repr
)
for
kwargs_repr
in
kwargs_reprs
])
for
kwargs_repr
in
kwargs_reprs
])
def
test_recursive_repr
(
self
):
if
self
.
partial
is
c_functools
.
partial
:
name
=
'functools.partial'
else
:
name
=
self
.
partial
.
__name__
f
=
self
.
partial
(
capture
)
f
.
__setstate__
((
f
,
(),
{},
{}))
self
.
assertEqual
(
repr
(
f
),
'
%
s(
%
s(...))'
%
(
name
,
name
))
f
=
self
.
partial
(
capture
)
f
.
__setstate__
((
capture
,
(
f
,),
{},
{}))
self
.
assertEqual
(
repr
(
f
),
'
%
s(
%
r,
%
s(...))'
%
(
name
,
capture
,
name
))
f
=
self
.
partial
(
capture
)
f
.
__setstate__
((
capture
,
(),
{
'a'
:
f
},
{}))
self
.
assertEqual
(
repr
(
f
),
'
%
s(
%
r, a=
%
s(...))'
%
(
name
,
capture
,
name
))
def
test_pickle
(
self
):
def
test_pickle
(
self
):
f
=
self
.
partial
(
signature
,
[
'asdf'
],
bar
=
[
True
])
f
=
self
.
partial
(
signature
,
[
'asdf'
],
bar
=
[
True
])
f
.
attr
=
[]
f
.
attr
=
[]
...
@@ -297,6 +315,25 @@ class TestPartialC(TestPartial, unittest.TestCase):
...
@@ -297,6 +315,25 @@ class TestPartialC(TestPartial, unittest.TestCase):
self
.
assertEqual
(
r
,
((
1
,
2
),
{}))
self
.
assertEqual
(
r
,
((
1
,
2
),
{}))
self
.
assertIs
(
type
(
r
[
0
]),
tuple
)
self
.
assertIs
(
type
(
r
[
0
]),
tuple
)
def
test_recursive_pickle
(
self
):
f
=
self
.
partial
(
capture
)
f
.
__setstate__
((
f
,
(),
{},
{}))
for
proto
in
range
(
pickle
.
HIGHEST_PROTOCOL
+
1
):
with
self
.
assertRaises
(
RecursionError
):
pickle
.
dumps
(
f
,
proto
)
f
=
self
.
partial
(
capture
)
f
.
__setstate__
((
capture
,
(
f
,),
{},
{}))
for
proto
in
range
(
pickle
.
HIGHEST_PROTOCOL
+
1
):
f_copy
=
pickle
.
loads
(
pickle
.
dumps
(
f
,
proto
))
self
.
assertIs
(
f_copy
.
args
[
0
],
f_copy
)
f
=
self
.
partial
(
capture
)
f
.
__setstate__
((
capture
,
(),
{
'a'
:
f
},
{}))
for
proto
in
range
(
pickle
.
HIGHEST_PROTOCOL
+
1
):
f_copy
=
pickle
.
loads
(
pickle
.
dumps
(
f
,
proto
))
self
.
assertIs
(
f_copy
.
keywords
[
'a'
],
f_copy
)
# Issue 6083: Reference counting bug
# Issue 6083: Reference counting bug
def
test_setstate_refcount
(
self
):
def
test_setstate_refcount
(
self
):
class
BadSequence
:
class
BadSequence
:
...
...
Misc/NEWS
Dosyayı görüntüle @
b62ff6eb
...
@@ -44,7 +44,8 @@ Core and Builtins
...
@@ -44,7 +44,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #25455: Fixed a crash in repr of ElementTree.Element with recursive tag.
- Issue #25455: Fixed crashes in repr of recursive ElementTree.Element and
functools.partial objects.
- Issue #27294: Improved repr for Tkinter event objects.
- Issue #27294: Improved repr for Tkinter event objects.
...
...
Modules/_functoolsmodule.c
Dosyayı görüntüle @
b62ff6eb
...
@@ -203,40 +203,45 @@ static PyGetSetDef partial_getsetlist[] = {
...
@@ -203,40 +203,45 @@ static PyGetSetDef partial_getsetlist[] = {
static
PyObject
*
static
PyObject
*
partial_repr
(
partialobject
*
pto
)
partial_repr
(
partialobject
*
pto
)
{
{
PyObject
*
result
;
PyObject
*
result
=
NULL
;
PyObject
*
arglist
;
PyObject
*
arglist
;
PyObject
*
tmp
;
Py_ssize_t
i
,
n
;
Py_ssize_t
i
,
n
;
PyObject
*
key
,
*
value
;
PyObject
*
key
,
*
value
;
int
status
;
arglist
=
PyUnicode_FromString
(
""
);
status
=
Py_ReprEnter
((
PyObject
*
)
pto
);
if
(
arglist
==
NULL
)
{
if
(
status
!=
0
)
{
return
NULL
;
if
(
status
<
0
)
return
NULL
;
return
PyUnicode_FromFormat
(
"%s(...)"
,
Py_TYPE
(
pto
)
->
tp_name
);
}
}
arglist
=
PyUnicode_FromString
(
""
);
if
(
arglist
==
NULL
)
goto
done
;
/* Pack positional arguments */
/* Pack positional arguments */
assert
(
PyTuple_Check
(
pto
->
args
));
assert
(
PyTuple_Check
(
pto
->
args
));
n
=
PyTuple_GET_SIZE
(
pto
->
args
);
n
=
PyTuple_GET_SIZE
(
pto
->
args
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
tmp
=
PyUnicode_FromFormat
(
"%U, %R"
,
arglist
,
Py_SETREF
(
arglist
,
PyUnicode_FromFormat
(
"%U, %R"
,
arglist
,
PyTuple_GET_ITEM
(
pto
->
args
,
i
));
PyTuple_GET_ITEM
(
pto
->
args
,
i
)));
Py_DECREF
(
arglist
);
if
(
arglist
==
NULL
)
if
(
tmp
==
NULL
)
goto
done
;
return
NULL
;
arglist
=
tmp
;
}
}
/* Pack keyword arguments */
/* Pack keyword arguments */
assert
(
PyDict_Check
(
pto
->
kw
));
assert
(
PyDict_Check
(
pto
->
kw
));
for
(
i
=
0
;
PyDict_Next
(
pto
->
kw
,
&
i
,
&
key
,
&
value
);)
{
for
(
i
=
0
;
PyDict_Next
(
pto
->
kw
,
&
i
,
&
key
,
&
value
);)
{
tmp
=
PyUnicode_FromFormat
(
"%U, %U=%R"
,
arglist
,
Py_SETREF
(
arglist
,
PyUnicode_FromFormat
(
"%U, %U=%R"
,
arglist
,
key
,
value
);
key
,
value
));
Py_DECREF
(
arglist
);
if
(
arglist
==
NULL
)
if
(
tmp
==
NULL
)
goto
done
;
return
NULL
;
arglist
=
tmp
;
}
}
result
=
PyUnicode_FromFormat
(
"%s(%R%U)"
,
Py_TYPE
(
pto
)
->
tp_name
,
result
=
PyUnicode_FromFormat
(
"%s(%R%U)"
,
Py_TYPE
(
pto
)
->
tp_name
,
pto
->
fn
,
arglist
);
pto
->
fn
,
arglist
);
Py_DECREF
(
arglist
);
Py_DECREF
(
arglist
);
done:
Py_ReprLeave
((
PyObject
*
)
pto
);
return
result
;
return
result
;
}
}
...
...
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