Index: Lib/idlelib/IOBinding.py =================================================================== --- Lib/idlelib/IOBinding.py (révision 67217) +++ Lib/idlelib/IOBinding.py (copie de travail) @@ -70,8 +70,8 @@ self.should_edit = False self.root = top = Toplevel(master) - top.bind("", self.return_event) - top.bind("", self.do_ok) + top.bind("", self.do_edit) + top.bind("", self.do_cancel) top.protocol("WM_DELETE_WINDOW", self.wm_delete_window) top.wm_title("I/O Warning") top.wm_iconname("I/O Warning") @@ -87,27 +87,26 @@ # 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) + "Edit your general options to silence this warning") 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 = Button(buttons, text="Cancel", + command=self.do_cancel) b1.pack(side=LEFT, fill=BOTH, expand=1) - b2 = Button(buttons, text="Edit my file", + b2 = Button(buttons, text="Edit my file", default="active", command=self.do_edit) b2.pack(side=LEFT, fill=BOTH, expand=1) self._set_transient(master) - def do_ok(self): + def do_cancel(self, event=None): self.done(0) - def do_edit(self): + def do_edit(self, event=None): self.done(1) def coding_spec(data): @@ -393,6 +392,8 @@ if self.eol_convention != "\n": text = text.replace("\n", self.eol_convention) chars = self.encode(text) + if chars is None: + return False try: f = open(filename, "wb") f.write(chars) @@ -477,7 +478,8 @@ else: self.text.insert("1.0", encline) return self.encode(self.text.get("1.0", "end-1c")) - return chars + else: + return None def fixlastline(self): c = self.text.get("end-2c")