New GitHub issue #117620 from rminkler1:<br>
<hr>
<pre>
# Crash report
### What happened?
When calling simpledialog to get user input, then later calling filedialog to save a text file, the python interpreter often crashes. Without both dialog boxes called, there is no crash.
Reproducible on macOS Sierra 14.4.1 Macbook Air M1
Could not reproduce on Windows
Python 3.12
ips crash report generated and available
```python
from tkinter import *
from tkinter import filedialog, scrolledtext, simpledialog
# BEGIN CODE THAT CAUSES CRASH ******
# BEGIN CODE THAT CAUSES CRASH ******
# BEGIN CODE THAT CAUSES CRASH ******
# prompt for settings
time_out_seconds = simpledialog.askinteger(title="Title", prompt="Prompt")
# set defaults if dialogs are cancelled
if not time_out_seconds:
time_out_seconds = 10
# END CODE THAT CAUSES CRASH ********
# END CODE THAT CAUSES CRASH ********
# END CODE THAT CAUSES CRASH ********
def save_to_file():
"""
Saves File
"""
# CRASH OCCURS HERE ******
# CRASH OCCURS HERE ******
# CRASH OCCURS HERE ******
# while it does crash without filetypes defined, it crashes more often when filetypes are defined.
file_path = filedialog.asksaveasfilename(defaultextension=".txt",
filetypes=[("Text files", "*.txt"), ("All files", "*.*")])
if file_path:
with open(file_path, 'w') as file:
text_content = "Sample text document text"
file.write(text_content)
# Window config
window = Tk()
# User input
text_box = scrolledtext.ScrolledText()
text_box.pack()
# Save Button
save_button = Button(window, text="Save", command=save_to_file)
save_button.pack()
window.mainloop()
```
### CPython versions tested on:
3.12
### Operating systems tested on:
macOS
### Output from running 'python -VV' on the command line:
2024-04-07 20:30:19.525 Python[3024:88005] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES. Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/117620">View on GitHub</a>
<p>Labels: type-crash</p>
<p>Assignee: </p>