Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
fc477048
Commit
fc477048
authored
Jul 22, 2009
by
Alexandre Vassalotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #6242: Fix deallocator of io.StringIO and io.BytesIO.
parent
4f1f4227
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
6 deletions
+17
-6
Lib/test/test_memoryio.py
Lib/test/test_memoryio.py
+7
-0
Modules/_io/bytesio.c
Modules/_io/bytesio.c
+4
-4
Modules/_io/stringio.c
Modules/_io/stringio.c
+6
-2
No files found.
Lib/test/test_memoryio.py
View file @
fc477048
...
...
@@ -338,6 +338,13 @@ class MemoryTestMixin:
self
.
assertEqual
(
test1
(),
buf
)
self
.
assertEqual
(
test2
(),
buf
)
def
test_instance_dict_leak
(
self
):
# Test case for issue #6242.
# This will be caught by regrtest.py -R if this leak.
for
_
in
range
(
100
):
memio
=
self
.
ioclass
()
memio
.
foo
=
1
class
PyBytesIOTest
(
MemoryTestMixin
,
MemorySeekTestMixin
,
unittest
.
TestCase
):
...
...
Modules/_io/bytesio.c
View file @
fc477048
...
...
@@ -609,11 +609,14 @@ bytesio_close(bytesio *self)
static
void
bytesio_dealloc
(
bytesio
*
self
)
{
_PyObject_GC_UNTRACK
(
self
);
if
(
self
->
buf
!=
NULL
)
{
PyMem_Free
(
self
->
buf
);
self
->
buf
=
NULL
;
}
Py_TYPE
(
self
)
->
tp_clear
((
PyObject
*
)
self
);
Py_CLEAR
(
self
->
dict
);
if
(
self
->
weakreflist
!=
NULL
)
PyObject_ClearWeakRefs
((
PyObject
*
)
self
);
Py_TYPE
(
self
)
->
tp_free
(
self
);
}
...
...
@@ -667,7 +670,6 @@ static int
bytesio_traverse
(
bytesio
*
self
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
self
->
dict
);
Py_VISIT
(
self
->
weakreflist
);
return
0
;
}
...
...
@@ -675,8 +677,6 @@ static int
bytesio_clear
(
bytesio
*
self
)
{
Py_CLEAR
(
self
->
dict
);
if
(
self
->
weakreflist
!=
NULL
)
PyObject_ClearWeakRefs
((
PyObject
*
)
self
);
return
0
;
}
...
...
Modules/_io/stringio.c
View file @
fc477048
...
...
@@ -509,11 +509,15 @@ static void
stringio_dealloc
(
stringio
*
self
)
{
_PyObject_GC_UNTRACK
(
self
);
self
->
ok
=
0
;
if
(
self
->
buf
)
{
PyMem_Free
(
self
->
buf
);
self
->
buf
=
NULL
;
}
Py_CLEAR
(
self
->
readnl
);
Py_CLEAR
(
self
->
writenl
);
Py_CLEAR
(
self
->
decoder
);
if
(
self
->
buf
)
PyMem_Free
(
self
->
buf
);
Py_CLEAR
(
self
->
dict
);
if
(
self
->
weakreflist
!=
NULL
)
PyObject_ClearWeakRefs
((
PyObject
*
)
self
);
Py_TYPE
(
self
)
->
tp_free
(
self
);
...
...
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