]> granicus.if.org Git - python/commitdiff
Merged revisions 85820,85823,85825,85840,85843-85845,85849-85851,85855,85867,85875...
authorGeorg Brandl <georg@python.org>
Fri, 26 Nov 2010 08:59:40 +0000 (08:59 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 26 Nov 2010 08:59:40 +0000 (08:59 +0000)
svn+ssh://svn.python.org/python/branches/py3k

........
  r85820 | georg.brandl | 2010-10-24 16:20:22 +0200 (So, 24 Okt 2010) | 1 line

  Remove usage of exception indexing.
........
  r85823 | georg.brandl | 2010-10-24 16:32:45 +0200 (So, 24 Okt 2010) | 1 line

  Fix style.
........
  r85825 | georg.brandl | 2010-10-24 17:16:02 +0200 (So, 24 Okt 2010) | 1 line

  Add documentation about the default warnings filters.
........
  r85840 | georg.brandl | 2010-10-25 19:50:20 +0200 (Mo, 25 Okt 2010) | 1 line

  #3018: tkinter demo fixes for py3k.
........
  r85843 | georg.brandl | 2010-10-26 08:59:23 +0200 (Di, 26 Okt 2010) | 1 line

  Markup fix.
........
  r85844 | georg.brandl | 2010-10-26 12:39:14 +0200 (Di, 26 Okt 2010) | 1 line

  Work a bit more on tkinter demos.
........
  r85845 | georg.brandl | 2010-10-26 12:42:16 +0200 (Di, 26 Okt 2010) | 1 line

  faqwiz is removed.
........
  r85849 | georg.brandl | 2010-10-26 21:31:06 +0200 (Di, 26 Okt 2010) | 1 line

  #10200: typo.
........
  r85850 | georg.brandl | 2010-10-26 21:58:11 +0200 (Di, 26 Okt 2010) | 1 line

  #10200: typo.
........
  r85851 | georg.brandl | 2010-10-26 22:12:37 +0200 (Di, 26 Okt 2010) | 1 line

  Fix import.
........
  r85855 | georg.brandl | 2010-10-27 09:21:54 +0200 (Mi, 27 Okt 2010) | 1 line

  Encoding fix.
........
  r85867 | georg.brandl | 2010-10-27 22:01:51 +0200 (Mi, 27 Okt 2010) | 1 line

  Add David.
........
  r85875 | georg.brandl | 2010-10-28 10:38:30 +0200 (Do, 28 Okt 2010) | 1 line

  Fix bytes/str issues in get-remote-certificate.py.
........
  r85907 | georg.brandl | 2010-10-29 06:54:13 +0200 (Fr, 29 Okt 2010) | 1 line

  #10222: fix for overzealous AIX compiler.
........
  r85908 | georg.brandl | 2010-10-29 07:22:17 +0200 (Fr, 29 Okt 2010) | 1 line

  send_bytes obviously needs bytes...
........
  r85911 | georg.brandl | 2010-10-29 07:36:28 +0200 (Fr, 29 Okt 2010) | 1 line

  Fix markup error and update false positive entries from "make suspicious".
........
  r85914 | georg.brandl | 2010-10-29 08:17:38 +0200 (Fr, 29 Okt 2010) | 1 line

  (?:...) is a non-capturing, but still grouping construct.
........

34 files changed:
Demo/cgi/README
Demo/md5test/md5driver.py
Demo/tkinter/guido/attr_dialog.py [moved from Demo/tkinter/guido/AttrDialog.py with 99% similarity, mode: 0644]
Demo/tkinter/guido/canvasevents.py
Demo/tkinter/guido/dialog.py
Demo/tkinter/guido/electrons.py
Demo/tkinter/guido/hanoi.py
Demo/tkinter/guido/listtree.py
Demo/tkinter/guido/manpage.py [moved from Demo/tkinter/guido/ManPage.py with 77% similarity, mode: 0644]
Demo/tkinter/guido/mbox.py
Demo/tkinter/guido/mimeviewer.py [moved from Demo/tkinter/guido/MimeViewer.py with 82% similarity]
Demo/tkinter/guido/rmt.py
Demo/tkinter/guido/shell_window.py [moved from Demo/tkinter/guido/ShellWindow.py with 96% similarity, mode: 0644]
Demo/tkinter/guido/solitaire.py
Demo/tkinter/guido/sortvisu.py
Demo/tkinter/guido/ss1.py
Demo/tkinter/guido/svkill.py
Demo/tkinter/guido/tkman.py
Demo/tkinter/guido/wish.py
Demo/tkinter/matt/bind-w-mult-calls-p-type.py
Demo/tkinter/matt/entry-with-shared-variable.py
Demo/tkinter/matt/pong-demo-1.py
Demo/tkinter/matt/printing-coords-of-items.py
Doc/library/locale.rst
Doc/library/multiprocessing.rst
Doc/library/re.rst
Doc/library/string.rst
Doc/library/warnings.rst
Doc/tools/sphinxext/susp-ignored.csv
Lib/test/test_ssl.py
Misc/developers.txt
Parser/tokenizer.h
Tools/pynche/pyColorChooser.py
Tools/ssl/get-remote-certificate.py

index e50d2d051739206ee44346f2cb5bf24be98fcd44..c0631b6c636dd5734577214b6397e0b97286812e 100644 (file)
@@ -1,8 +1,7 @@
 CGI Examples
 ------------
 
-Here are some example CGI programs.  For a larger example, see
-../../Tools/faqwiz/.
+Here are some example CGI programs.
 
 cgi0.sh -- A shell script to test your server is configured for CGI
 cgi1.py -- A Python script to test your server is configured for CGI
index 7df3e757b095612d6cf5e02cb773235a07aca414..7f561aba407e437cf183f91b8ba5c9880501fb3d 100755 (executable)
@@ -80,7 +80,7 @@ def MDFilter():
     mdContext = md5()
 
     while 1:
-        data = sys.stdin.read(16)
+        data = sys.stdin.read(16).encode()
         if not data:
             break
         mdContext.update(data)
old mode 100755 (executable)
new mode 100644 (file)
similarity index 99%
rename from Demo/tkinter/guido/AttrDialog.py
rename to Demo/tkinter/guido/attr_dialog.py
index 5508e3b..229a558
@@ -14,6 +14,7 @@
 
 from tkinter import *
 
+
 class Option:
 
     varclass = StringVar            # May be overridden
@@ -45,6 +46,7 @@ class Option:
     def set(self, e=None):          # Should be overridden
         pass
 
+
 class BooleanOption(Option):
 
     varclass = BooleanVar
@@ -60,6 +62,7 @@ class BooleanOption(Option):
                                  command=self.set)
         self.button.pack(side=RIGHT)
 
+
 class EnumOption(Option):
 
     def addoption(self):
@@ -76,6 +79,7 @@ class EnumOption(Option):
                 value=v,
                 command=self.set)
 
+
 class StringOption(Option):
 
     def addoption(self):
@@ -87,6 +91,7 @@ class StringOption(Option):
         self.entry.pack(side=RIGHT, fill=X, expand=1)
         self.entry.bind('<Return>', self.set)
 
+
 class ReadonlyOption(Option):
 
     def addoption(self):
@@ -94,6 +99,7 @@ class ReadonlyOption(Option):
                            anchor=E)
         self.label.pack(side=RIGHT)
 
+
 class Dialog:
 
     def __init__(self, master):
@@ -120,7 +126,7 @@ class Dialog:
                 cl = self.classes[c]
             except KeyError:
                 cl = 'unknown'
-            if type(cl) == TupleType:
+            if type(cl) is tuple:
                 cl = self.enumoption
             elif cl == 'boolean':
                 cl = self.booleanoption
@@ -140,6 +146,7 @@ class Dialog:
     enumoption = EnumOption
     readonlyoption = ReadonlyOption
 
+
 class PackDialog(Dialog):
 
     def __init__(self, widget):
