Attachment "repro.py" to
ticket [91c9bc1c45]
added by
serhiy.storchaka
2026-11-12 20:28:42.
# Tcl ticket 91c9bc1c45. Windows only. Run with stdout redirected to a
# file: python repro.py > out.txt
import os, sys, tkinter
tcl = tkinter.Tcl()
tcl.eval('fconfigure stdout') # create the stdout channel
os.dup2(os.open('captured.txt', os.O_WRONLY | os.O_CREAT | os.O_TRUNC), 1)
try:
tcl.eval('close [open repro.py]')
print('ok', file=sys.stderr)
except tkinter.TclError as e:
print(f'error: {str(e)!r}', file=sys.stderr)