[Idle-dev] CVS: idle PyShell.py,1.75,1.76 run.py,1.22,1.23

Kurt B. Kaiser kbk@users.sourceforge.net
Wed, 09 Jul 2003 20:47:42 -0700


Update of /cvsroot/idlefork/idle
In directory sc8-pr-cvs1:/tmp/cvs-serv4082

Modified Files:
	PyShell.py run.py 
Log Message:
SF Patch 682347
"Convert Unicode strings from readline to IOBinding.encoding.  Also
set sys.std{in|out|err}.encoding, for both the local and the subprocess
case."  

This is Martin v. Loewis' patch to idlelib 22Jun03.
 Modified Files:
 	PyShell.py run.py 


Index: PyShell.py
===================================================================
RCS file: /cvsroot/idlefork/idle/PyShell.py,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -r1.75 -r1.76
*** PyShell.py	22 Jun 2003 19:45:46 -0000	1.75
--- PyShell.py	10 Jul 2003 03:47:40 -0000	1.76
***************
*** 745,751 ****
          self.save_stderr = sys.stderr
          self.save_stdin = sys.stdin
!         self.stdout = PseudoFile(self, "stdout")
!         self.stderr = PseudoFile(self, "stderr")
!         self.console = PseudoFile(self, "console")
          if not use_subprocess:
              sys.stdout = self.stdout
--- 745,752 ----
          self.save_stderr = sys.stderr
          self.save_stdin = sys.stdin
!         import IOBinding
!         self.stdout = PseudoFile(self, "stdout", IOBinding.encoding)
!         self.stderr = PseudoFile(self, "stderr", IOBinding.encoding)
!         self.console = PseudoFile(self, "console", IOBinding.encoding)
          if not use_subprocess:
              sys.stdout = self.stdout
***************
*** 890,893 ****
--- 891,900 ----
              self.reading = save
          line = self.text.get("iomark", "end-1c")
+         if isinstance(line, unicode):
+             import IOBinding
+             try:
+                 line = line.encode(IOBinding.encoding)
+             except UnicodeError:
+                 pass
          self.resetoutput()
          if self.canceled:
***************
*** 1094,1101 ****
  class PseudoFile:
  
!     def __init__(self, shell, tags):
          self.shell = shell
          self.tags = tags
          self.softspace = 0
  
      def write(self, s):
--- 1101,1109 ----
  class PseudoFile:
  
!     def __init__(self, shell, tags, encoding=None):
          self.shell = shell
          self.tags = tags
          self.softspace = 0
+         self.encoding = encoding
  
      def write(self, s):

Index: run.py
===================================================================
RCS file: /cvsroot/idlefork/idle/run.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** run.py	5 Jun 2003 23:51:29 -0000	1.22
--- run.py	10 Jul 2003 03:47:40 -0000	1.23
***************
*** 213,216 ****
--- 213,219 ----
          sys.stdout = self.get_remote_proxy("stdout")
          sys.stderr = self.get_remote_proxy("stderr")
+         import IOBinding
+         sys.stdin.encoding = sys.stdout.encoding = \
+                              sys.stderr.encoding = IOBinding.encoding
          self.interp = self.get_remote_proxy("interp")
          rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05)