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
1c873bf7
Commit
1c873bf7
authored
Sep 29, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clear BufferedRWPair weakrefs on deallocation (closes #22517)
parent
f8c4b3a7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
0 deletions
+11
-0
Lib/test/test_io.py
Lib/test/test_io.py
+6
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_io/bufferedio.c
Modules/_io/bufferedio.c
+2
-0
No files found.
Lib/test/test_io.py
View file @
1c873bf7
...
...
@@ -1474,6 +1474,12 @@ class BufferedRWPairTest(unittest.TestCase):
pair
=
self
.
tp
(
SelectableIsAtty
(
True
),
SelectableIsAtty
(
True
))
self
.
assertTrue
(
pair
.
isatty
())
def
test_weakref_clearing
(
self
):
brw
=
self
.
tp
(
self
.
MockRawIO
(),
self
.
MockRawIO
())
ref
=
weakref
.
ref
(
brw
)
brw
=
None
ref
=
None
# Shouldn't segfault.
class
CBufferedRWPairTest
(
BufferedRWPairTest
):
tp
=
io
.
BufferedRWPair
...
...
Misc/NEWS
View file @
1c873bf7
...
...
@@ -29,6 +29,9 @@ Core and Builtins
Library
-------
-
Issue
#
22517
:
When
a
io
.
BufferedRWPair
object
is
deallocated
,
clear
its
weakrefs
.
-
Issue
#
10510
:
distutils
register
and
upload
methods
now
use
HTML
standards
compliant
CRLF
line
endings
.
...
...
Modules/_io/bufferedio.c
View file @
1c873bf7
...
...
@@ -2120,6 +2120,8 @@ static void
bufferedrwpair_dealloc
(
rwpair
*
self
)
{
_PyObject_GC_UNTRACK
(
self
);
if
(
self
->
weakreflist
!=
NULL
)
PyObject_ClearWeakRefs
((
PyObject
*
)
self
);
Py_CLEAR
(
self
->
reader
);
Py_CLEAR
(
self
->
writer
);
Py_CLEAR
(
self
->
dict
);
...
...
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