@@ -248,6 +255,7 @@ class RemotePackDialog(PackDialog):
     class stringoption(remotepackoption, StringOption): pass
     class readonlyoption(remotepackoption, ReadonlyOption): pass
 
+
 class WidgetDialog(Dialog):
 
     def __init__(self, widget):
@@ -357,6 +365,7 @@ class WidgetDialog(Dialog):
             'Slider': _bistate,
             }
 
+
 class RemoteWidgetDialog(WidgetDialog):
 
     def __init__(self, master, app, widget):
@@ -407,6 +416,7 @@ class RemoteWidgetDialog(WidgetDialog):
     class stringoption(remotewidgetoption, StringOption): pass
     class readonlyoption(remotewidgetoption, ReadonlyOption): pass
 
+
 def test():
     import sys
     root = Tk()
@@ -435,12 +445,11 @@ def remotetest(root, app):
     list.app = app                  # Pass it on to handler
 
 def opendialogs(e):
-    import string
     list = e.widget
     sel = list.curselection()
     for i in sel:
         item = list.get(i)
-        widget = string.split(item)[0]
+        widget = item.split()[0]
         RemoteWidgetDialog(list, list.app, widget)
         if widget == '.': continue
         try:
index aeb0eb1d626d992a175169982ce64c7656fa7bb1..ffeb0caaf8dd75c56120edebe6a1b8d50c9092b0 100644 (file)
@@ -1,15 +1,41 @@
 #! /usr/bin/env python
 
 from tkinter import *
-from Canvas import Oval, Group, CanvasText
 
 
-# Fix a bug in Canvas.Group as distributed in Python 1.4.  The
-# distributed bind() method is broken.  This is what should be used:
+# Since Canvas.Group is no longer present, the following class reproduces
+# a subset of the old Group class that is used by this app.
+
+class Group:
+    def __init__(self, canvas, tag=None):
+        if tag is None:
+            tag = 'Group%d' % id(self)
+
+        self.tag = self.id = tag
+        self.canvas = canvas
+        self.canvas.dtag(self.tag)
+
+    def __str__(self):
+        return self.tag
+
+    def _do(self, cmd, *args):
+        return self.canvas.tk.call(self.canvas._w, cmd, self.tag, *args)
+
+    def addtag_withtag(self, tagOrId):
+        self._do('addtag', 'withtag', tagOrId)
+
+    def bind(self, sequence=None, command=None, add=None):
+        return self.canvas.tag_bind(self.id, sequence, command, add)
+
+    def move(self, x_amount, y_amount):
+        self._do('move', x_amount, y_amount)
+
+    def dtag(self, tagToDelete=None):
+        self._do('dtag', tagToDelete)
+
+    def tkraise(self, aboveThis=None):
+        self._do('raise', aboveThis)
 
-class Group(Group):
-    def bind(self, sequence=None, command=None):
-        return self.canvas.tag_bind(self.id, sequence, command)
 
 class Object:
 
@@ -29,7 +55,6 @@ class Object:
 
     All instance attributes are public since the derived class may
     need them.
-
     """
 
     def __init__(self, canvas, x=0, y=0, fill='red', text='object'):
@@ -44,12 +69,10 @@ class Object:
         return str(self.group)
 
     def createitems(self, fill, text):
-        self.__oval = Oval(self.canvas,
-                           self.x-20, self.y-10, self.x+20, self.y+10,
-                           fill=fill, width=3)
+        self.__oval = self.canvas.create_oval(self.x - 20, self.y - 10,
+            self.x + 20, self.y + 20, fill=fill, width=3)
         self.group.addtag_withtag(self.__oval)
-        self.__text = CanvasText(self.canvas,
-                           self.x, self.y, text=text)
+        self.__text = self.canvas.create_text(self.x, self.y, text=text)
         self.group.addtag_withtag(self.__text)
 
     def moveby(self, dx, dy):
@@ -75,18 +98,15 @@ class Object:
 
 
 class Bottom(Object):
-
     """An object to serve as the bottom of a pile."""
 
     def createitems(self, *args):
-        self.__oval = Oval(self.canvas,
-                           self.x-20, self.y-10, self.x+20, self.y+10,
-                           fill='gray', outline='')
+        self.__oval = self.canvas.create_oval(self.x - 20, self.y - 10,
+            self.x + 20, self.y + 10, fill='gray', outline='')
         self.group.addtag_withtag(self.__oval)
 
 
 class Pile:
-
     """A group of graphical objects."""
 
     def __init__(self, canvas, x, y, tag=None):
index 1832ba481b0ef909184c3d88ba8a251a8dcbd5da..2a4a9391112799b5f28ff291f585df9f7a9e836e 100755 (executable)
@@ -24,8 +24,7 @@ def dialog(master, title, text, bitmap, default, *args):
 
     # 2. Fill the top part with the bitmap and message.
 
-    msg = Message(top, width='3i', text=text,
-                  font='-Adobe-Times-Medium-R-Normal-*-180-*')
+    msg = Message(top, width='3i', text=text)
     msg.pack(side=RIGHT, expand=1, fill=BOTH, padx='3m', pady='3m')
     if bitmap:
         bm = Label(top, bitmap=bitmap)
index e3bf4687874ac1940e636dd7eb6d1340504cdc2c..b5c9ec09ffffc9d08ffbc1911cefe626b8c7d41a 100755 (executable)
@@ -62,11 +62,11 @@ class Electrons:
 
 # Main program
 def main():
-    import sys, string
+    import sys
 
     # First argument is number of electrons, default 30
     if sys.argv[1:]:
-        n = string.atoi(sys.argv[1])
+        n = int(sys.argv[1])
     else:
         n = 30
 
index a29b1d7dab8e045f454937b1985cfd79d855d7f2..34a0bbadd33b5d2760796cd2dfc63e43e0e4d6d6 100755 (executable)
@@ -125,11 +125,11 @@ class Tkhanoi:
 
 # Main program
 def main():
-    import sys, string
+    import sys
 
     # First argument is number of pegs, default 4
     if sys.argv[1:]:
-        n = string.atoi(sys.argv[1])
+        n = int(sys.argv[1])
     else:
         n = 4
 
index 625d20e622ccb0dd0f0f7e8eeaecdfdc8a00b3ff..8db5b60ddbe900fcad3a2bd4ae6d1e05c6b7e415 100755 (executable)
@@ -1,7 +1,6 @@
 # List a remote app's widget tree (names and classes only)
 
 import sys
-import string
 
 from tkinter import *
 
@@ -13,8 +12,6 @@ def listtree(master, app):
 
 def listnodes(list, app, widget, level):
     klass = list.send(app, 'winfo', 'class', widget)
-##      i = string.rindex(widget, '.')
-##      list.insert(END, '%s%s (%s)' % ((level-1)*'.   ', widget[i:], klass))
     list.insert(END, '%s (%s)' % (widget, klass))
     children = list.tk.splitlist(
             list.send(app, 'winfo', 'children', widget))
old mode 100755 (executable)
new mode 100644 (file)
similarity index 77%
rename from Demo/tkinter/guido/ManPage.py
rename to Demo/tkinter/guido/manpage.py
index a9309a3..750c675
@@ -1,14 +1,13 @@
 # Widget to display a man page
 
+import os
 import re
+import sys
+
 from tkinter import *
-from tkinter import _tkinter
+from tkinter.font import Font
 from tkinter.scrolledtext import ScrolledText
 
-# XXX These fonts may have to be changed to match your system
-BOLDFONT = '*-Courier-Bold-R-Normal-*-120-*'
-ITALICFONT = '*-Courier-Medium-O-Normal-*-120-*'
-
 # XXX Recognizing footers is system dependent
 # (This one works for IRIX 5.2 and Solaris 2.2)
 footerprog = re.compile(
@@ -16,64 +15,64 @@ footerprog = re.compile(
 emptyprog = re.compile('^[ \t]*\n')
 ulprog = re.compile('^[ \t]*[Xv!_][Xv!_ \t]*\n')
 
-# Basic Man Page class -- does not disable editing
+
 class EditableManPage(ScrolledText):
+    """Basic Man Page class -- does not disable editing."""
 
-    # Initialize instance
     def __init__(self, master=None, **cnf):
-        # Initialize base class
         ScrolledText.__init__(self, master, **cnf)
 
+        bold = Font(font=self['font']).copy()
+        bold.config(weight='bold')
+        italic = Font(font=self['font']).copy()
+        italic.config(slant='italic')
+
         # Define tags for formatting styles
         self.tag_config('X', underline=1)
-        self.tag_config('!', font=BOLDFONT)
-        self.tag_config('_', font=ITALICFONT)
+        self.tag_config('!', font=bold)
+        self.tag_config('_', font=italic)
 
         # Set state to idle
         self.fp = None
         self.lineno = 0
 
-    # Test whether we are busy parsing a file
     def busy(self):
+        """Test whether we are busy parsing a file."""
         return self.fp != None
 
-    # Ensure we're not busy
     def kill(self):
+        """Ensure we're not busy."""
         if self.busy():
             self._endparser()
 
