Index: Lib/idlelib/IOBinding.py =================================================================== --- Lib/idlelib/IOBinding.py (révision 67217) +++ Lib/idlelib/IOBinding.py (copie de travail) @@ -64,52 +64,6 @@ coding_re = re.compile("coding[:=]\s*([-\w_.]+)") -class EncodingMessage(SimpleDialog): - "Inform user that an encoding declaration is needed." - def __init__(self, master, enc): - self.should_edit = False - - self.root = top = Toplevel(master) - top.bind("", self.return_event) - top.bind("", self.do_ok) - top.protocol("WM_DELETE_WINDOW", self.wm_delete_window) - top.wm_title("I/O Warning") - top.wm_iconname("I/O Warning") - self.top = top - - l1 = Label(top, - text="Non-ASCII found, yet no encoding declared. Add a line like") - l1.pack(side=TOP, anchor=W) - l2 = Entry(top, font="courier") - l2.insert(0, "# -*- coding: %s -*-" % enc) - # For some reason, the text is not selectable anymore if the - # widget is disabled. - # l2['state'] = DISABLED - l2.pack(side=TOP, anchor = W, fill=X) - l3 = Label(top, text="to your file\n" - "Choose OK to save this file as %s\n" - "Edit your general options to silence this warning" % enc) - l3.pack(side=TOP, anchor = W) - - buttons = Frame(top) - buttons.pack(side=TOP, fill=X) - # Both return and cancel mean the same thing: do nothing - self.default = self.cancel = 0 - b1 = Button(buttons, text="Ok", default="active", - command=self.do_ok) - b1.pack(side=LEFT, fill=BOTH, expand=1) - b2 = Button(buttons, text="Edit my file", - command=self.do_edit) - b2.pack(side=LEFT, fill=BOTH, expand=1) - - self._set_transient(master) - - def do_ok(self): - self.done(0) - - def do_edit(self): - self.done(1) - def coding_spec(data): """Return the encoding declaration according to PEP 263. @@ -465,20 +419,17 @@ enc = "utf-8" if not ask_user: return chars - dialog = EncodingMessage(self.editwin.top, enc) - dialog.go() - if dialog.num == 1: - # User asked us to edit the file - encline = "# -*- coding: %s -*-\n" % enc - firstline = self.text.get("1.0", "2.0") - if firstline.startswith("#!"): - # Insert encoding after #! line - self.text.insert("2.0", encline) - else: - self.text.insert("1.0", encline) - return self.encode(self.text.get("1.0", "end-1c")) - return chars + # Add an encoding header + encline = "# -*- coding: %s -*-\n" % enc + firstline = self.text.get("1.0", "2.0") + if firstline.startswith("#!"): + # Insert encoding after #! line + self.text.insert("2.0", encline) + else: + self.text.insert("1.0", encline) + return self.encode(self.text.get("1.0", "end-1c")) + def fixlastline(self): c = self.text.get("end-2c") if c != '\n':