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
dc469454
Commit
dc469454
authored
Oct 04, 2012
by
Jesus Cea
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Closes #15488: Closed files keep their buffer alive
parent
279ed3cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
0 deletions
+16
-0
Lib/test/test_io.py
Lib/test/test_io.py
+8
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_io/bufferedio.c
Modules/_io/bufferedio.c
+5
-0
No files found.
Lib/test/test_io.py
View file @
dc469454
...
...
@@ -815,6 +815,14 @@ class SizeofTest:
bufio
=
self
.
tp
(
rawio
,
buffer_size
=
bufsize2
)
self
.
assertEqual
(
sys
.
getsizeof
(
bufio
),
size
+
bufsize2
)
@
support
.
cpython_only
def
test_buffer_freeing
(
self
)
:
bufsize
=
4096
rawio
=
self
.
MockRawIO
()
bufio
=
self
.
tp
(
rawio
,
buffer_size
=
bufsize
)
size
=
sys
.
getsizeof
(
bufio
)
-
bufsize
bufio
.
close
()
self
.
assertEqual
(
sys
.
getsizeof
(
bufio
),
size
)
class
BufferedReaderTest
(
unittest
.
TestCase
,
CommonBufferedTests
):
read_mode
=
"rb"
...
...
Misc/NEWS
View file @
dc469454
...
...
@@ -24,6 +24,9 @@ Core and Builtins
- Issue #15839: Convert SystemErrors in `super()` to RuntimeErrors.
- Issue #15448: Buffered IO now frees the buffer when closed, instead
of when deallocating.
- Issue #15846: Fix SystemError which happened when using `ast.parse()` in an
exception handler on code with syntax errors.
...
...
Modules/_io/bufferedio.c
View file @
dc469454
...
...
@@ -519,6 +519,11 @@ buffered_close(buffered *self, PyObject *args)
res
=
PyObject_CallMethodObjArgs
(
self
->
raw
,
_PyIO_str_close
,
NULL
);
if
(
self
->
buffer
)
{
PyMem_Free
(
self
->
buffer
);
self
->
buffer
=
NULL
;
}
end:
LEAVE_BUFFERED
(
self
)
return
res
;
...
...
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