-    # Parse a file, in the background
     def asyncparsefile(self, fp):
+        """Parse a file, in the background."""
         self._startparser(fp)
-        self.tk.createfilehandler(fp, _tkinter.READABLE,
+        self.tk.createfilehandler(fp, READABLE,
                                   self._filehandler)
 
-    parsefile = asyncparsefile      # Alias
+    parsefile = asyncparsefile   # Alias
 
-    # I/O handler used by background parsing
     def _filehandler(self, fp, mask):
+        """I/O handler used by background parsing."""
         nextline = self.fp.readline()
         if not nextline:
             self._endparser()
             return
         self._parseline(nextline)
 
-    # Parse a file, now (cannot be aborted)
     def syncparsefile(self, fp):
-        from select import select
-        def avail(fp=fp, tout=0.0, select=select):
-            return select([fp], [], [], tout)[0]
-        height = self.getint(self['height'])
+        """Parse a file, now (cannot be aborted)."""
         self._startparser(fp)
-        while 1:
+        while True:
             nextline = fp.readline()
             if not nextline:
                 break
             self._parseline(nextline)
         self._endparser()
 
-    # Initialize parsing from a particular file -- must not be busy
     def _startparser(self, fp):
+        """Initialize parsing from a particular file -- must not be busy."""
         if self.busy():
             raise RuntimeError('startparser: still busy')
         fp.fileno()             # Test for file-ness
@@ -87,33 +86,33 @@ class EditableManPage(ScrolledText):
         self.delete('1.0', END)
         self['state'] = savestate
 
-    # End parsing -- must be busy, need not be at EOF
     def _endparser(self):
+        """End parsing -- must be busy, need not be at EOF."""
         if not self.busy():
             raise RuntimeError('endparser: not busy')
         if self.buffer:
             self._parseline('')
         try:
             self.tk.deletefilehandler(self.fp)
-        except TclError as msg:
+        except TclError:
             pass
         self.fp.close()
         self.fp = None
         del self.ok, self.empty, self.buffer
 
-    # Parse a single line
     def _parseline(self, nextline):
+        """Parse a single line."""
         if not self.buffer:
             # Save this line -- we need one line read-ahead
             self.buffer = nextline
             return
-        if emptyprog.match(self.buffer) >= 0:
+        if emptyprog.match(self.buffer):
             # Buffered line was empty -- set a flag
             self.empty = 1
             self.buffer = nextline
             return
         textline = self.buffer
-        if ulprog.match(nextline) >= 0:
+        if ulprog.match(nextline):
             # Next line is properties for buffered line
             propline = nextline
             self.buffer = None
@@ -127,7 +126,7 @@ class EditableManPage(ScrolledText):
             self.ok = 1
             self.empty = 0
             return
-        if footerprog.match(textline) >= 0:
+        if footerprog.match(textline):
             # Footer -- start skipping until next non-blank line
             self.ok = 0
             self.empty = 0
@@ -161,8 +160,8 @@ class EditableManPage(ScrolledText):
         self.lineno = self.lineno + 1
         self['state'] = savestate
 
-    # Insert a string at the end, with at most one property (tag)
     def _insert_prop(self, str, prop = ' '):
+        """Insert a string at the end, with at most one property (tag)."""
         here = self.index(AtInsert())
         self.insert(AtInsert(), str)
         if TkVersion <= 4.0:
@@ -172,10 +171,10 @@ class EditableManPage(ScrolledText):
         if prop != ' ':
             self.tag_add(prop, here, AtInsert())
 
-# Readonly Man Page class -- disables editing, otherwise the same
+
 class ReadonlyManPage(EditableManPage):
+    """Readonly Man Page class -- disables editing, otherwise the same."""
 
-    # Initialize instance
     def __init__(self, master=None, **cnf):
         cnf['state'] = DISABLED
         EditableManPage.__init__(self, master, **cnf)
@@ -183,14 +182,11 @@ class ReadonlyManPage(EditableManPage):
 # Alias
 ManPage = ReadonlyManPage
 
-# Test program.
 # usage: ManPage [manpage]; or ManPage [-f] file
 # -f means that the file is nroff -man output run through ul -i
-def test():
-    import os
-    import sys
+def main():
     # XXX This directory may be different on your system
-    MANDIR = '/usr/local/man/mann'
+    MANDIR = ''
     DEFAULTPAGE = 'Tcl'
     formatted = 0
     if sys.argv[1:] and sys.argv[1] == '-f':
@@ -211,10 +207,9 @@ def test():
     if formatted:
         fp = open(name, 'r')
     else:
-        fp = os.popen('nroff -man %s | ul -i' % name, 'r')
+        fp = os.popen('nroff -man -c %s | ul -i' % name, 'r')
     manpage.parsefile(fp)
     root.mainloop()
 
-# Run the test program when called as a script
 if __name__ == '__main__':
-    test()
+    main()
index 45c384e66c82b1596b29174b2560664257e726c8..754a31240220cdac378d824cc80080a77b19c634 100755 (executable)
@@ -3,17 +3,15 @@
 # Scan MH folder, display results in window
 
 import os
-import sys
 import re
+import sys
 import getopt
-import string
-import mhlib
-
+import mailbox
 from tkinter import *
 
 from dialog import dialog
 
-mailbox = os.environ['HOME'] + '/Mail'
+MBOXPATH = os.environ['HOME'] + '/Mail'
 
 def main():
     global root, tk, top, mid, bot
@@ -38,8 +36,8 @@ def main():
 
     # Initialize MH
 
-    mh = mhlib.MH()
-    mhf = mh.openfolder(folder)
+    mh = mailbox.MH(MBOXPATH)
+    mhf = mh.get_folder(folder)
 
     # Build widget hierarchy
 
@@ -171,7 +169,7 @@ def open_folder(e=None):
         return
     i = sel[0]
     folder = folderbox.get(i)
-    mhf = mh.openfolder(folder)
+    mhf = mh.get_folder(folder)
     rescan()
 
 def open_message(e=None):
@@ -189,11 +187,12 @@ def open_message(e=None):
     tk.call('update', 'idletasks')
     i = sel[0]
     line = scanbox.get(i)
-    if scanparser.match(line) >= 0:
-        num = string.atoi(scanparser.group(1))
-        m = mhf.openmessage(num)
+    m = scanparser.match(line)
+    if m:
+        num = int(m.group(1))
+        m = mhf.get_message(num)
         if viewer: viewer.destroy()
-        from MimeViewer import MimeViewer
+        from mimeviewer import MimeViewer
         viewer = MimeViewer(bot, '+%s/%d' % (folder, num), m)
         viewer.pack()
         viewer.show()
@@ -212,9 +211,11 @@ def remove_message(e=None):
     todo = []
     for i in sel:
         line = scanbox.get(i)
-        if scanparser.match(line) >= 0:
-            todo.append(string.atoi(scanparser.group(1)))
-    mhf.removemessages(todo)
+        m = scanparser.match(line)
+        if m:
+            toremove = int(m.group(1))
+            todo.append(toremove)
+            mhf.remove(toremove)
     rescan()
     fixfocus(min(todo), itop)
 
@@ -240,12 +241,13 @@ def refile_message(e=None):
     todo = []
     for i in sel:
         line = scanbox.get(i)
-        if scanparser.match(line) >= 0:
-            todo.append(string.atoi(scanparser.group(1)))
+        m = scanparser.match(line)
+        if m:
+            todo.append(int(m.group(1)))
     if lastrefile != refileto or not tofolder:
         lastrefile = refileto
         tofolder = None
-        tofolder = mh.openfolder(lastrefile)
+        tofolder = mh.get_folder(lastrefile)
     mhf.refilemessages(todo, tofolder)
     rescan()
     fixfocus(min(todo), itop)
@@ -254,18 +256,18 @@ def fixfocus(near, itop):
     n = scanbox.size()
     for i in range(n):
         line = scanbox.get(repr(i))
-        if scanparser.match(line) >= 0:
-            num = string.atoi(scanparser.group(1))
+        m = scanparser.match(line)
+        if m:
+            num = int(m.group(1))
             if num >= near:
                 break
     else:
         i = 'end'
-    scanbox.select_from(i)
     scanbox.yview(itop)
 
 def setfolders():
     folderbox.delete(0, 'end')
-    for fn in mh.listallfolders():
+    for fn in mh.list_folders():
         folderbox.insert('end', fn)
 
 def rescan():
@@ -278,6 +280,7 @@ def rescan():
         scanbox.insert('end', line)
 
 def scanfolder(folder = 'inbox', sequence = 'all'):
-    return [line[:-1] for line in os.popen('scan +%s %s' % (folder, sequence), 'r').readlines()]
+    return [line[:-1] for line in
+            os.popen('scan +%s %s' % (folder, sequence), 'r').readlines()]
 
 main()
similarity index 82%
rename from Demo/tkinter/guido/MimeViewer.py
rename to Demo/tkinter/guido/mimeviewer.py
index 11701cd0f2e4b1e6e2dce4c9a799500611b949f3..babed8f5d0e5be4b2e56e9f19bfb0935fe68b43a 100755 (executable)
@@ -1,13 +1,29 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 
 # View a single MIME multipart message.
 # Display each part as a box.
 
-import string
-from types import *
+import os
+import sys
+import getopt
+import mailbox
 from tkinter import *
 from tkinter.scrolledtext import ScrolledText
 
+MBOXPATH = os.environ['HOME'] + '/Mail'
+
+class Error(Exception):
+    pass
+
+def getcurrent(self):
+    """Return the current message.  Raise Error when there is none."""
+    seqs = self.get_sequences()
+    try:
+        return max(seqs['cur'])
+    except (ValueError, KeyError):
+        raise Error("no cur message")
+
+
 class MimeViewer:
     def __init__(self, parent, title, msg):
         self.title = title
@@ -18,8 +34,10 @@ class MimeViewer:
                              {'text': title,
                               'command': self.toggle})
         self.button.pack({'anchor': 'w'})
