Skip to content

Commit

Permalink
Fixed bug in __mass_add_words()
Browse files Browse the repository at this point in the history
Context manager cannot accept NoneType. Close file manually.
  • Loading branch information
thelabcat committed Apr 28, 2024
1 parent cd27895 commit ffe2fae
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions bookworm_wordlist_editor.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,15 @@ class Editor(Tk):
"""Add a whole file's worth of words"""

#Open and read a file with a human-readable list of new words
with filedialog.askopenfile(title = "Select human-readable list of words", filetypes = [("Plain text", "*.txt")]) as f:
#The user cancelled via the open file dialog
if not f:
return
f = filedialog.askopenfile(title = "Select human-readable list of words", filetypes = [("Plain text", "*.txt")])

#The user cancelled via the open file dialog
if not f:
return

#Read the file
text = f.read().strip()
#Read and close the file
text = f.read().strip()
f.close()

#filter file to only letters and spaces
alpha_text = "".join([c for c in text if c.lower() in bw.ALPHABET or c.isspace()])
Expand Down

0 comments on commit ffe2fae

Please sign in to comment.