Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 61e2c9a

Browse files
committed
Forwardport Patch from IDLEfork SF 610329
Remove deprecated tempfile usage
1 parent d141a8c commit 61e2c9a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/idlelib/IOBinding.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,10 @@ def print_window(self, event):
465465
# shell undo is reset after every prompt, looks saved, probably isn't
466466
if not saved or filename is None:
467467
# XXX KBK 08Jun03 Wouldn't it be better to ask the user to save?
468-
filename = tempfilename = tempfile.mktemp()
469-
if not self.writefile(filename):
468+
(tfd, tempfilename) = tempfile.mkstemp(prefix='IDLE_tmp_')
469+
filename = tempfilename
470+
os.close(tfd)
471+
if not self.writefile(tempfilename):
470472
os.unlink(tempfilename)
471473
return "break"
472474
platform=os.name
@@ -494,6 +496,8 @@ def print_window(self, event):
494496
else: #no printing for this platform
495497
message="Printing is not enabled for this platform: %s" % platform
496498
tkMessageBox.showinfo("Print status", message, master=self.text)
499+
if tempfilename:
500+
os.unlink(tempfilename)
497501
return "break"
498502

499503
opendialog = None

0 commit comments

Comments
 (0)