-        headertext = msg.getheadertext(
-                lambda x: x != 'received' and x[:5] != 'x400-')
+        headertext = []
+        for item in msg.items():
+            headertext.append("%s: %s" % item)
+        headertext = '\n'.join(headertext)
         height = countlines(headertext, 4)
         if height:
             self.htext = ScrolledText(self.frame,
@@ -38,8 +56,8 @@ class MimeViewer:
                                   'ipady': 2,
                                   'fill': 'x',
                                   'after': self.button}
-        body = msg.getbody()
-        if type(body) == StringType:
+        body = msg.get_payload()
+        if type(body) == str:
             self.pad = None
             height = countlines(body, 10)
             if height:
@@ -102,16 +120,13 @@ def countlines(str, limit):
     i = 0
     n = 0
     while  n < limit:
-        i = string.find(str, '\n', i)
+        i = str.find('\n', i)
         if i < 0: break
         n = n+1
         i = i+1
     return n
 
 def main():
-    import sys
-    import getopt
-    import mhlib
     opts, args = getopt.getopt(sys.argv[1:], '')
     for o, a in opts:
         pass
@@ -121,13 +136,13 @@ def main():
         if arg[:1] == '+':
             folder = arg[1:]
         else:
-            message = string.atoi(arg)
+            message = int(arg)
 
-    mh = mhlib.MH()
-    f = mh.openfolder(folder)
-    if not message:
-        message = f.getcurrent()
-    m = f.openmessage(message)
+    mh = mailbox.MH(MBOXPATH)
+    f = mh.get_folder(folder)
+    if message is None:
+        message = getcurrent(f)
+    m = mailbox.MHMessage(f.get(message))
 
     root = Tk()
     tk = root.tk
@@ -140,4 +155,5 @@ def main():
 
     tk.mainloop()
 
-if __name__ == '__main__': main()
+if __name__ == '__main__':
+    main()
index 7b3f700e19c2565a2d0c21bef15072882301e736..350d60bb51fc2bce00c74b0ef8c54f0d846db2de 100755 (executable)
@@ -28,7 +28,7 @@ s = Scrollbar(f, relief=FLAT)
 s.pack(side=RIGHT, fill=Y)
 t = Text(f, relief=RAISED, borderwidth=2, yscrollcommand=s.set, setgrid=1)
 t.pack(side=LEFT, fill=BOTH, expand=1)
-t.tag_config('bold', font='-Adobe-Courier-Bold-R-Normal-*-120-*')
+t.tag_config('bold')
 s['command'] = t.yview
 
 root.title('Tk Remote Controller')
old mode 100755 (executable)
new mode 100644 (file)
similarity index 96%
rename from Demo/tkinter/guido/ShellWindow.py
rename to Demo/tkinter/guido/shell_window.py
index fffcbc5..c5a0401
@@ -1,6 +1,5 @@
 import os
 import sys
-import string
 from tkinter import *
 from tkinter.scrolledtext import ScrolledText
 from tkinter.dialog import Dialog
@@ -17,7 +16,7 @@ class ShellWindow(ScrolledText):
             except KeyError:
                 shell = '/bin/sh'
             shell = shell + ' -i'
-        args = string.split(shell)
+        args = shell.split()
         shell = args[0]
 
         ScrolledText.__init__(self, master, **cnf)
@@ -33,7 +32,7 @@ class ShellWindow(ScrolledText):
                                   self.outputhandler)
 
     def outputhandler(self, file, mask):
-        data = os.read(file, BUFSIZE)
+        data = os.read(file, BUFSIZE).decode()
         if not data:
             self.tk.deletefilehandler(file)
             pid, sts = os.waitpid(self.pid, 0)
@@ -65,7 +64,7 @@ class ShellWindow(ScrolledText):
         self.insert(END, "\n")
         line = self.get(self.pos, "end - 1 char")
         self.pos = self.index(END)
-        os.write(self.tochild, line)
+        os.write(self.tochild, line.encode())
         return "break"
 
     def sendeof(self, *args):
@@ -132,7 +131,7 @@ def spawn(prog, args):
     return pid, c2pread, p2cwrite
 
 def test():
-    shell = string.join(sys.argv[1:])
+    shell = ' '.join(sys.argv[1: ])
     root = Tk()
     root.minsize(1, 1)
     if shell:
index b2a2a667f1b458fc22b90bd4196b4a9a240c0d26..43106e1f2577e8fe017f93006d42c9669acfe1df 100755 (executable)
@@ -22,20 +22,10 @@ know!
 
 # Imports
 
-import math
 import random
 
 from tkinter import *
-from Canvas import Rectangle, CanvasText, Group, Window
-
-
-# Fix a bug in Canvas.Group as distributed in Python 1.4.  The
-# distributed bind() method is broken.  Rather than asking you to fix
-# the source, we fix it here by deriving a subclass:
-
-class Group(Group):
-    def bind(self, sequence=None, command=None):
-        return self.canvas.tag_bind(self.id, sequence, command)
+from canvasevents import Group
 
 
 # Constants determining the size and lay-out of cards and stacks.  We
