Armin Rigo avatar Armin Rigo committed 4ac21ef

Finish the merge of trunk into pyjitpl5.

Comments (0)

Files changed (492)

 
     Armin Rigo
     Samuele Pedroni
+    Carl Friedrich Bolz
+    Maciek Fijalkowski
     Michael Hudson
-    Carl Friedrich Bolz
+    Antonio Cuni
     Christian Tismer
     Holger Krekel
     Eric van Riet Paap
-    Antonio Cuni
+    Richard Emslie
     Anders Chrigstrom
-    Maciek Fijalkowski
-    Richard Emslie
     Aurelien Campeas
+    Amaury Forgeot d Arc
     Anders Lehmann
     Niklaus Haldimann
     Seo Sanghyeon
+    Leonardo Santagada
     Lawrence Oluyede
+    Jakub Gustak
+    Guido Wesdorp
+    Niko Matsakis
+    Toon Verwaest
+    Alexander Schremmer
+    Ludovic Aubry
     Alex Martelli
-    Ludovic Aubry
+    Stephan Diehl
     Adrien Di Mascio
-    Stephan Diehl
-    Guido Wesdorp
     Stefan Schwarzer
     Tomek Meka
     Patrick Maupin
-    Leonardo Santagada
+    Jacob Hallen
+    Laura Creighton
+    Camillo Bruni
     Bob Ippolito
-    Laura Creighton
-    Jacob Hallen
+    Simon Burton
+    Bruno Gola
+    Alexandre Fayolle
     Marius Gedminas
-    Niko Matsakis
-    Amaury Forgeot d Arc
     Guido van Rossum
     Valentino Volonghi
-    Alexander Schremmer
-    Alexandre Fayolle
+    Adrian Kuhn
+    Anders Hammarquist
+    Paul deGrandis
+    Gerald Klix
     Wanja Saatkamp
-    Gerald Klix
+    Oscar Nierstrasz
     Eugene Oden
+    Lukas Renggli
+    Bartosz SKOWRON
+    Guenter Jantzen
     Dinu Gherman
-    Guenter Jantzen
+    Georg Brandl
     Ben Young
     Nicolas Chauvat
+    Jean-Paul Calderone
+    Rocco Moretti
     Michael Twomey
-    Rocco Moretti
-    Simon Burton
     Boris Feigin
+    Jared Grubb
     Olivier Dormond
-    Gintautas Miliauskas
     Stuart Williams
     Jens-Uwe Mager
+    Justas Sadzevicius
     Brian Dorsey
     Jonathan David Riehl
+    Beatrice During
+    Elmo Mäntynen
+    Andreas Friedge
     Anders Qvist
-    Beatrice During
-    Andreas Friedge
     Alan McIntyre
     Bert Freudenberg
 
     Heinrich-Heine University, Germany 
-    Open End AB (formerly AB Strakt), Sweden  
+    Open End AB (formerly AB Strakt), Sweden
     merlinux GmbH, Germany 
     tismerysoft GmbH, Germany 
     Logilab Paris, France 
 The file 'pypy/translator/jvm/src/jna.jar' is licensed under the GNU
 Lesser General Public License of which you can find a copy here:
 http://www.gnu.org/licenses/lgpl.html
+
+License for 'pypy/translator/jvm/src/jasmin.jar'
+=============================================
+
+The file 'pypy/translator/jvm/src/jasmin.jar' is copyright (c) 1996-2004 Jon Meyer
+and distributed with permission.  The use of Jasmin by PyPy does not imply
+that PyPy is endorsed by Jon Meyer nor any of Jasmin's contributors.  Furthermore,
+the following disclaimer applies to Jasmin:
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 PyPy.  It will also point you to our documentation section which is
 generated from information in the pypy/doc directory.
 
-For information in what's new in this release and about PyPy current
-status, please read the release announcement:
-
-    pypy/doc/release-1.0.0.txt or
-    pypy/doc/release-1.0.0.html
-    http://codespeak.net/pypy/dist/pypy/doc/release-1.0.0.html
-
 Enjoy and send us feedback!
 
     the pypy-dev team <pypy-dev@codespeak.net>
 
-For the period December 2004 - March 2007, the development of PyPy has
-been co-funded by the European Union's research programme.  For more
-information on this aspect of the project please visit
-http://pypy.org/.
-
 $Id$
 $HeadURL$

ctypes_configure/configure.py

         return try_compile([self.path], eci)
 
         
-def configure(CConfig):
+def configure(CConfig, noerr=False):
     """Examine the local system by running the C compiler.
     The CConfig class contains CConfigEntry attribues that describe
     what should be inspected; configure() returns a dict mapping
         writer.close()
 
         eci = CConfig._compilation_info_
-        infolist = list(run_example_code(writer.path, eci))
+        infolist = list(run_example_code(writer.path, eci, noerr=noerr))
         assert len(infolist) == len(entries)
 
         resultinfo = {}
 }
 """
 
-def run_example_code(filepath, eci):
-    executable = build_executable([filepath], eci)
+def run_example_code(filepath, eci, noerr=False):
+    executable = build_executable([filepath], eci, noerr=noerr)
     output = py.process.cmdexec(executable)
     section = None
     for line in output.splitlines():
     Insert '--help' before 'bpnn.py' for a list of translation options,
     or see the Overview of Command Line Options for translation at
     http://codespeak.net/pypy/dist/pypy/doc/config/commandline.html
