Skip to content

gh-84632: IDLE: fix clipboard being cleared upon exit #26163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
12 changes: 9 additions & 3 deletions Lib/idlelib/pyshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1688,9 +1688,15 @@ def main():
if prefer_tabs_preference_warning:
shell.show_warning(prefer_tabs_preference_warning)

while flist.inversedict: # keep IDLE running while files are open.
root.mainloop()
root.destroy()
try:
while flist.inversedict: # keep IDLE running while files are open.
root.mainloop()
finally:
try:
root.destroy()
finally:
import _tkinter
_tkinter._finalize_tcl()
capture_warnings(False)

if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix new clipboard content copied from IDLE being gone after exiting IDLE.
19 changes: 19 additions & 0 deletions Modules/_tkinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3039,6 +3039,24 @@ _tkinter_getbusywaitinterval_impl(PyObject *module)
return Tkinter_busywaitinterval;
}

/*[clinic input]
_tkinter._finalize_tcl

Finalize the Tcl interpreter.

This should be called just before an app exits, to allow Tcl to
execute its own finalization logic. After this, tkinter can no
longer be used, and attempts to do so will result in errors.
[clinic start generated code]*/

static PyObject *
_tkinter__finalize_tcl_impl(PyObject *module)
/*[clinic end generated code: output=a7a2a4c67f43bd28 input=e1082c1b262a40aa]*/
{
Tcl_FinalizeThread();
Py_RETURN_NONE;
}

#include "clinic/_tkinter.c.h"

static PyMethodDef Tktt_methods[] =
Expand Down Expand Up @@ -3122,6 +3140,7 @@ static PyMethodDef moduleMethods[] =
_TKINTER_CREATE_METHODDEF
_TKINTER_SETBUSYWAITINTERVAL_METHODDEF
_TKINTER_GETBUSYWAITINTERVAL_METHODDEF
_TKINTER__FINALIZE_TCL_METHODDEF
{NULL, NULL}
};

Expand Down
24 changes: 23 additions & 1 deletion Modules/clinic/_tkinter.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.