@@ -165,20 +155,22 @@ class Card:
         self.face_shown = 0
 
         self.x = self.y = 0
+        self.canvas = canvas
         self.group = Group(canvas)
 
         text = "%s  %s" % (VALNAMES[value], suit)
-        self.__text = CanvasText(canvas, CARDWIDTH//2, 0,
-                               anchor=N, fill=self.color, text=text)
+        self.__text = canvas.create_text(CARDWIDTH // 2, 0, anchor=N,
+                                         fill=self.color, text=text)
         self.group.addtag_withtag(self.__text)
 
-        self.__rect = Rectangle(canvas, 0, 0, CARDWIDTH, CARDHEIGHT,
-                              outline='black', fill='white')
+        self.__rect = canvas.create_rectangle(0, 0, CARDWIDTH, CARDHEIGHT,
+                                              outline='black', fill='white')
         self.group.addtag_withtag(self.__rect)
 
-        self.__back = Rectangle(canvas, MARGIN, MARGIN,
-                              CARDWIDTH-MARGIN, CARDHEIGHT-MARGIN,
-                              outline='black', fill='blue')
+        self.__back = canvas.create_rectangle(MARGIN, MARGIN,
+                                              CARDWIDTH - MARGIN,
+                                              CARDHEIGHT - MARGIN,
+                                              outline='black', fill='blue')
         self.group.addtag_withtag(self.__back)
 
     def __repr__(self):
@@ -202,15 +194,15 @@ class Card:
     def showface(self):
         """Turn the card's face up."""
         self.tkraise()
-        self.__rect.tkraise()
-        self.__text.tkraise()
+        self.canvas.tag_raise(self.__rect)
+        self.canvas.tag_raise(self.__text)
         self.face_shown = 1
 
     def showback(self):
         """Turn the card's face down."""
         self.tkraise()
-        self.__rect.tkraise()
-        self.__back.tkraise()
+        self.canvas.tag_raise(self.__rect)
+        self.canvas.tag_raise(self.__back)
         self.face_shown = 0
 
 
@@ -400,10 +392,9 @@ class Deck(Stack):
     """
 
     def makebottom(self):
-        bottom = Rectangle(self.game.canvas,
-                           self.x, self.y,
-                           self.x+CARDWIDTH, self.y+CARDHEIGHT,
-                           outline='black', fill=BACKGROUND)
+        bottom = self.game.canvas.create_rectangle(self.x, self.y,
+            self.x + CARDWIDTH, self.y + CARDHEIGHT, outline='black',
+            fill=BACKGROUND)
         self.group.addtag_withtag(bottom)
 
     def fill(self):
@@ -435,7 +426,7 @@ class Deck(Stack):
 
 def randperm(n):
     """Function returning a random permutation of range(n)."""
-    r = range(n)
+    r = list(range(n))
     x = []
     while r:
         i = random.choice(r)
@@ -478,10 +469,8 @@ class OpenStack(Stack):
 class SuitStack(OpenStack):
 
     def makebottom(self):
-        bottom = Rectangle(self.game.canvas,
-                           self.x, self.y,
-                           self.x+CARDWIDTH, self.y+CARDHEIGHT,
-                           outline='black', fill='')
+        bottom = self.game.canvas.create_rectangle(self.x, self.y,
+            self.x + CARDWIDTH, self.y + CARDHEIGHT, outline='black', fill='')
 
     def userclickhandler(self):
         pass
@@ -540,8 +529,8 @@ class Solitaire:
                                  background=BACKGROUND,
                                  activebackground="green",
                                  command=self.deal)
-        Window(self.canvas, MARGIN, 3*YSPACING + 20,
-               window=self.dealbutton, anchor=SW)
+        self.canvas.create_window(MARGIN, 3 * YSPACING + 20,
+            window=self.dealbutton, anchor=SW)
 
         x = MARGIN
         y = MARGIN
index 0c71fc94f73a4a6560f78ca1a210f637781452e2..326baecc91e3da6439307157d749624f51170f9d 100644 (file)
@@ -18,9 +18,7 @@ stand-alone application.
 
 """
 
-
 from tkinter import *
-from Canvas import Line, Rectangle
 import random
 
 
@@ -31,6 +29,9 @@ WIDTH = 6
 
 class Array:
 
+    class Cancelled(BaseException):
+        pass
+
     def __init__(self, master, data=None):
         self.master = master
         self.frame = Frame(self.master)
@@ -41,9 +42,9 @@ class Array:
         self.canvas.pack()
         self.report = Label(self.frame)
         self.report.pack()
-        self.left = Line(self.canvas, 0, 0, 0, 0)
-        self.right = Line(self.canvas, 0, 0, 0, 0)
-        self.pivot = Line(self.canvas, 0, 0, 0, 0)
+        self.left = self.canvas.create_line(0, 0, 0, 0)
+        self.right = self.canvas.create_line(0, 0, 0, 0)
+        self.pivot = self.canvas.create_line(0, 0, 0, 0)
         self.items = []
         self.size = self.maxvalue = 0
         if data:
@@ -82,8 +83,6 @@ class Array:
         if self.in_mainloop:
             self.master.quit()
 
-    Cancelled = "Array.Cancelled"       # Exception
-
     def wait(self, msecs):
         if self.speed == "fastest":
             msecs = 0
@@ -110,15 +109,15 @@ class Array:
         for i in range(self.size):
             item = self.items[i]
             if first <= i < last:
-                item.item.config(fill='red')
+                self.canvas.itemconfig(item, fill='red')
             else:
-                item.item.config(fill='orange')
+                self.canvas.itemconfig(item, fill='orange')
         self.hide_left_right_pivot()
 
     def hide_partition(self):
         for i in range(self.size):
             item = self.items[i]
-            item.item.config(fill='red')
+            self.canvas.itemconfig(item, fill='red')
         self.hide_left_right_pivot()
 
     def show_left(self, left):
@@ -127,7 +126,7 @@ class Array:
             return
         x1, y1, x2, y2 = self.items[left].position()
 ##      top, bot = HIRO
-        self.left.coords([(x1-2, 0), (x1-2, 9999)])
+        self.canvas.coords(self.left, (x1 - 2, 0, x1 - 2, 9999))
         self.master.update()
 
     def show_right(self, right):
@@ -135,7 +134,7 @@ class Array:
             self.hide_right()
             return
         x1, y1, x2, y2 = self.items[right].position()
-        self.right.coords(((x2+2, 0), (x2+2, 9999)))
+        self.canvas.coords(self.right, (x2 + 2, 0, x2 + 2, 9999))
         self.master.update()
 
     def hide_left_right_pivot(self):
@@ -144,17 +143,17 @@ class Array:
         self.hide_pivot()
 
     def hide_left(self):
-        self.left.coords(((0, 0), (0, 0)))
+        self.canvas.coords(self.left, (0, 0, 0, 0))
 
     def hide_right(self):
-        self.right.coords(((0, 0), (0, 0)))
+        self.canvas.coords(self.right, (0, 0, 0, 0))
 
     def show_pivot(self, pivot):
         x1, y1, x2, y2 = self.items[pivot].position()
-        self.pivot.coords(((0, y1-2), (9999, y1-2)))
+        self.canvas.coords(self.pivot, (0, y1 - 2, 9999, y1 - 2))
 
     def hide_pivot(self):
-        self.pivot.coords(((0, 0), (0, 0)))
+        self.canvas.coords(self.pivot, (0, 0, 0, 0))
 
     def swap(self, i, j):
         if i == j: return
@@ -199,28 +198,30 @@ class ArrayItem:
         self.array = array
         self.index = index
         self.value = value
+        self.canvas = array.canvas
         x1, y1, x2, y2 = self.position()
