Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Lib/test/test_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ def test_multiline_string_parsing(self):
output = kill_python(p)
self.assertEqual(p.returncode, 0)

@cpython_only
@unittest.skipIf(sys.platform =="win32", 'Skip Windows')
def test_close_fd_zero(self):
user_input = '''\
import os
os.close(0)
'''
user_input = dedent(user_input)
user_input = user_input.encode()
p = spawn_repl()
with SuppressCrashReport():
p.stdin.write(user_input)
output = kill_python(p)
self.assertEqual(p.returncode, 0)


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix segfaults issue when close file descriptor 0 on REPL. Patch by Dong-hee
Na.
8 changes: 6 additions & 2 deletions Modules/signalmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1782,8 +1782,12 @@ PyOS_FiniInterrupts(void)
int
PyOS_InterruptOccurred(void)
{
PyInterpreterState *interp = _PyInterpreterState_GET();
if (!_Py_ThreadCanHandleSignals(interp)) {
PyThreadState *tstate = _PyThreadState_GET();
if (tstate == NULL) {
// FIXME: PyGILState_GetThisThreadState doesn't support subinterpreters.
tstate = PyGILState_GetThisThreadState();
}
if (!_Py_ThreadCanHandleSignals(tstate->interp)) {
return 0;
}

Expand Down