-
-    Use '--text' before 'bpnn.py' if you don't have Pygame installed.
 """
 # Back-Propagation Neural Networks
 # 
 import autopath
 from pypy.rlib import rrandom
 
-PRINT_IT = False
+PRINT_IT = True
 
 random = rrandom.Random(1)
 
     return entry_point, None
 
 if __name__ == '__main__':
-    #demo()
+    demo()
     print __doc__

demo/contract_stack.py

-
-class Stack:
-    """A very simple stack interface
-    (not very useful in Python)
-    """
-
-    def __init__(self, max_size = 10):
-        self.max_size = max_size
-        self.elements = []
-
-    def _pre_pop(self):
-        return not self.is_empty()
-    def _post_pop(self, old, ret):
-        return ret == old.top() and \
-               self.size() == old.size() - 1
-    def pop(self):
-        return self.elements.pop()
-
-
-    def _pre_push(self, obj):
-        return obj is not None and not self.is_full()
-    def _post_push(self, old, ret, obj):
-        return not self.is_empty() and (self.top() == obj)
-    def push(self, obj):
-        self.elements.append(obj)
-
-
-    def top(self):
-        """Returns the top element of the stack
-        """
-        return self.elements[-1]
-    
-    def is_empty(self):
-        """Tells whether or not the stack is empty
-        """
-        return not bool(self.elements)
-
-
-    def is_full(self):
-        """Tells whether or not the stack is full
-        """
-        return len(self.elements) == self.max_size
-    
-    def size(self):
-        """Returns the current size of the stack
-        """
-        return len(self.elements)
-
-    def __str__(self):
-        return "elements = %s, max_size = %s" % (self.elements, self.max_size)

demo/contracts.py

-from dbc import ContractAspect, ContractError
-ContractAspect()
-from  contract_stack import Stack
-
-def run():
-    """This is an example of how contracts work
-    """
-    print "*"*30
-    print "Creating an empty stack (max_size = 3)"
-    stack = Stack(3)
-
-    try:
-        print "Empty stack, pop() should fail"
-        stack.pop()
-    except ContractError, excpt:
-        print "\t failed with %s, (OK)" % excpt
-    else:
-        print "\t did not failed, (XXX)"
-
-    print "\n\n\n"
-    stack.push(1)
-    print "push 1 done"
-    stack.push(2)
-    print "push 2 done"
-    stack.push(3)
-    print "push 3 done"
-        
-    try:
-        print "The stack is full, push() should fail"
-        stack.push(4)
-    except ContractError, excpt:
-        print "\t failed with %s, (OK)" % excpt
-    else:
-        print "\t did not failed, (XXX)"
-
-    print "\n\n\n"
-
-
-
-if __name__ == '__main__':
-    run()

demo/http-and-html.py

-"""
-    Standard Library usage demo.
-    Uses urllib and htmllib to download and parse a web page.
-
-    The purpose of this demo is to remind and show that almost all
-    pure-Python modules of the Standard Library work just fine.
-"""
-
-url = 'http://www.python.org/'
-html = 'python.html'
-import urllib
-content = urllib.urlopen(url).read()
-file(html, 'w').write(content)
-import htmllib
-htmllib.test([html])
-import os
-os.remove(html)

demo/jit/f1.py

-import time
-
-
-ZERO = 0
-
-def f1(n):
-    "Arbitrary test function."
-    i = 0
-    x = 1
-    while i<n:
-        j = 0   #ZERO
-        while j<=i:
-            j = j + 1
-            x = x + (i&j)
-        i = i + 1
-    return x
-
-
-try:
-    import pypyjit
-except ImportError:
-    print "No jit"
-else:
-    pypyjit.enable(f1.func_code)
-
-res = f1(2117)
-print res
-N = 5
-start = time.time()
-for i in range(N):
-    assert f1(2117) == res
-end = time.time()
-
-print '%d iterations, time per iteration: %s' % (N, (end-start)/N)

demo/jit/factorial.py

-import time
-
-
-def f(n):
-    r = 1
-    while n > 1:
-        r *= n
-        n -= 1
-    return r
-
-import pypyjit
-pypyjit.enable(f.func_code)
-
-print f(7)

demo/jit/factorialrec.py

-import time
-
-
-def f(n):
-    if n > 1:
-        return n * f(n-1)
-    else:
-        return 1
-
-import pypyjit
-pypyjit.enable(f.func_code)
-
-print f(7)

demo/producerconsumer.py

-"""This is an example that uses the (prototype) Logic Object Space. To run,
-you have to set USE_GREENLETS in pypy.objspace.logic to True and do:
-  
-    $ py.py -o logic producerconsumer.py
-
-newvar creates a new unbound logical variable. If you try to access an unbound
-variable, the current uthread is blocked, until the variable is bound.
-"""
-
-def generate(n, limit):
-    print "generate", n, limit
-    if n < limit:
-        return (n, generate(n + 1, limit))
-    return None
-
-def sum(L, a):
-    print "sum", a
-    Head, Tail = newvar(), newvar()
-    unify(L, (Head, Tail))
-    if Tail != None:
-        return sum(Tail, Head + a)
-    return a + Head
-
-print "eager producer consummer"
-print "before"
-X = newvar()
-S = newvar()
-bind(S, uthread(sum, X, 0))
-unify(X, uthread(generate, 0, 10))
-print "after"
-
-assert S == 45
-print S # needs a special treatment

demo/sharedref.py

             chan = server(port)
         channels.append(chan)
 
-    mainloop(channels)
+    try:
+        mainloop(channels)
+    finally:
+        for channel in channels:
+                channel.s.close()

demo/sqlinj/populate.py

-# Populate the database for the SQL injection demo,
-# it creates a DBS directory in the current working dir.
-# Requires Gadfly on the python path, and a --allworkingmodules --oldstyle
-# pypy-c.
-# Passwords for the demo are just the reverse of user names.
-
-import md5
-import sys, os
-import random
-
-os.mkdir("DBS")
-
-import gadfly
-
-conn = gadfly.gadfly()
-conn.startup("db0", "DBS")
-
-names = ['bob', 'jamie', 'david', 'monica', 'rose', 'anna']
-
-def make_pwd(name):
-    rname = list(name)
-    rname.reverse()
-    rname = ''.join(rname)
-    return md5.new(rname).hexdigest()
-
-pwds = [make_pwd(name) for name in names]
-
-products = [('superglue', 10.0, 5),
-            ('pink wallpaper', 25.0, 20),
-            ('red wallpaper', 20.0, 20),
-            ('gray wallpaper', 15.0, 20),
-            ('white wallpaper', 15.0, 20),
-            ('green wallpaper', 20.0, 20) ]
-
-cursor = conn.cursor()
-cursor.execute("""create table purchases (pwd varchar, user varchar,
-                                          month integer, year integer,
-                                          product varchar,
-                                          qty integer,
-                                          amount float)
-               """)
-
-
-
-ins = "insert into purchases values (?,?,?,2007,?,?,?)"
-for i in range(15):
-    uid = random.randrange(0, len(names))
-    pwd = pwds[uid]
-    name = names[uid]
-    month = random.randrange(1, 13)
-    product, unitprice, maxqty = random.choice(products)
-    qty = random.randrange(1, maxqty)
-    data = (pwd, name, month, product, qty, qty*unitprice)
-    cursor.execute(ins, data)
-
-conn.commit()
-
-print "Done"

demo/sqlinj/server.py

-"""SQL injection example
-
-   Needs gadfly (sf.net/projects/gadfly) to be on the python path.
-
-   Use populate.py to create the example db.
-
-   Passwords are the reverse of user names :).
-
-   Query is the number of a calendar month, purchases
-   for the user with the password since including that month
-   are shown.
-
-   Works with an --allworkingmodules --oldstyle pypy-c .
-"""
-
-import sys
-
-import gadfly
-
-import BaseHTTPServer
-import cgi
-import md5
-
-page="""
-<html>
-<head>
-<title>DEMO</title>
-</head>
-<body>
-<form method="get" action="/">
-<label for="pwd">Passwd</label>
-<input name="pwd" type="text" size="10"></input><br />
-<label for="query">Query</label>
-<input name="query" type="text" size="20"></input><br />
-<input type="submit">
-</form>
-
-<div>
-%s
-</div>
-</body>
-</html>
-"""
-
-table = """
-<table>
-<th>customer</th>
-<th>month</th>
-<th>year</th>
-<th>prod.</th>
-<th>qty</th>
-<th>amount</th>
-%s
-</table>
-"""
-
-row = "<tr>"+"<td>%s</td>"*6 +"</tr>"
-
-def do_query(query):
-    conn = gadfly.gadfly("db0", "DBS")
-    cursor = conn.cursor()
-    pwd = md5.new(query['pwd'][0]).hexdigest()
-    q = query['query'][0]
-
-    sel = ("""select user,month,year,product,qty,amount from purchases
-                      where pwd='%s' and month>=%s
-                   """ % (pwd, q))
-    cursor.execute(sel)
-    rows = []
-    for x in cursor.fetchall():
-        rows.append(row % x)
-    results = table % ('\n'.join(rows))
-    
-    conn.close()
-    return results
-    
-    
-
-class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
-    
-    def do_GET(self):
-        self.send_response(200, "OK")
-        self.end_headers()
-        parts = self.path.split('?')
-        if len(parts) > 1:
-            _, query = parts
-            query = cgi.parse_qs(query, strict_parsing=True)
-        else:
-            query = None
-
-        if query is not None:
-            results = do_query(query)
-        else:
-            results = "no query"
-
-        self.wfile.write(page % results)
-
-
-
-if __name__ == '__main__':
-    if len(sys.argv) > 1:
-        port = int(sys.argv[1])
-    else:
-        port = 8000
-    
-    server_address = ('', port)
-    httpd = BaseHTTPServer.HTTPServer(server_address, RequestHandler)
-    httpd.serve_forever()

demo/sqlinj/tserver.py

-"""SQL injection example with holes fixed using the taint space.
-
-   Needs gadfly (sf.net/projects/gadfly) to be on the python path.
-
-   Use populate.py to create the example db.
-
-   Passwords are the reverse of user names :).
-
-   Query is the number of a calendar month, purchases
-   for the user with the password since including that month
-   are shown.
-
-   Works with a -otaint --allworkingmodules --oldstyle pypy-c .
-"""
-
-import sys
-import __pypy__
-
-import gadfly
-
-import BaseHTTPServer
-import cgi
-import md5
-
-page="""
-<html>
-<head>
-<title>DEMO</title>
-</head>
-<body>
-<form method="get" action="/">
-<label for="pwd">Passwd</label>
-<input name="pwd" type="text" size="10"></input><br />
-<label for="query">Query</label>
-<input name="query" type="text" size="20"></input><br />
-<input type="submit">
-</form>
-
-<div>
-%s
-</div>
-</body>
-</html>
-"""
-
-table = """
-<table>
-<th>customer</th>
-<th>month</th>
-<th>year</th>
-<th>prod.</th>
-<th>qty</th>
-<th>amount</th>
-%s
-</table>
-"""
-
-row = "<tr>"+"<td>%s</td>"*6 +"</tr>"
-
-def do_query(query):
-    conn = gadfly.gadfly("db0", "DBS")
-    cursor = conn.cursor()
-
-    pwd = pypymagic.untaint(str, query['pwd'][0])
-    pwd = md5.new(pwd).hexdigest()
-
-    q = pypymagic.untaint(str, query['query'][0])
-    if not q.isdigit():
-        return "Wrong query!"
-    
-    sel = ("""select user,month,year,product,qty,amount from purchases
-                      where pwd='%s' and month>=%s
-                   """ % (pwd, q))
-    cursor.execute(sel)
-    rows = []
-    for x in cursor.fetchall():
-        rows.append(row % x)
-    results = table % ('\n'.join(rows))
-    
-    conn.close()
-    return results
-    
-    
-
-class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
-    
-    def do_GET(self):
-        self.send_response(200, "OK")
-        self.end_headers()
-        parts = self.path.split('?')
-        if len(parts) > 1:
-            _, query = parts
-            query = cgi.parse_qs(query, strict_parsing=True)
-        else:
-            query = None
-
-        if query is not None:
-            query = pypymagic.taint(query)
-            results = do_query(query)
-        else:
-            results = "no query"
-
-        self.wfile.write(page % results)
-
-
-
-if __name__ == '__main__':
-    if len(sys.argv) > 1:
-        port = int(sys.argv[1])
-    else:
-        port = 8000
-    
-    server_address = ('', port)
-    httpd = BaseHTTPServer.HTTPServer(server_address, RequestHandler)
-    httpd.serve_forever()

demo/tproxy/persistance.py

-"""
-
-This small example implements a basic orthogonal persistence 
-mechanism on top of PyPy's transparent proxies. 
-
-"""
-from tputil import make_proxy
-
-list_changeops = set('__iadd__ __imul__ __delitem__ __setitem__ __setattr__'
-                     '__delslice__ __setslice__ '
-                     'append extend insert pop remove reverse sort'.split())
-
-dict_changeops = set('__delitem__ __setitem__  __setattr__'
-                     'clear pop popitem setdefault update'.split())
-
-def ischangeop(operation): 
-    """ return True if this operation is a changing operation 
-        on known builtins (dicts, lists). 
-    """ 
-    if isinstance(operation.obj, list):
-        changeops = list_changeops 
-    elif isinstance(operation.obj, dict):
-        changeops = dict_changeops 
-    else:
-        return False
-    return operation.opname in changeops 
-
-def make_persistent_proxy(instance, storage): 
-    def perform(operation): 
-        res = operation.delegate()
-        if ischangeop(operation):
-            print "persisting after:", operation 
-            storage.dump(instance)
-        if res is not operation.proxyobj and isinstance(res, (dict, list)):
-            res = make_proxy(perform, obj=res)
-        return res
-    return make_proxy(perform, obj=instance) 
-
-def load(storage):
-    obj = storage.load()
-    return make_persistent_proxy(obj, storage) 
-    
-if __name__ == '__main__': 
-    import py 
-    storage = py.path.local("/tmp/dictpickle")
-    pdict = make_persistent_proxy({}, storage) 
-
-    # the code below is not aware of pdict being a proxy 
-    assert type(pdict) is dict
-    pdict['hello'] = 'world'       
-    pdict['somelist'] = []
-    del pdict 
-
-    newdict = load(storage) 
-    assert newdict == {'hello': 'world', 'somelist': []}
-    l = newdict['somelist']  
-    l.append(1)              # this triggers persisting the whole dict 
-    l.extend([2,3])          # this triggers persisting the whole dict 
-    del newdict, l 
-    
-    newdict = load(storage)
-    print newdict['somelist']   # will show [1,2,3]

demo/tproxy/persistence.py

+"""
+
+This small example implements a basic orthogonal persistence 
+mechanism on top of PyPy's transparent proxies. 
+
+"""
+from tputil import make_proxy
+
+list_changeops = set('__iadd__ __imul__ __delitem__ __setitem__ __setattr__'
+                     '__delslice__ __setslice__ '
+                     'append extend insert pop remove reverse sort'.split())
+
+dict_changeops = set('__delitem__ __setitem__  __setattr__'
+                     'clear pop popitem setdefault update'.split())
+
+def ischangeop(operation): 
+    """ return True if this operation is a changing operation 
+        on known builtins (dicts, lists). 
+    """ 
+    if isinstance(operation.obj, list):
+        changeops = list_changeops 
+    elif isinstance(operation.obj, dict):
+        changeops = dict_changeops 
+    else:
+        return False
+    return operation.opname in changeops 
+
+def make_persistent_proxy(instance, storage): 
+    def perform(operation): 
+        res = operation.delegate()
+        if ischangeop(operation):
+            print "persisting after:", operation 
+            storage.dump(instance)
+        if res is not operation.proxyobj and isinstance(res, (dict, list)):
+            res = make_proxy(perform, obj=res)
+        return res
+    return make_proxy(perform, obj=instance) 
+
+def load(storage):
+    obj = storage.load()
+    return make_persistent_proxy(obj, storage) 
+    
+if __name__ == '__main__': 
+    import py 
+    storage = py.path.local("/tmp/dictpickle")
+    pdict = make_persistent_proxy({}, storage) 
+
+    # the code below is not aware of pdict being a proxy 
+    assert type(pdict) is dict
+    pdict['hello'] = 'world'       
+    pdict['somelist'] = []
+    del pdict 
+
+    newdict = load(storage) 
+    assert newdict == {'hello': 'world', 'somelist': []}
+    l = newdict['somelist']  
+    l.append(1)              # this triggers persisting the whole dict 
+    l.extend([2,3])          # this triggers persisting the whole dict 
+    del newdict, l 
+    
+    newdict = load(storage)
+    print newdict['somelist']   # will show [1,2,3]

demo/uthread.py

-"""This is an example that uses the (prototype) Logic Object Space. To run,
-you have to set USE_GREENLETS in pypy.objspace.logic to True and do:
-  
-    $ py.py -o logic uthread.py
-
-newvar creates a new unbound logical variable. If you try to access an unbound
-variable, the current uthread is blocked, until the variable is bound.
-"""
-
-X = newvar()
-Y = newvar()
-
-bind(Y, X) # aliasing
-
-def f():
-    print "starting"
-    print is_free(X)
-    if Y:
-        print "ok"
-        return
-    print "false"
-    return
-
-def bind():
-    unify(X, 1)
-
-uthread(f)
-print "afterwards"
-uthread(bind)

dotviewer/conftest.py

 import py
 
-Option = py.test.config.Option
-option = py.test.config.addoptions("dotviewer options",
-        Option('--pygame', action="store_true", dest="pygame", default=False,
-               help="allow interactive tests using Pygame"),
-        )
+class ConftestPlugin:
+    def pytest_addoption(self, parser):
+        group = parser.addgroup("dotviever")
+        group.addoption('--pygame', action="store_true", 
+            dest="pygame", default=False, 
+            help="allow interactive tests using Pygame")

dotviewer/graphclient.py

             if msg[0] == msgstruct.MSG_OK:
                 break
     except EOFError:
-        ioerror = ioerror or IOError("connexion unexpectedly closed "
+        ioerror = ioerror or IOError("connection unexpectedly closed "
                                      "(graphserver crash?)")
     if ioerror is not None:
         raise ioerror

dotviewer/graphserver.py

     print 'listening on %r...' % (s1.getsockname(),)
     while True:
         conn, addr = s1.accept()
-        print 'accepted connexion from %r' % (addr,)
+        print 'accepted connection from %r' % (addr,)
         sock_io = msgstruct.SocketIO(conn)
         handler_io = graphclient.spawn_local_handler()
         thread.start_new_thread(copy_all, (sock_io, handler_io))

lib-python/2.5.2/test/test_mailbox.py

         msg = self._box.get(key1)
         self.assert_(msg['from'] == 'foo')
         self.assert_(msg.fp.read() == '1')
-        msg.fp.close()
 
     def test_getitem(self):
         # Retrieve message using __getitem__()
         # Get file representations of messages
         key0 = self._box.add(self._template % 0)
         key1 = self._box.add(_sample_message)
-        f0 = self._box.get_file(key0)
-        self.assert_(f0.read().replace(os.linesep, '\n') == self._template % 0)
-        f0.close()
-        f1 = self._box.get_file(key1)
-        self.assert_(f1.read().replace(os.linesep, '\n') == _sample_message)
-        f1.close()
+        self.assert_(self._box.get_file(key0).read().replace(os.linesep, '\n')
+                     == self._template % 0)
+        self.assert_(self._box.get_file(key1).read().replace(os.linesep, '\n')
+                     == _sample_message)
 
     def test_iterkeys(self):
         # Get keys using iterkeys()
         self._box.add(contents[1])
         self._box.add(contents[2])
         method()
-
-        # XXX this makes some tests not useful any more,
-        # but the mailbox really must closed before we replace the variable.
-        self._box.close()
-
         self._box = self._factory(self._path)
         keys = self._box.keys()
         self.assert_(len(keys) == 3)
         self._box._file.seek(0)
         contents = self._box._file.read()
         self._box.close()
-        f = open(self._path, 'rb')
-        initial = f.read()
-        f.close()
-        self.assert_(contents == initial)
+        self.assert_(contents == open(self._path, 'rb').read())
         self._box = self._factory(self._path)
 
     def test_lock_conflict(self):
         #self.assert_(len(self.mbox.boxes) == 0)
         self.assert_(self.mbox.next() is None)
         self.assert_(self.mbox.next() is None)
-        self.mbox.close()
 
     def test_nonempty_maildir_cur(self):
         self.createMessage("cur")
         self.mbox = mailbox.Maildir(test_support.TESTFN)
         #self.assert_(len(self.mbox.boxes) == 1)
-        msg = self.mbox.next()
-        self.assert_(msg is not None)
-        msg.fp.close()
+        self.assert_(self.mbox.next() is not None)
         self.assert_(self.mbox.next() is None)
         self.assert_(self.mbox.next() is None)
-        self.mbox.close()
 
     def test_nonempty_maildir_new(self):
         self.createMessage("new")
         self.mbox = mailbox.Maildir(test_support.TESTFN)
         #self.assert_(len(self.mbox.boxes) == 1)
-        msg = self.mbox.next()
-        self.assert_(msg is not None)
-        msg.fp.close()
+        self.assert_(self.mbox.next() is not None)
         self.assert_(self.mbox.next() is None)
         self.assert_(self.mbox.next() is None)
-        self.mbox.close()
 
     def test_nonempty_maildir_both(self):
         self.createMessage("cur")
         self.createMessage("new")
         self.mbox = mailbox.Maildir(test_support.TESTFN)
         #self.assert_(len(self.mbox.boxes) == 2)
-        msg = self.mbox.next()
-        self.assert_(msg is not None)
-        msg.fp.close()
-        msg = self.mbox.next()
-        self.assert_(msg is not None)
-        msg.fp.close()
+        self.assert_(self.mbox.next() is not None)
+        self.assert_(self.mbox.next() is not None)
         self.assert_(self.mbox.next() is None)
         self.assert_(self.mbox.next() is None)
-        self.mbox.close()
 
     def test_unix_mbox(self):
         ### should be better!
         import email.Parser
         fname = self.createMessage("cur", True)
         n = 0
-        fp = open(fname)
-        for msg in mailbox.PortableUnixMailbox(fp,
+        for msg in mailbox.PortableUnixMailbox(open(fname),
                                                email.Parser.Parser().parse):
             n += 1
             self.assertEqual(msg["subject"], "Simple Test")
             self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
-        fp.close()
         self.assertEqual(n, 1)
 
 ## End: classes from the original module (for backward compatibility).

lib-python/conftest.py

     RegrTest('test_bz2.py', usemodules='bz2'),
     RegrTest('test_calendar.py'),
     RegrTest('test_call.py', core=True),
-    RegrTest('test_capi.py', skip=True),
+    RegrTest('test_capi.py', skip="not applicable"),
     RegrTest('test_cd.py', skip=True),
     RegrTest('test_cfgparser.py'),
 
     RegrTest('test_slice.py', core=True),
     RegrTest('test_socket.py', usemodules='thread _weakref'),
 
-    RegrTest('test_socket_ssl.py', skip="no ssl support yet"),
+    RegrTest('test_socket_ssl.py', usemodules='_ssl'),
     RegrTest('test_socketserver.py', usemodules='thread'),
 
     RegrTest('test_softspace.py', core=True),

lib-python/modified-2.5.2/distutils/cmd.py

 from distutils import util, dir_util, file_util, archive_util, dep_util
 from distutils import log
 
+def _easy_install_get_site_dirs():
+    # return a list of 'site' dirs for easy_install
+    from pkg_resources import normalize_path
+    sitedirs = filter(None,os.environ.get('PYTHONPATH','').split(os.pathsep))
+    sitedirs.append(os.path.join(sys.pypy_prefix, 'site-packages'))
+    sitedirs = map(normalize_path, sitedirs)
+    return sitedirs
+
 class Command:
     """Abstract base class for defining command classes, the "worker bees"
     of the Distutils.  A useful analogy for command classes is to think of
 
     # -- Creation/initialization methods -------------------------------
 