-        self.item = Rectangle(array.canvas, x1, y1, x2, y2,
-                              fill='red', outline='black', width=1)
-        self.item.bind('<Button-1>', self.mouse_down)
-        self.item.bind('<Button1-Motion>', self.mouse_move)
-        self.item.bind('<ButtonRelease-1>', self.mouse_up)
+        self.item_id = array.canvas.create_rectangle(x1, y1, x2, y2,
+            fill='red', outline='black', width=1)
+        self.canvas.tag_bind(self.item_id, '<Button-1>', self.mouse_down)
+        self.canvas.tag_bind(self.item_id, '<Button1-Motion>', self.mouse_move)
+        self.canvas.tag_bind(self.item_id, '<ButtonRelease-1>', self.mouse_up)
 
     def delete(self):
-        item = self.item
+        item_id = self.item_id
         self.array = None
-        self.item = None
-        item.delete()
+        self.item_id = None
+        self.canvas.delete(item_id)
 
     def mouse_down(self, event):
         self.lastx = event.x
         self.lasty = event.y
         self.origx = event.x
         self.origy = event.y
-        self.item.tkraise()
+        self.canvas.tag_raise(self.item_id)
 
     def mouse_move(self, event):
-        self.item.move(event.x - self.lastx, event.y - self.lasty)
+        self.canvas.move(self.item_id,
+                         event.x - self.lastx, event.y - self.lasty)
         self.lastx = event.x
         self.lasty = event.y
 
@@ -235,7 +236,7 @@ class ArrayItem:
         self.array.items[here], self.array.items[i] = other, self
         self.index = i
         x1, y1, x2, y2 = self.position()
-        self.item.coords(((x1, y1), (x2, y2)))
+        self.canvas.coords(self.item_id, (x1, y1, x2, y2))
         other.setindex(here)
 
     def setindex(self, index):
@@ -247,9 +248,9 @@ class ArrayItem:
         self.index = index
         newpts = self.position()
         trajectory = interpolate(oldpts, newpts, nsteps)
-        self.item.tkraise()
+        self.canvas.tag_raise(self.item_id)
         for pts in trajectory:
-            self.item.coords((pts[:2], pts[2:]))
+            self.canvas.coords(self.item_id, pts)
             self.array.wait(50)
 
     def swapwith(self, other):
@@ -262,61 +263,63 @@ class ArrayItem:
         self.index, other.index = other.index, self.index
         mynewpts = self.position()
         othernewpts = other.position()
-        myfill = self.item['fill']
-        otherfill = other.item['fill']
-        self.item.config(fill='green')
-        other.item.config(fill='yellow')
+        myfill = self.canvas.itemcget(self.item_id, 'fill')
+        otherfill = self.canvas.itemcget(other.item_id, 'fill')
+        self.canvas.itemconfig(self.item_id, fill='green')
+        self.canvas.itemconfig(other.item_id, fill='yellow')
         self.array.master.update()
         if self.array.speed == "single-step":
-            self.item.coords((mynewpts[:2], mynewpts[2:]))
-            other.item.coords((othernewpts[:2], othernewpts[2:]))
+            self.canvas.coords(self.item_id, mynewpts)
+            self.canvas.coords(other.item_id, othernewpts)
             self.array.master.update()
-            self.item.config(fill=myfill)
-            other.item.config(fill=otherfill)
+            self.canvas.itemconfig(self.item_id, fill=myfill)
+            self.canvas.itemconfig(other.item_id, fill=otherfill)
             self.array.wait(0)
             return
         mytrajectory = interpolate(myoldpts, mynewpts, nsteps)
         othertrajectory = interpolate(otheroldpts, othernewpts, nsteps)
         if self.value > other.value:
-            self.item.tkraise()
-            other.item.tkraise()
+            self.canvas.tag_raise(self.item_id)
+            self.canvas.tag_raise(other.item_id)
         else:
-            other.item.tkraise()
-            self.item.tkraise()
+            self.canvas.tag_raise(other.item_id)
+            self.canvas.tag_raise(self.item_id)
         try:
             for i in range(len(mytrajectory)):
                 mypts = mytrajectory[i]
                 otherpts = othertrajectory[i]
-                self.item.coords((mypts[:2], mypts[2:]))
-                other.item.coords((otherpts[:2], otherpts[2:]))
+                self.canvas.coords(self.item_id, mypts)
+                self.canvas.coords(other.item_id, otherpts)
                 self.array.wait(50)
         finally:
             mypts = mytrajectory[-1]
             otherpts = othertrajectory[-1]
-            self.item.coords((mypts[:2], mypts[2:]))
-            other.item.coords((otherpts[:2], otherpts[2:]))
-            self.item.config(fill=myfill)
-            other.item.config(fill=otherfill)
+            self.canvas.coords(self.item_id, mypts)
+            self.canvas.coords(other.item_id, otherpts)
+            self.canvas.itemconfig(self.item_id, fill=myfill)
+            self.canvas.itemconfig(other.item_id, fill=otherfill)
 
     def compareto(self, other):
-        myfill = self.item['fill']
-        otherfill = other.item['fill']
-        outcome = cmp(self.value, other.value)
-        if outcome < 0:
+        myfill = self.canvas.itemcget(self.item_id, 'fill')
+        otherfill = self.canvas.itemcget(other.item_id, 'fill')
+        if self.value < other.value:
             myflash = 'white'
             otherflash = 'black'
-        elif outcome > 0:
+            outcome = -1
+        elif self.value > other.value:
             myflash = 'black'
             otherflash = 'white'
+            outcome = 1
         else:
             myflash = otherflash = 'grey'
+            outcome = 0
         try:
-            self.item.config(fill=myflash)
-            other.item.config(fill=otherflash)
+            self.canvas.itemconfig(self.item_id, fill=myflash)
+            self.canvas.itemconfig(other.item_id, fill=otherflash)
             self.array.wait(500)
         finally:
-            self.item.config(fill=myfill)
-            other.item.config(fill=otherfill)
+            self.canvas.itemconfig(self.item_id, fill=myfill)
+            self.canvas.itemconfig(other.item_id, fill=otherfill)
         return outcome
 
     def position(self):
@@ -429,7 +432,7 @@ def quicksort(array):
                         j = j-1
                 continue
             array.message("Choosing pivot")
-            j, i, k = first, (first+last)//2, last-1
+            j, i, k = first, (first+last) // 2, last-1
             if array.compare(k, i) < 0:
                 array.swap(k, i)
             if array.compare(k, j) < 0:
@@ -519,7 +522,7 @@ class SortDemo:
 
         self.v_size = MyIntVar(self.master, self)
         self.v_size.set(size)
-        sizes = [1, 2, 3, 4] + range(5, 55, 5)
+        sizes = [1, 2, 3, 4] + list(range(5, 55, 5))
         if self.size not in sizes:
             sizes.append(self.size)
             sizes.sort()
index a6c8c2181edcecc358629acddea666361d9d31d1..8b074895e4995bc866b61c98fe195de95efe9a50 100644 (file)
@@ -3,7 +3,7 @@
 import os
 import re
 import sys
-import cgi
+import html
 from xml.parsers import expat
 
 LEFT, CENTER, RIGHT = "LEFT", "CENTER", "RIGHT"
@@ -201,7 +201,7 @@ class Sheet:
             if hasattr(cell, 'xml'):
                 cellxml = cell.xml()
             else:
-                cellxml = '<value>%s</value>' % cgi.escape(cell)
+                cellxml = '<value>%s</value>' % html.escape(cell)
             out.append('<cell row="%s" col="%s">\n  %s\n</cell>' %
                        (y, x, cellxml))
         out.append('</spreadsheet>')
@@ -216,7 +216,7 @@ class Sheet:
         f.close()
 
     def load(self, filename):
-        f = open(filename, 'r')
+        f = open(filename, 'rb')
         SheetParser(self).parsefile(f)
         f.close()
 
@@ -382,7 +382,7 @@ class StringCell(BaseCell):
         return s % (
             align2xml[self.alignment],
             self.fmt,
-            cgi.escape(self.text))
+            html.escape(self.text))
 
 class FormulaCell(BaseCell):
 
