[Idle-dev] [ idlefork-Bugs-1698204 ] [IDLE-BUG] HP-UX

SourceForge.net noreply at sourceforge.net
Wed Apr 11 09:34:58 CEST 2007


Bugs item #1698204, was opened at 2007-04-11 00:34
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109579&aid=1698204&group_id=9579

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: [IDLE-BUG] HP-UX 

Initial Comment:
I recently tried to use IDLE in HP-UX system and I have encountered some errors.
I have corrected it myself, but like to report these errors/Bugs.

My  system configuration
    HP-UX  B.11.00 
    python 2.5 
    Tcl ActiveTcl8.4
    Locale "en_US.iso88591"

First time it stated ok without any problem, but the next time it gave the
follwing error message: 
The Error happend when the IDLE tred to add the filenames in to the recent file list.
===============================
filename: /mmc/users/gg00215/mypy/contact6.py
Traceback (most recent call last):
  File "/usr/local/bin/idle", line 5, in <module>
    main()
  File "/mmc/users/gg00215/Python-2.5/Lib/idlelib/PyShell.py", line 1402, in main
    shell = flist.open_shell()
  File "/mmc/users/gg00215/Python-2.5/Lib/idlelib/PyShell.py", line 275, in open_shell
    self.pyshell = PyShell(self)
  File "/mmc/users/gg00215/Python-2.5/Lib/idlelib/PyShell.py", line 811, in __init__
    OutputWindow.__init__(self, flist, None, None)
  File "/mmc/users/gg00215/Python-2.5/Lib/idlelib/OutputWindow.py", line 16, in __init__
    EditorWindow.__init__(self, *args)
  File "/mmc/users/gg00215/Python-2.5/Lib/idlelib/EditorWindow.py", line 248, in __init__
    self.update_recent_files_list()
  File "/mmc/users/gg00215/Python-2.5/Lib/idlelib/EditorWindow.py", line 735, in update_recent_files_list
    ufile_name = self._filename_to_unicode(file_name)
  File "/mmc/users/gg00215/Python-2.5/Lib/idlelib/EditorWindow.py", line 284, in _filename_to_unicode
    return filename.decode(self.filesystemencoding)
TypeError: decode() argument 1 must be string, not None
===============================

* The reason I have found out that the argument is None in File "/mmc/users/gg00215/Python-2.5/Lib/idlelib/EditorWindow.py", line 284, in _filename_to_unicodein 
   becuase the line 36:filesystemencoding = sys.getfilesystemencoding() of /mmc/users/gg00215/Python-2.5/Lib/idlelib/IOBinding.py
   returns None:
* The reason for the sys.getfilesystemencoding() is giving None is becuase of my locale which
   is en_US.iso88591.

Correction:

* I tried to fix the problem and I assumed the lcoale en_US.iso88591 is the default file
  system encoding.
* And I have modified the function  _filename_to_unicode by adding one except statement for
TypeError, the code given below.
===========
    def _filename_to_unicode(self, filename):
        """convert filename to unicode in order to display it in Tk"""
        if isinstance(filename, unicode) or not filename:
            return filename
        else:
            try:
                return filename.decode(self.filesystemencoding)
            except UnicodeDecodeError:
                # XXX
                try:
		    return filename.decode(self.encoding)
                except UnicodeDecodeError:
                    # byte-to-byte conversion
                    return filename.decode('iso8859-1')
	    #raja next twolines
	    except TypeError:
        	return filename.decode('iso8859-1')
===========

after that it worked nice, but becuase of curiosity I tried to open a text file which had a
Japanese name. Then I have encountered anotehr error/bug in IOBinding.py at function
askopenfile()
so I have modified the the code as below again adding an except statement

==================
    def askopenfile(self):
        dir, base = self.defaultfilename("open")
        if not self.opendialog:
            self.opendialog = tkFileDialog.Open(master=self.text,
                                                filetypes=self.filetypes)
        filename = self.opendialog.show(initialdir=dir, initialfile=base)
    	#raja try except
        try:
	    if isinstance(filename, unicode):
        	filename = filename.encode(filesystemencoding)
            return filename
	except TypeError:
	    return filename.encode('iso8859-1')
=======================

Now it works without any problems. I am not a professional programmer, so I would greatly
appreciate if you can fix this error with proper measures.

Thanks a lot in advance

Raj




----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109579&aid=1698204&group_id=9579


More information about the IDLE-dev mailing list