Commits

mattip committed bc9fdf9 Merge

merge default into branch

Comments (0)

Files changed (8)

lib-python/2.7/test/test_httpservers.py

             response = self.request(self.tempdir_name + '/')
             self.check_status_and_reason(response, 404)
             os.chmod(self.tempdir, 0755)
+        f.close()    
 
     def test_head(self):
         response = self.request(

lib_pypy/_testcapi.py

     raise ImportError("No module named '_testcapi'")
 
 def get_hashed_dir(cfile):
+    with open(cfile,'r') as fid:
+        content = fid.read()
     # from cffi's Verifier()
-    key = '\x00'.join([sys.version[:3], cfile])
+    key = '\x00'.join([sys.version[:3], content])
     if sys.version_info >= (3,):
         key = key.encode('utf-8')
     k1 = hex(binascii.crc32(key[0::2]) & 0xffffffff)
     return output_dir 
 
 cfile = '_testcapimodule.c'
-output_dir = get_hashed_dir(cfile)
+thisdir = os.path.dirname(__file__)
+output_dir = get_hashed_dir(os.path.join(thisdir, cfile))
 
 try:
     fp, filename, description = imp.find_module('_testcapi', path=[output_dir])

pypy/doc/garbage_collection.rst

 The present document describes the specific garbage collectors that we
 wrote in our framework.
 
-.. _`EU-report on this topic`: http://codespeak.net/pypy/extradoc/eu-report/D07.1_Massive_Parallelism_and_Translation_Aspects-2007-02-28.pdf
+.. _`EU-report on this topic`: https://bitbucket.org/pypy/extradoc/raw/tip/eu-report/D07.1_Massive_Parallelism_and_Translation_Aspects-2007-02-28.pdf
 
 
 Garbage collectors currently written for the GC framework

pypy/module/test_lib_pypy/test_testcapi.py

+import py, sys
+
+if '__pypy__' not in sys.builtin_module_names:
+    py.test.skip('pypy only test')
+
+from lib_pypy import _testcapi #make sure _testcapi is built
+
+def test_get_hashed_dir():
+    import sys
+    # This should not compile _testcapi, so the output is empty
+    script = "import _testcapi; assert 'get_hashed_dir' in dir(_testcapi)"
+    output = py.process.cmdexec('''"%s" -c "%s"''' %
+                             (sys.executable, script))
+    assert output == ''
+            

rpython/flowspace/objspace.py

     if func.func_doc and func.func_doc.lstrip().startswith('NOT_RPYTHON'):
         raise ValueError("%r is tagged as NOT_RPYTHON" % (func,))
     if func.func_code.co_cellvars:
-        raise ValueError("RPython functions cannot create closures")
+        raise ValueError(
+"""RPython functions cannot create closures
+Possible casues:
+    Function is inner function
+    Function uses generator expressions
+    Lambda expressions
+in %r""" % (func,))
     if not (func.func_code.co_flags & CO_NEWLOCALS):
         raise ValueError("The code object for a RPython function should have "
                          "the flag CO_NEWLOCALS set.")

rpython/rlib/rsre/rsre_re.py

 """
-Testing code.  This is not used in a PyPy translation.
-It exports the same interface as the Python 're' module.
+This is not used in a PyPy translation, but it can be used
+in RPython code.  It exports the same interface as the
+Python 're' module.  You can call the functions at the start
+of the module (expect the ones with NOT_RPYTHON for now).
+They must be called with a *constant* pattern string.
 """
 import re, sys
 from rpython.rlib.rsre import rsre_core, rsre_char
 from rpython.rlib.rsre.rpy import get_code as _get_code
 from rpython.rlib.unicodedata import unicodedb
-from rpython.rlib.objectmodel import specialize
+from rpython.rlib.objectmodel import specialize, we_are_translated
 rsre_char.set_unicode_db(unicodedb)
 
 
 X = VERBOSE    = re.X   # ignore whitespace and comments
 
 
+@specialize.call_location()
 def match(pattern, string, flags=0):
     return compile(pattern, flags).match(string)
 
+@specialize.call_location()
 def search(pattern, string, flags=0):
     return compile(pattern, flags).search(string)
 
+@specialize.call_location()
 def findall(pattern, string, flags=0):
     return compile(pattern, flags).findall(string)
 
+@specialize.call_location()
 def finditer(pattern, string, flags=0):
     return compile(pattern, flags).finditer(string)
 
 def sub(pattern, repl, string, count=0):
+    "NOT_RPYTHON"
     return compile(pattern).sub(repl, string, count)
 
 def subn(pattern, repl, string, count=0):
+    "NOT_RPYTHON"
     return compile(pattern).subn(repl, string, count)
 
+@specialize.call_location()
 def split(pattern, string, maxsplit=0):
     return compile(pattern).split(string, maxsplit)
 
 
     def findall(self, string, pos=0, endpos=sys.maxint):
         matchlist = []
-        for match in self.finditer(string, pos, endpos):
+        scanner = self.scanner(string, pos, endpos)
+        while True:
+            match = scanner.search()
+            if match is None:
+                break
             if self.groups == 0 or self.groups == 1:
                 item = match.group(self.groups)
             else:
+                assert False, ("findall() not supported if there is more "
+                               "than one group: not valid RPython")
                 item = match.groups("")
             matchlist.append(item)
         return matchlist
 
     def finditer(self, string, pos=0, endpos=sys.maxint):
-        return iter(self.scanner(string, pos, endpos).search, None)
+        scanner = self.scanner(string, pos, endpos)
+        while True:
+            match = scanner.search()
+            if match is None:
+                break
+            yield match
 
     def subn(self, repl, string, count=0):
+        "NOT_RPYTHON"
         filter = repl
         if not callable(repl) and "\\" in repl:
             # handle non-literal strings; hand it over to the template compiler
         return item, n
 
     def sub(self, repl, string, count=0):
+        "NOT_RPYTHON"
         item, n = self.subn(repl, string, count)
         return item
 
             grp = self.group(i)
             if grp is None: grp = default
             grps.append(grp)
-        return tuple(grps)
+        if not we_are_translated():
+            grps = tuple(grps)    # xxx mostly to make tests happy
+        return grps
 
     def groupdict(self, default=None):
         d = {}

rpython/rlib/rsre/test/test_re.py

         assert re.findall(":+", "abc") == []
         assert re.findall(":+", "a:b::c:::d") == [":", "::", ":::"]
         assert re.findall("(:+)", "a:b::c:::d") == [":", "::", ":::"]
+
+    def test_re_findall_2(self):
+        py.test.skip("findall() returning groups is not RPython")
         assert re.findall("(:)(:*)", "a:b::c:::d") == [(":", ""),
                                                                (":", ":"),
                                                                (":", "::")]
 
     def test_bug_117612(self):
+        py.test.skip("findall() returning groups is not RPython")
         assert re.findall(r"(a|(b))", "aba") == (
                          [("a", ""),("b", "b"),("a", "")])
 

rpython/rlib/rsre/test/test_zinterp.py

         return int("aaaaaa" == g.group(0))
     assert interpret(f, [3]) == 1
     assert interpret(f, [0]) == 3
+
+def test_translates():
+    from rpython.rlib.rsre import rsre_re
+    def f(i):
+        if i:
+            s = "aaaaaa"
+        else:
+            s = "caaaaa"
+        print rsre_re.match("(a|b)aa", s)
+        print rsre_re.match("a{4}", s)
+        print rsre_re.search("(a|b)aa", s)
+        print rsre_re.search("a{4}", s)
+        for x in rsre_re.findall("(a|b)a", s):  print x
+        for x in rsre_re.findall("a{2}", s):    print x
+        for x in rsre_re.finditer("(a|b)a", s): print x
+        for x in rsre_re.finditer("a{2}", s):   print x
+        for x in rsre_re.split("(a|b)a", s):    print x
+        for x in rsre_re.split("a{2}", s):      print x
+        return 0
+    interpret(f, [3])  # assert does not crash