index 0dd9f954eb5bd8ee5514cb6d56cbcadab4a140f1..e63a32b5545350ef483b0cee30fec4dd9d80d9c9 100755 (executable)
@@ -7,8 +7,6 @@ from tkinter import *
 if TkVersion < 4.0:
     raise ImportError("This version of svkill requires Tk 4.0 or later")
 
-from string import splitfields
-from string import split
 import subprocess
 import os
 
@@ -40,14 +38,14 @@ class Kill(Frame):
             ]
     def kill(self, selected):
         c = self.format_list[self.format.get()][2]
-        pid = split(selected)[c]
+        pid = selected.split()[c]
         os.system('kill -9 ' + pid)
         self.do_update()
     def do_update(self):
         format = self.format_list[self.format.get()][1]
         view = self.view_list[self.view.get()][1]
         s = subprocess.getoutput('ps %s %s' % (view, format))
-        list = splitfields(s, '\n')
+        list = s.split('\n')
         self.header.set(list[0] + '          ')
         del list[0]
         self.frame.list.delete(0, AtEnd())
@@ -97,14 +95,12 @@ class Kill(Frame):
         self.header = StringVar(self)
         self.frame.label = Label(
                 self.frame, relief=FLAT, anchor=NW, borderwidth=0,
-                font='*-Courier-Bold-R-Normal-*-120-*',
                 textvariable=self.header)
         self.frame.label.pack(fill=Y, anchor=W)
         self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL)
         self.frame.list = Listbox(
                 self.frame,
                 relief=SUNKEN,
-                font='*-Courier-Medium-R-Normal-*-120-*',
                 width=40, height=10,
                 selectbackground='#eed5b7',
                 selectborderwidth=0,
index 52b6d03904dfe63f8ebe33fbc8c50f7b2cf040c5..1baed88c4814ce16ba8494b45511bdab7e6ff87d 100755 (executable)
@@ -2,15 +2,15 @@
 
 # Tk man page browser -- currently only shows the Tcl/Tk man pages
 
-import sys
 import os
-import string
 import re
+import sys
 from tkinter import *
-from ManPage import ManPage
 
-MANNDIRLIST = ['/depot/sundry/man/mann','/usr/local/man/mann']
-MAN3DIRLIST = ['/depot/sundry/man/man3','/usr/local/man/man3']
+from manpage import ManPage
+
+MANNDIRLIST = ['/usr/local/man/mann', '/usr/share/man/mann']
+MAN3DIRLIST = ['/usr/local/man/man3', '/usr/share/man/man3']
 
 foundmanndir = 0
 for dir in MANNDIRLIST:
@@ -197,7 +197,7 @@ class SelectionBox:
 
     def show_page(self, name):
         file = '%s/%s.?' % (self.chaptervar.get(), name)
-        fp = os.popen('nroff -man %s | ul -i' % file, 'r')
+        fp = os.popen('nroff -man -c %s | ul -i' % file, 'r')
         self.text.kill()
         self.title['text'] = name
         self.text.parsefile(fp)
@@ -221,9 +221,9 @@ class SelectionBox:
             print('Regex error:', msg)
             return
         here = self.text.index(AtInsert())
-        lineno = string.atoi(here[:string.find(here, '.')])
+        lineno = int(here[:here.find('.')])
         end = self.text.index(AtEnd())
-        endlineno = string.atoi(end[:string.find(end, '.')])
+        endlineno = int(end[:end.find('.')])
         wraplineno = lineno
         found = 0
         while 1:
@@ -237,9 +237,9 @@ class SelectionBox:
             line = self.text.get('%d.0 linestart' % lineno,
                                  '%d.0 lineend' % lineno)
             i = prog.search(line)
-            if i >= 0:
+            if i:
                 found = 1
-                n = max(1, len(prog.group(0)))
+                n = max(1, len(i.group(0)))
                 try:
                     self.text.tag_remove('sel',
                                          AtSelFirst(),
@@ -247,10 +247,10 @@ class SelectionBox:
                 except TclError:
                     pass
                 self.text.tag_add('sel',
-                                  '%d.%d' % (lineno, i),
-                                  '%d.%d' % (lineno, i+n))
+                                  '%d.%d' % (lineno, i.start()),
+                                  '%d.%d' % (lineno, i.start()+n))
                 self.text.mark_set(AtInsert(),
-                                   '%d.%d' % (lineno, i))
+                                   '%d.%d' % (lineno, i.start()))
                 self.text.yview_pickplace(AtInsert())
                 break
         if not found:
index bebab1e5e38ee06e7369e30328839d184a47c90b..332501d82c007e25f2cda5e4afb60b2846971e97 100755 (executable)
@@ -4,21 +4,25 @@ import _tkinter
 import os
 import sys
 
-tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1)
+tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1, 1)
 tk.call('update')
 
 cmd = ''
 
-while 1:
-    if cmd: prompt = ''
-    else: prompt = '% '
+while True:
+    if cmd:
+        prompt = ''
+    else:
+        prompt = '% '
     try:
         sys.stdout.write(prompt)
         sys.stdout.flush()
         line = sys.stdin.readline()
+        if not line:
+            break
     except EOFError:
         break
-    cmd = cmd + (line + '\n')
+    cmd += line
     if tk.getboolean(tk.call('info', 'complete', cmd)):
         tk.record(line)
         try:
index af0ec81df98744376ce6b708976350a547e426b6..0da7c3786e9c92801f68f1da2fe3dcfd519515af 100644 (file)
@@ -1,5 +1,4 @@
 from tkinter import *
-import string
 
 # This program  shows how to use a simple type-in box
 
index 473a596dabd819970fe91ac07cdb9cf193de59df..7d93da764e03c08742cb1be13a0f53e4acc1f32d 100644 (file)
@@ -1,5 +1,4 @@
 from tkinter import *
-import string
 
 # This program  shows how to make a typein box shadow a program variable.
 
@@ -35,7 +34,7 @@ class App(Frame):
         # because it's being looked at by the entry widget, changing
         # the variable changes the entry widget display automatically.
         # the strange get/set operators are clunky, true...
-        str = string.upper(self.contents.get())
+        str = self.contents.get().upper()
         self.contents.set(str)
 
     def print_contents(self, event):
index 09f9f2e2eec56b9e47776b6033b3c8239ed25233..82a5dc07403c41519ec3ac8bfb4052b7004cd014 100644 (file)
@@ -1,7 +1,5 @@
 from tkinter import *
 
-import string
-
 
 class Pong(Frame):
     def createWidgets(self):
index 26a4649f731e982e618571aaf6dbd810d0a3c2e0..771a60d0fd947a6fbf0cd65e13322ced82ad698a 100644 (file)
@@ -35,7 +35,7 @@ class Test(Frame):
         # the "current" tag is applied to the object the cursor is over.
         # this happens automatically.
         self.draw.itemconfig(CURRENT, fill="red")
-        print(self.draw.coords(CURRENT))
+        print(list(self.draw.coords(CURRENT)))
 
     def mouseLeave(self, event):
         # the "current" tag is applied to the object the cursor is over.
index 601c94971ef6e26ec80e5c70011684654937768c..9581186a938999ebc08b3593e24038d5ba2f8b80 100644 (file)
@@ -529,7 +529,7 @@ catalogs, and the C library's search algorithms for locating message catalogs.
 
 Python applications should normally find no need to invoke these functions, and
 should use :mod:`gettext` instead.  A known exception to this rule are
-applications that link use additional C libraries which internally invoke
+applications that link with additional C libraries which internally invoke
 :cfunc:`gettext` or :func:`dcgettext`.  For these applications, it may be
 necessary to bind the text domain, so that the libraries can properly locate
 their message catalogs.
index c4ee87ede10ba3a0b06393894852cbfff35cef64..f726a0227d884b4f49db35e24710193aba8096b5 100644 (file)
@@ -792,9 +792,9 @@ For example:
     >>> a.send([1, 'hello', None])
     >>> b.recv()
     [1, 'hello', None]
