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
b2677c73
Kaydet (Commit)
b2677c73
authored
Mar 02, 2012
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #14172: Fix reference leak when marshalling a buffer-like object (other than a bytes object).
üst
92818d53
679e9d36
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
4 deletions
+30
-4
test_marshal.py
Lib/test/test_marshal.py
+23
-0
NEWS
Misc/NEWS
+3
-0
marshal.c
Python/marshal.c
+4
-4
No files found.
Lib/test/test_marshal.py
Dosyayı görüntüle @
b2677c73
#!/usr/bin/env python3
from
test
import
support
import
array
import
marshal
import
sys
import
unittest
...
...
@@ -154,6 +155,27 @@ class ContainerTestCase(unittest.TestCase, HelperMixin):
for
constructor
in
(
set
,
frozenset
):
self
.
helper
(
constructor
(
self
.
d
.
keys
()))
class
BufferTestCase
(
unittest
.
TestCase
,
HelperMixin
):
def
test_bytearray
(
self
):
b
=
bytearray
(
b
"abc"
)
self
.
helper
(
b
)
new
=
marshal
.
loads
(
marshal
.
dumps
(
b
))
self
.
assertEqual
(
type
(
new
),
bytes
)
def
test_memoryview
(
self
):
b
=
memoryview
(
b
"abc"
)
self
.
helper
(
b
)
new
=
marshal
.
loads
(
marshal
.
dumps
(
b
))
self
.
assertEqual
(
type
(
new
),
bytes
)
def
test_array
(
self
):
a
=
array
.
array
(
'B'
,
b
"abc"
)
new
=
marshal
.
loads
(
marshal
.
dumps
(
a
))
self
.
assertEqual
(
new
,
b
"abc"
)
class
BugsTestCase
(
unittest
.
TestCase
):
def
test_bug_5888452
(
self
):
# Simple-minded check for SF 588452: Debug build crashes
...
...
@@ -260,6 +282,7 @@ def test_main():
CodeTestCase
,
ContainerTestCase
,
ExceptionTestCase
,
BufferTestCase
,
BugsTestCase
)
if
__name__
==
"__main__"
:
...
...
Misc/NEWS
Dosyayı görüntüle @
b2677c73
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
-----------------
- Issue #14172: Fix reference leak when marshalling a buffer-like object
(other than a bytes object).
- Issue #13521: dict.setdefault() now does only one lookup for the given key,
making it "atomic" for many purposes. Patch by Filip Gruszczyński.
...
...
Python/marshal.c
Dosyayı görüntüle @
b2677c73
...
...
@@ -409,11 +409,12 @@ w_object(PyObject *v, WFILE *p)
else
if
(
PyObject_CheckBuffer
(
v
))
{
/* Write unknown buffer-style objects as a string */
char
*
s
;
PyBufferProcs
*
pb
=
v
->
ob_type
->
tp_as_buffer
;
Py_buffer
view
;
if
(
(
*
pb
->
bf_getbuffer
)
(
v
,
&
view
,
PyBUF_SIMPLE
)
!=
0
)
{
if
(
PyObject_GetBuffer
(
v
,
&
view
,
PyBUF_SIMPLE
)
!=
0
)
{
w_byte
(
TYPE_UNKNOWN
,
p
);
p
->
depth
--
;
p
->
error
=
WFERR_UNMARSHALLABLE
;
return
;
}
w_byte
(
TYPE_STRING
,
p
);
n
=
view
.
len
;
...
...
@@ -425,8 +426,7 @@ w_object(PyObject *v, WFILE *p)
}
w_long
((
long
)
n
,
p
);
w_string
(
s
,
(
int
)
n
,
p
);
if
(
pb
->
bf_releasebuffer
!=
NULL
)
(
*
pb
->
bf_releasebuffer
)(
v
,
&
view
);
PyBuffer_Release
(
&
view
);
}
else
{
w_byte
(
TYPE_UNKNOWN
,
p
);
...
...
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