+    def _easy_install_integration(self):
+        from setuptools.command import easy_install
+        easy_install.get_site_dirs = _easy_install_get_site_dirs
+        
     def __init__ (self, dist):
         """Create and initialize a new Command object.  Most importantly,
         invokes the 'initialize_options()' method, which is the real
         if self.__class__ is Command:
             raise RuntimeError, "Command is an abstract class"
 
+        if self.__class__.__name__ == "easy_install":
+            self._easy_install_integration()
+
         self.distribution = dist
         self.initialize_options()
 

lib-python/modified-2.5.2/netrc.py

+"""An object-oriented interface to .netrc files."""
+
+# Module and documentation by Eric S. Raymond, 21 Dec 1998
+
+import os, shlex
+
+__all__ = ["netrc", "NetrcParseError"]
+
+
+class NetrcParseError(Exception):
+    """Exception raised on syntax errors in the .netrc file."""
+    def __init__(self, msg, filename=None, lineno=None):
+        self.filename = filename
+        self.lineno = lineno
+        self.msg = msg
+        Exception.__init__(self, msg)
+
+    def __str__(self):
+        return "%s (%s, line %s)" % (self.msg, self.filename, self.lineno)
+
+
+class netrc:
+    def __init__(self, file=None):
+        if file is None:
+            try:
+                file = os.path.join(os.environ['HOME'], ".netrc")
+            except KeyError:
+                raise IOError("Could not find .netrc: $HOME is not set")
+        self.hosts = {}
+        self.macros = {}
+        fp = open(file)
+        try:
+            self._parse(fp)
+        finally:
+            fp.close()
+
+    def _parse(self, fp):
+        lexer = shlex.shlex(fp)
+        lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
+        while 1:
+            # Look for a machine, default, or macdef top-level keyword
+            toplevel = tt = lexer.get_token()
+            if not tt:
+                break
+            elif tt == 'machine':
+                entryname = lexer.get_token()
+            elif tt == 'default':
+                entryname = 'default'
+            elif tt == 'macdef':                # Just skip to end of macdefs
+                entryname = lexer.get_token()
+                self.macros[entryname] = []
+                lexer.whitespace = ' \t'
+                while 1:
+                    line = lexer.instream.readline()
+                    if not line or line == '\012':
+                        lexer.whitespace = ' \t\r\n'
+                        break
+                    self.macros[entryname].append(line)
+                continue
+            else:
+                raise NetrcParseError(
+                    "bad toplevel token %r" % tt, file, lexer.lineno)
+
+            # We're looking at start of an entry for a named machine or default.
+            login = ''
+            account = password = None
+            self.hosts[entryname] = {}
+            while 1:
+                tt = lexer.get_token()
+                if (tt=='' or tt == 'machine' or
+                    tt == 'default' or tt =='macdef'):
+                    if password:
+                        self.hosts[entryname] = (login, account, password)
+                        lexer.push_token(tt)
+                        break
+                    else:
+                        raise NetrcParseError(
+                            "malformed %s entry %s terminated by %s"
+                            % (toplevel, entryname, repr(tt)),
+                            file, lexer.lineno)
+                elif tt == 'login' or tt == 'user':
+                    login = lexer.get_token()
+                elif tt == 'account':
+                    account = lexer.get_token()
+                elif tt == 'password':
+                    password = lexer.get_token()
+                else:
+                    raise NetrcParseError("bad follower token %r" % tt,
+                                          file, lexer.lineno)
+        fp.close()
+
+    def authenticators(self, host):
+        """Return a (user, account, password) tuple for given host."""
+        if host in self.hosts:
+            return self.hosts[host]
+        elif 'default' in self.hosts:
+            return self.hosts['default']
+        else:
+            return None
+
+    def __repr__(self):
+        """Dump the class data in the format of a .netrc file."""
+        rep = ""
+        for host in self.hosts.keys():
+            attrs = self.hosts[host]
+            rep = rep + "machine "+ host + "\n\tlogin " + repr(attrs[0]) + "\n"
+            if attrs[1]:
+                rep = rep + "account " + repr(attrs[1])
+            rep = rep + "\tpassword " + repr(attrs[2]) + "\n"
+        for macro in self.macros.keys():
+            rep = rep + "macdef " + macro + "\n"
+            for line in self.macros[macro]:
+                rep = rep + line
+            rep = rep + "\n"
+        return rep
+
+if __name__ == '__main__':
+    print netrc()

lib-python/modified-2.5.2/platform.py

+#!/usr/bin/env python
+
+""" This module tries to retrieve as much platform-identifying data as
+    possible. It makes this information available via function APIs.
+
+    If called from the command line, it prints the platform
+    information concatenated as single string to stdout. The output
+    format is useable as part of a filename.
+
+"""
+#    This module is maintained by Marc-Andre Lemburg <mal@egenix.com>.
+#    If you find problems, please submit bug reports/patches via the
+#    Python SourceForge Project Page and assign them to "lemburg".
+#
+#    Note: Please keep this module compatible to Python 1.5.2.
+#
+#    Still needed:
+#    * more support for WinCE
+#    * support for MS-DOS (PythonDX ?)
+#    * support for Amiga and other still unsupported platforms running Python
+#    * support for additional Linux distributions
+#
+#    Many thanks to all those who helped adding platform-specific
+#    checks (in no particular order):
+#
+#      Charles G Waldman, David Arnold, Gordon McMillan, Ben Darnell,
+#      Jeff Bauer, Cliff Crawford, Ivan Van Laningham, Josef
+#      Betancourt, Randall Hopper, Karl Putland, John Farrell, Greg
+#      Andruk, Just van Rossum, Thomas Heller, Mark R. Levinson, Mark
+#      Hammond, Bill Tutt, Hans Nowak, Uwe Zessin (OpenVMS support),
+#      Colin Kong, Trent Mick, Guido van Rossum
+#
+#    History:
+#
+#    <see CVS and SVN checkin messages for history>
+#
+#    1.0.3 - added normalization of Windows system name
+#    1.0.2 - added more Windows support
+#    1.0.1 - reformatted to make doc.py happy
+#    1.0.0 - reformatted a bit and checked into Python CVS
+#    0.8.0 - added sys.version parser and various new access
+#            APIs (python_version(), python_compiler(), etc.)
+#    0.7.2 - fixed architecture() to use sizeof(pointer) where available
+#    0.7.1 - added support for Caldera OpenLinux
+#    0.7.0 - some fixes for WinCE; untabified the source file
+#    0.6.2 - support for OpenVMS - requires version 1.5.2-V006 or higher and
+#            vms_lib.getsyi() configured
+#    0.6.1 - added code to prevent 'uname -p' on platforms which are
+#            known not to support it
+#    0.6.0 - fixed win32_ver() to hopefully work on Win95,98,NT and Win2k;
+#            did some cleanup of the interfaces - some APIs have changed
+#    0.5.5 - fixed another type in the MacOS code... should have
+#            used more coffee today ;-)
+#    0.5.4 - fixed a few typos in the MacOS code
+#    0.5.3 - added experimental MacOS support; added better popen()
+#            workarounds in _syscmd_ver() -- still not 100% elegant
+#            though
+#    0.5.2 - fixed uname() to return '' instead of 'unknown' in all
+#            return values (the system uname command tends to return
+#            'unknown' instead of just leaving the field emtpy)
+#    0.5.1 - included code for slackware dist; added exception handlers
+#            to cover up situations where platforms don't have os.popen
+#            (e.g. Mac) or fail on socket.gethostname(); fixed libc
+#            detection RE
+#    0.5.0 - changed the API names referring to system commands to *syscmd*;
+#            added java_ver(); made syscmd_ver() a private
+#            API (was system_ver() in previous versions) -- use uname()
+#            instead; extended the win32_ver() to also return processor
+#            type information
+#    0.4.0 - added win32_ver() and modified the platform() output for WinXX
+#    0.3.4 - fixed a bug in _follow_symlinks()
+#    0.3.3 - fixed popen() and "file" command invokation bugs
+#    0.3.2 - added architecture() API and support for it in platform()
+#    0.3.1 - fixed syscmd_ver() RE to support Windows NT
+#    0.3.0 - added system alias support
+#    0.2.3 - removed 'wince' again... oh well.
+#    0.2.2 - added 'wince' to syscmd_ver() supported platforms
+#    0.2.1 - added cache logic and changed the platform string format
+#    0.2.0 - changed the API to use functions instead of module globals
+#            since some action take too long to be run on module import
+#    0.1.0 - first release
+#
+#    You can always get the latest version of this module at:
+#
+#             http://www.egenix.com/files/python/platform.py
+#
+#    If that URL should fail, try contacting the author.
+
+__copyright__ = """
+    Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
+    Copyright (c) 2000-2003, eGenix.com Software GmbH; mailto:info@egenix.com
+
+    Permission to use, copy, modify, and distribute this software and its
+    documentation for any purpose and without fee or royalty is hereby granted,
+    provided that the above copyright notice appear in all copies and that
+    both that copyright notice and this permission notice appear in
+    supporting documentation or portions thereof, including modifications,
+    that you make.
+
+    EGENIX.COM SOFTWARE GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO
+    THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+    FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
+    INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+    FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+    NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+    WITH THE USE OR PERFORMANCE OF THIS SOFTWARE !
+
+"""
+
+__version__ = '1.0.4'
+
+import sys,string,os,re
+
+### Platform specific APIs
+
+_libc_search = re.compile(r'(__libc_init)'
+                          '|'
+                          '(GLIBC_([0-9.]+))'
+                          '|'
+                          '(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)')
+
+def libc_ver(executable=sys.executable,lib='',version='',
+
+             chunksize=2048, maxsize=65536):
+
+    """ Tries to determine the libc version that the file executable
+        (which defaults to the Python interpreter) is linked against.
+
+        Returns a tuple of strings (lib,version) which default to the
+        given parameters in case the lookup fails.
+
+        Note that the function has intimate knowledge of how different
+        libc versions add symbols to the executable and thus is probably
+        only useable for executables compiled using gcc.
+
+        At most 'maxsize' bytes of the file are read.
+
+    """
+    f = open(executable,'rb')
+    binary = f.read(maxsize)
+    pos = 0
+    while 1:
+        m = _libc_search.search(binary,pos)
+        if not m:
+            break
+        libcinit,glibc,glibcversion,so,threads,soversion = m.groups()
+        if libcinit and not lib:
+            lib = 'libc'
+        elif glibc:
+            if lib != 'glibc':
+                lib = 'glibc'
+                version = glibcversion
+            elif glibcversion > version:
+                version = glibcversion
+        elif so:
+            if lib != 'glibc':
+                lib = 'libc'
+                if soversion > version:
+                    version = soversion
+                if threads and version[-len(threads):] != threads:
+                    version = version + threads
+        pos = m.end()
+    f.close()
+    return lib,version
+
+def _dist_try_harder(distname,version,id):
+
+    """ Tries some special tricks to get the distribution
+        information in case the default method fails.
+
+        Currently supports older SuSE Linux, Caldera OpenLinux and
+        Slackware Linux distributions.
+
+    """
+    if os.path.exists('/var/adm/inst-log/info'):
+        # SuSE Linux stores distribution information in that file
+        info = open('/var/adm/inst-log/info').readlines()
+        distname = 'SuSE'
+        for line in info:
+            tv = string.split(line)
+            if len(tv) == 2:
+                tag,value = tv
+            else:
+                continue
+            if tag == 'MIN_DIST_VERSION':
+                version = string.strip(value)
+            elif tag == 'DIST_IDENT':
+                values = string.split(value,'-')
+                id = values[2]
+        return distname,version,id
+
+    if os.path.exists('/etc/.installed'):
+        # Caldera OpenLinux has some infos in that file (thanks to Colin Kong)
+        info = open('/etc/.installed').readlines()
+        for line in info:
+            pkg = string.split(line,'-')
+            if len(pkg) >= 2 and pkg[0] == 'OpenLinux':
+                # XXX does Caldera support non Intel platforms ? If yes,
+                #     where can we find the needed id ?
+                return 'OpenLinux',pkg[1],id
+
+    if os.path.isdir('/usr/lib/setup'):
+        # Check for slackware verson tag file (thanks to Greg Andruk)
+        verfiles = os.listdir('/usr/lib/setup')
+        for n in range(len(verfiles)-1, -1, -1):
+            if verfiles[n][:14] != 'slack-version-':
+                del verfiles[n]
+        if verfiles:
+            verfiles.sort()
+            distname = 'slackware'
+            version = verfiles[-1][14:]
+            return distname,version,id
+
+    return distname,version,id
+
+_release_filename = re.compile(r'(\w+)[-_](release|version)')
+_release_version = re.compile(r'([\d.]+)[^(]*(?:\((.+)\))?')
+
+# Note:In supported_dists below we need 'fedora' before 'redhat' as in
+# Fedora redhat-release is a link to fedora-release.
+
+def dist(distname='',version='',id='',
+
+         supported_dists=('SuSE', 'debian', 'fedora', 'redhat', 'mandrake')):
+
+    """ Tries to determine the name of the Linux OS distribution name.
+
+        The function first looks for a distribution release file in
+        /etc and then reverts to _dist_try_harder() in case no
+        suitable files are found.
+
+        Returns a tuple (distname,version,id) which default to the
+        args given as parameters.
+
+    """
+    try:
+        etc = os.listdir('/etc')
+    except os.error:
+        # Probably not a Unix system
+        return distname,version,id
+    for file in etc:
+        m = _release_filename.match(file)
+        if m:
+            _distname,dummy = m.groups()
+            if _distname in supported_dists:
+                distname = _distname
+                break
+    else:
+        return _dist_try_harder(distname,version,id)
+    f = open('/etc/'+file,'r')
+    firstline = f.readline()
+    f.close()
+    m = _release_version.search(firstline)
+    if m:
+        _version,_id = m.groups()
+        if _version:
+            version = _version
+        if _id:
+            id = _id
+    else:
+        # Unkown format... take the first two words
+        l = string.split(string.strip(firstline))
+        if l:
+            version = l[0]
+            if len(l) > 1:
+                id = l[1]
+    return distname,version,id