-    >>> b.send_bytes('thank you')
+    >>> b.send_bytes(b'thank you')
     >>> a.recv_bytes()
-    'thank you'
+    b'thank you'
     >>> import array
     >>> arr1 = array.array('i', range(5))
     >>> arr2 = array.array('i', [0] * 10)
index 448bcb7271ba0d243dc63a74eddf175290ba4a23..49c241d1d93bb78f16fe7b0666d687e7959cfae9 100644 (file)
@@ -229,7 +229,7 @@ The special characters are:
    undefined.
 
 ``(?:...)``
-   A non-grouping version of regular parentheses. Matches whatever regular
+   A non-capturing version of regular parentheses.  Matches whatever regular
    expression is inside the parentheses, but the substring matched by the group
    *cannot* be retrieved after performing a match or referenced later in the
    pattern.
index 409f4611719d1e5222169b810290a01aa4dc4fc8..a5d11deb24bb235445ba2467efb609ad591073b6 100644 (file)
@@ -114,7 +114,7 @@ implementation as the built-in :meth:`format` method.
 
       Loop over the format_string and return an iterable of tuples
       (*literal_text*, *field_name*, *format_spec*, *conversion*).  This is used
-      by :meth:`vformat` to break the string in to either literal text, or
+      by :meth:`vformat` to break the string into either literal text, or
       replacement fields.
 
       The values in the tuple conceptually represent a span of literal text
index 36d47ad12a761eebdb44b3b165353f7d1a52d5d7..e62be551bb57560a097a7ca0ca25618214e9cffa 100644 (file)
@@ -159,6 +159,20 @@ ImportWarning can also be enabled explicitly in Python code using::
    warnings.simplefilter('default', ImportWarning)
 
 
+Default Warning Filters
+~~~~~~~~~~~~~~~~~~~~~~~
+
+By default, Python installs several warning filters, which can be overridden by
+the command-line options passed to :option:`-W` and calls to
+:func:`filterwarnings`.
+
+* :exc:`PendingDeprecationWarning`, and :exc:`ImportWarning` are ignored.
+
+* :exc:`BytesWarning` is ignored unless the :option:`-b` option is given once or
+  twice; in this case this warning is either printed (``-b``) or turned into an
+  exception (``-bb``).
+
+
 .. _warning-suppress:
 
 Temporarily Suppressing Warnings
index dffd32c3530b25156b58b2751c0b1b00e6a0628f..4d4db948268ae9bc004cbf4a98731a81a7b783b3 100644 (file)
@@ -207,14 +207,14 @@ library/nntplib,272,:bytes,:bytes
 library/nntplib,272,:lines,:lines
 library/nntplib,272,:lines,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']"
 library/nntplib,272,:bytes,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']"
-library/pickle,567,:memory,"conn = sqlite3.connect("":memory:"")"
-library/profile,293,:lineno,"(sort by filename:lineno),"
-library/socket,261,::,"(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]"
+library/pickle,,:memory,"conn = sqlite3.connect("":memory:"")"
+library/profile,,:lineno,"(sort by filename:lineno),"
+library/socket,,::,"(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]"
 library/stdtypes,1026,:end,s[start:end]
 library/stdtypes,1195,:end,s[start:end]
-library/urllib.request,64,:close,Connection:close
-library/urllib.request,901,:password,"""joe:password@python.org"""
-library/urllib.request,1064,:lang,"xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""en"" lang=""en"">\n\n<head>\n"
+library/urllib.request,,:close,Connection:close
+library/urllib.request,,:password,"""joe:password@python.org"""
+library/urllib.request,,:lang,"xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""en"" lang=""en"">\n\n<head>\n"
 library/xmlrpc.client,103,:pass,http://user:pass@host:port/path
 library/xmlrpc.client,103,:port,http://user:pass@host:port/path
 library/xmlrpc.client,103,:pass,user:pass
index 987a4259b39a2d0868f359afe6b7c69988a09eb6..38ad140d9edc3559c9fcc2b950dc915c036ea5a5 100644 (file)
@@ -635,7 +635,7 @@ else:
                     sys.stdout.write("\nSSLError is %s\n" % x.args[1])
             except socket.error as x:
                 if support.verbose:
-                    sys.stdout.write("\nsocket.error is %s\n" % x[1])
+                    sys.stdout.write("\nsocket.error is %s\n" % x.args[1])
             else:
                 self.fail("Use of invalid cert should have failed!")
         finally:
index 7ae68cadf3a585eca4c1c0f501b16f2165057c8d..0c34613bb0f2f7dae59ddf5a6d3c794141e73896 100644 (file)
@@ -23,6 +23,9 @@ transliteration too.
 Permissions History
 -------------------
 
+- David Malcolm was given commit access on Oct 27 2010 by GFB,
+  at recommendation by Antoine Pitrou and Raymond Hettinger.
+
 - Tal Einat was given commit access on Oct 4 2010 by MvL,
   for improving IDLE.
 
index c153cbf8f2ac46308c29e748b18accada39c5ef0..6c1742f97dd9917ef7e8bf94c38639594bd8d210 100644 (file)
@@ -15,7 +15,7 @@ extern "C" {
 enum decoding_state {
     STATE_INIT,
     STATE_RAW,
-    STATE_NORMAL, /* have a codec associated with input */
+    STATE_NORMAL        /* have a codec associated with input */
 };
 
 /* Tokenizer state */
index 9507847ffdaa121b33803a5614adf0568a64e2c5..3286047a5fc8b087f963f543f2c1db5aab04b63c 100644 (file)
@@ -31,7 +31,7 @@ class Chooser:
         if dbfile != self.__databasefile:
             colordb = ColorDB.get_colordb(dbfile)
         if not self.__master:
-            from Tkinter import Tk
+            from tkinter import Tk
             self.__master = Tk()
         if not self.__pw:
             self.__pw, self.__sb = \
@@ -92,7 +92,7 @@ def save():
 \f
 # test stuff
 if __name__ == '__main__':
-    from Tkinter import *
+    from tkinter import *
 
     class Tester:
         def __init__(self):
index b63428abd4a9423144b2d80cb49afbda9cdfc788..ab851efdf852be8697493310b7c7bdac077b467b 100644 (file)
@@ -6,11 +6,14 @@
 #
 # By Bill Janssen.
 
+import re
+import os
+import ssl
 import sys
+import tempfile
 
-def fetch_server_certificate (host, port):
 
-    import re, tempfile, os, ssl
+def fetch_server_certificate (host, port):
 
     def subproc(cmd):
         from subprocess import Popen, PIPE, STDOUT
@@ -20,15 +23,15 @@ def fetch_server_certificate (host, port):
         return status, output
 
     def strip_to_x509_cert(certfile_contents, outfile=None):
-        m = re.search(r"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n"
-                      r".*[\r]*^[-]+END CERTIFICATE[-]+)$",
+        m = re.search(br"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n"
+                      br".*[\r]*^[-]+END CERTIFICATE[-]+)$",
                       certfile_contents, re.MULTILINE | re.DOTALL)
         if not m:
             return None
         else:
             tn = tempfile.mktemp()
-            fp = open(tn, "w")
-            fp.write(m.group(1) + "\n")
+            fp = open(tn, "wb")
+            fp.write(m.group(1) + b"\n")
             fp.close()
             try:
                 tn2 = (outfile or tempfile.mktemp())
@@ -67,6 +70,7 @@ def fetch_server_certificate (host, port):
                          (host, port))
     return certtext
 
+
 if __name__ == "__main__":
     if len(sys.argv) < 2:
         sys.stderr.write(
@@ -75,5 +79,5 @@ if __name__ == "__main__":
         sys.exit(1)
     for arg in sys.argv[1:]:
         host, port = arg.split(":")
-        sys.stdout.write(fetch_server_certificate(host, int(port)))
+        sys.stdout.buffer.write(fetch_server_certificate(host, int(port)))
     sys.exit(0)