Re: Python shell wont open idle or an exisiting py file
On 2/1/2014 2:26 AM, Chris Angelico wrote: On Sat, Feb 1, 2014 at 4:46 PM, Terry Reedy tjre...@udel.edu wrote: On 1/31/2014 10:36 PM, Chris Angelico wrote: On Sat, Feb 1, 2014 at 1:54 PM, MRAB pyt...@mrabarnett.plus.com wrote: I think that some years ago I heard about a variation on UTF-8 (Microsoft?) where codepoint U+ is encoded as 0xC0 0x80 so that the null byte can be used as the string terminator. I had a look on Wikipedia found this: http://en.wikipedia.org/wiki/Null-terminated_string Yeah, it's a common abuse of UTF-8. It's a violation of spec, but an understandable one. However, I don't understand why the first part - why should \0 become U+ but (presumably) the \a later on (...cs\accel...) doesn't become U+0007, etc? Because only \0 has a special meaning in a C string, I should have added 'to C itself', as the string terminator. and Tk is written in C and uses C strings. Eh? I've used \a in C programs (not often but I have used it). It's possible that \0 is the only one that actually bombs anything (because of C0 80 representation). \0 can bomb C byte processing by terminating it sooner than it should. Its unexpected replacement bombs utf-8 decoding. But since \7 and \a both represent 0x07 in a C string, I would expect there to be other problems, if it's interpreting it as source. Ah well! Weird weird. While other control codes may have special meaning to a terminal or other device, to do not have special meaning to the operation of C string functions themselves (except possible for a 'getline' function looking for n -- but I do not remember is the C stdlib has any such functions). I am speaking from my memory of C. I have not looked at the Tk C code to see just what it did where to create the exception. I am just happy that Serhiy was able to fixed tkinter without causing another test to fail. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
On Sat, Feb 1, 2014 at 7:51 PM, Terry Reedy tjre...@udel.edu wrote: I should have added 'to C itself', as the string terminator. Oh, right. Yes, in that sense \0 is special. It's still wrong that an incoming text string gets interpreted as code, but that's probably just a consequence of the jump from Python to Tcl. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Python shell wont open idle or an exisiting py file
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. import idlelib.idle Exception in Tkinter callback Traceback (most recent call last): File C:\Python33\lib\tkinter\__init__.py, line 1475, in __call__ return self.func(*args) File C:\Python33\lib\idlelib\EditorWindow.py, line 927, in open_recent_file self.io.open(editFile=fn_closure) File C:\Python33\lib\idlelib\IOBinding.py, line 183, in open flist.open(filename) File C:\Python33\lib\idlelib\FileList.py, line 36, in open edit = self.EditorWindow(self, filename, key) File C:\Python33\lib\idlelib\PyShell.py, line 126, in __init__ EditorWindow.__init__(self, *args) File C:\Python33\lib\idlelib\EditorWindow.py, line 287, in __init__ if io.loadfile(filename): File C:\Python33\lib\idlelib\IOBinding.py, line 242, in loadfile self.updaterecentfileslist(filename) File C:\Python33\lib\idlelib\IOBinding.py, line 523, in updaterecentfileslist self.editwin.update_recent_files_list(filename) File C:\Python33\lib\idlelib\EditorWindow.py, line 915, in update_recent_files_list menu.delete(0, END) # clear, and rebuild: File C:\Python33\lib\tkinter\__init__.py, line 2778, in delete if 'command' in self.entryconfig(i): File C:\Python33\lib\tkinter\__init__.py, line 2788, in entryconfigure return self._configure(('entryconfigure', index), cnf, kw) File C:\Python33\lib\tkinter\__init__.py, line 1247, in _configure self.tk.call(_flatten((self._w, cmd: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 10: invalid start byte This is the error message.-- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
rpuc...@cox.net wrote: Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. import idlelib.idle Exception in Tkinter callback Traceback (most recent call last): File C:\Python33\lib\tkinter\__init__.py, line 1475, in __call__ return self.func(*args) File C:\Python33\lib\idlelib\EditorWindow.py, line 927, in open_recent_file self.io.open(editFile=fn_closure) File C:\Python33\lib\idlelib\IOBinding.py, line 183, in open flist.open(filename) File C:\Python33\lib\idlelib\FileList.py, line 36, in open edit = self.EditorWindow(self, filename, key) File C:\Python33\lib\idlelib\PyShell.py, line 126, in __init__ EditorWindow.__init__(self, *args) File C:\Python33\lib\idlelib\EditorWindow.py, line 287, in __init__ if io.loadfile(filename): File C:\Python33\lib\idlelib\IOBinding.py, line 242, in loadfile self.updaterecentfileslist(filename) File C:\Python33\lib\idlelib\IOBinding.py, line 523, in updaterecentfileslist self.editwin.update_recent_files_list(filename) File C:\Python33\lib\idlelib\EditorWindow.py, line 915, in update_recent_files_list menu.delete(0, END) # clear, and rebuild: File C:\Python33\lib\tkinter\__init__.py, line 2778, in delete if 'command' in self.entryconfig(i): File C:\Python33\lib\tkinter\__init__.py, line 2788, in entryconfigure return self._configure(('entryconfigure', index), cnf, kw) File C:\Python33\lib\tkinter\__init__.py, line 1247, in _configure self.tk.call(_flatten((self._w, cmd: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 10: invalid start byte This is the error message. What happens if you rename $HOME/.idlerc/recent-files.lst (to an arbitrary name, just to keep it around for further debugging if the file indeed triggers the problem)? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
On 1/31/2014 2:51 PM, Peter Otten wrote: rpuc...@cox.net wrote: Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. import idlelib.idle Exception in Tkinter callback Traceback (most recent call last): File C:\Python33\lib\tkinter\__init__.py, line 1475, in __call__ return self.func(*args) File C:\Python33\lib\idlelib\EditorWindow.py, line 927, in open_recent_file self.io.open(editFile=fn_closure) File C:\Python33\lib\idlelib\IOBinding.py, line 183, in open flist.open(filename) File C:\Python33\lib\idlelib\FileList.py, line 36, in open edit = self.EditorWindow(self, filename, key) File C:\Python33\lib\idlelib\PyShell.py, line 126, in __init__ EditorWindow.__init__(self, *args) File C:\Python33\lib\idlelib\EditorWindow.py, line 287, in __init__ if io.loadfile(filename): File C:\Python33\lib\idlelib\IOBinding.py, line 242, in loadfile self.updaterecentfileslist(filename) File C:\Python33\lib\idlelib\IOBinding.py, line 523, in updaterecentfileslist self.editwin.update_recent_files_list(filename) File C:\Python33\lib\idlelib\EditorWindow.py, line 915, in update_recent_files_list menu.delete(0, END) # clear, and rebuild: File C:\Python33\lib\tkinter\__init__.py, line 2778, in delete if 'command' in self.entryconfig(i): File C:\Python33\lib\tkinter\__init__.py, line 2788, in entryconfigure return self._configure(('entryconfigure', index), cnf, kw) File C:\Python33\lib\tkinter\__init__.py, line 1247, in _configure self.tk.call(_flatten((self._w, cmd: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 10: invalid start byte This is the error message. What happens if you rename $HOME/.idlerc/recent-files.lst For me, on Win7, $HOME is C:/Users/Terry (to an arbitrary name, just to keep it around for further debugging if the file indeed triggers the problem)? Or try the following in the console with the file name changed, but without the first line wrapped with open('C:/Users/Terry/.idlerc/recent-files.lst', encoding='utf-8') as f: for n, line in enumerate(f): print(n, line, end='') There was a (non-obvious) bug, recently fixed in http://bugs.python.org/issue19020 which caused this seemingly bogus error message when an entry in recent-files.list contained a directory or file name beginning with '0'. H:\HP_Documents\0PythonWork\AirplaneKinematics\accel2.py caused this message UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 14: invalid start byte If your file has such a line, either delete it or upgrade to 3.3.4 (rc1, final soon) or 3.4.0 (rc1 due soon). -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
On Sat, Feb 1, 2014 at 12:45 PM, Terry Reedy tjre...@udel.edu wrote: H:\HP_Documents\0PythonWork\AirplaneKinematics\accel2.py caused this message UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 14: invalid start byte So... something's interpreting \0 as codepoint U+ (which it shouldn't), storing that in UTF-8 as 0xC0 0x80 (which it shouldn't), and then giving it to Python to decode. That's a weird little combination bug right there. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
On 2014-02-01 01:52, Chris Angelico wrote: On Sat, Feb 1, 2014 at 12:45 PM, Terry Reedy tjre...@udel.edu wrote: H:\HP_Documents\0PythonWork\AirplaneKinematics\accel2.py caused this message UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 14: invalid start byte So... something's interpreting \0 as codepoint U+ (which it shouldn't), storing that in UTF-8 as 0xC0 0x80 (which it shouldn't), and then giving it to Python to decode. That's a weird little combination bug right there. I think that some years ago I heard about a variation on UTF-8 (Microsoft?) where codepoint U+ is encoded as 0xC0 0x80 so that the null byte can be used as the string terminator. I had a look on Wikipedia found this: http://en.wikipedia.org/wiki/Null-terminated_string -- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
On Sat, Feb 1, 2014 at 1:54 PM, MRAB pyt...@mrabarnett.plus.com wrote: I think that some years ago I heard about a variation on UTF-8 (Microsoft?) where codepoint U+ is encoded as 0xC0 0x80 so that the null byte can be used as the string terminator. I had a look on Wikipedia found this: http://en.wikipedia.org/wiki/Null-terminated_string Yeah, it's a common abuse of UTF-8. It's a violation of spec, but an understandable one. However, I don't understand why the first part - why should \0 become U+ but (presumably) the \a later on (...cs\accel...) doesn't become U+0007, etc? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
On 1/31/2014 8:52 PM, Chris Angelico wrote: On Sat, Feb 1, 2014 at 12:45 PM, Terry Reedy tjre...@udel.edu wrote: H:\HP_Documents\0PythonWork\AirplaneKinematics\accel2.py caused this message UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 14: invalid start byte So... something's interpreting \0 as codepoint U+ (which it shouldn't), storing that in UTF-8 as 0xC0 0x80 (which it shouldn't), and then giving it to Python to decode. Right. Which is why it puzzled me. Credit Serhiy for unraveling this and fixing it. That's a weird little combination bug right there. Which started with Microsoft's decision to reuse the string excape character '\' as a directory separator. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
On 1/31/2014 10:36 PM, Chris Angelico wrote: On Sat, Feb 1, 2014 at 1:54 PM, MRAB pyt...@mrabarnett.plus.com wrote: I think that some years ago I heard about a variation on UTF-8 (Microsoft?) where codepoint U+ is encoded as 0xC0 0x80 so that the null byte can be used as the string terminator. I had a look on Wikipedia found this: http://en.wikipedia.org/wiki/Null-terminated_string Yeah, it's a common abuse of UTF-8. It's a violation of spec, but an understandable one. However, I don't understand why the first part - why should \0 become U+ but (presumably) the \a later on (...cs\accel...) doesn't become U+0007, etc? Because only \0 has a special meaning in a C string, and Tk is written in C and uses C strings. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
On Sat, Feb 1, 2014 at 4:46 PM, Terry Reedy tjre...@udel.edu wrote: On 1/31/2014 10:36 PM, Chris Angelico wrote: On Sat, Feb 1, 2014 at 1:54 PM, MRAB pyt...@mrabarnett.plus.com wrote: I think that some years ago I heard about a variation on UTF-8 (Microsoft?) where codepoint U+ is encoded as 0xC0 0x80 so that the null byte can be used as the string terminator. I had a look on Wikipedia found this: http://en.wikipedia.org/wiki/Null-terminated_string Yeah, it's a common abuse of UTF-8. It's a violation of spec, but an understandable one. However, I don't understand why the first part - why should \0 become U+ but (presumably) the \a later on (...cs\accel...) doesn't become U+0007, etc? Because only \0 has a special meaning in a C string, and Tk is written in C and uses C strings. Eh? I've used \a in C programs (not often but I have used it). It's possible that \0 is the only one that actually bombs anything (because of C0 80 representation). But since \7 and \a both represent 0x07 in a C string, I would expect there to be other problems, if it's interpreting it as source. Ah well! Weird weird. ChrisA -- https://mail.python.org/mailman/listinfo/python-list