summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-08-29 11:04:40 (GMT)
committerGitHub <noreply@github.com>2021-08-29 11:04:40 (GMT)
commit2a8127cafe1d196f858a3ecabf5f1df3eebf9a12 (patch)
treeddf073f1752e1dd20aba534964da961aeecf8c95 /Lib/test/test_io.py
parent07d3d54f4e84b1259b800884b202701f69e408d8 (diff)
downloadcpython-2a8127cafe1d196f858a3ecabf5f1df3eebf9a12.zip
cpython-2a8127cafe1d196f858a3ecabf5f1df3eebf9a12.tar.gz
cpython-2a8127cafe1d196f858a3ecabf5f1df3eebf9a12.tar.bz2
bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005)
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 32c29ea..273545a 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -4372,6 +4372,31 @@ class SignalsTest(unittest.TestCase):
"""Check that a partial write, when it gets interrupted, properly
invokes the signal handler, and bubbles up the exception raised
in the latter."""
+
+ # XXX This test has three flaws that appear when objects are
+ # XXX not reference counted.
+
+ # - if wio.write() happens to trigger a garbage collection,
+ # the signal exception may be raised when some __del__
+ # method is running; it will not reach the assertRaises()
+ # call.
+
+ # - more subtle, if the wio object is not destroyed at once
+ # and survives this function, the next opened file is likely
+ # to have the same fileno (since the file descriptor was
+ # actively closed). When wio.__del__ is finally called, it
+ # will close the other's test file... To trigger this with
+ # CPython, try adding "global wio" in this function.
+
+ # - This happens only for streams created by the _pyio module,
+ # because a wio.close() that fails still consider that the
+ # file needs to be closed again. You can try adding an
+ # "assert wio.closed" at the end of the function.
+
+ # Fortunately, a little gc.collect() seems to be enough to
+ # work around all these issues.
+ support.gc_collect() # For PyPy or other GCs.
+
read_results = []
def _read():
s = os.read(r, 1)