File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
Misc/NEWS.d/next/Core and Builtins Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,21 @@ def test_multiline_string_parsing(self):
93
93
output = kill_python (p )
94
94
self .assertEqual (p .returncode , 0 )
95
95
96
+ @cpython_only
97
+ @unittest .skipIf (sys .platform == "win32" , '' )
98
+ def test_close_fd_zero (self ):
99
+ user_input = '''\
100
+ import os
101
+ os.close(0)
102
+ '''
103
+ user_input = dedent (user_input )
104
+ user_input = user_input .encode ()
105
+ p = spawn_repl ()
106
+ with SuppressCrashReport ():
107
+ p .stdin .write (user_input )
108
+ output = kill_python (p )
109
+ self .assertEqual (p .returncode , 0 )
110
+
96
111
97
112
if __name__ == "__main__" :
98
113
unittest .main ()
Original file line number Diff line number Diff line change
1
+ Fix segfaults issue when close file descriptor 0 on REPL. Patch by Dong-hee
2
+ Na.
Original file line number Diff line number Diff line change @@ -1782,8 +1782,12 @@ PyOS_FiniInterrupts(void)
1782
1782
int
1783
1783
PyOS_InterruptOccurred (void )
1784
1784
{
1785
- PyInterpreterState * interp = _PyInterpreterState_GET ();
1786
- if (!_Py_ThreadCanHandleSignals (interp )) {
1785
+ PyThreadState * tstate = _PyThreadState_GET ();
1786
+ if (tstate == NULL ) {
1787
+ // FIXME: PyGILState_GetThisThreadState doesn't support subinterpreters.
1788
+ tstate = PyGILState_GetThisThreadState ();
1789
+ }
1790
+ if (!_Py_ThreadCanHandleSignals (tstate -> interp )) {
1787
1791
return 0 ;
1788
1792
}
1789
1793
You can’t perform that action at this time.
0 commit comments