Commits

Brian Kearns committed ac5e46d Merge

merge default

Comments (0)

Files changed (13)

lib-python/2.7/inspect.py

                 raise TypeError('%s() takes exactly 0 arguments '
                                 '(%d given)' % (f_name, num_total))
         else:
-            raise TypeError('%s() takes no argument (%d given)' %
+            raise TypeError('%s() takes no arguments (%d given)' %
                             (f_name, num_total))
     for arg in args:
         if isinstance(arg, str) and arg in named:

lib-python/2.7/site.py

 USER_SITE = None
 USER_BASE = None
 
+
 def makepath(*paths):
     dir = os.path.join(*paths)
     try:

lib-python/2.7/test/test_capi.py

     threading = None
 import _testcapi
 
+skips = []
+if test_support.check_impl_detail(pypy=True):
+    skips += [
+            'test_broken_memoryview',
+            'test_capsule',
+            'test_lazy_hash_inheritance',
+            'test_long_api',
+            'test_longlong_api',
+            'test_null_strings',
+            'test_widechar',
+            'TestThreadState',
+            'TestPendingCalls',
+            ]
+
 @unittest.skipUnless(threading, 'Threading required for this test.')
 class TestPendingCalls(unittest.TestCase):
 
 def test_main():
 
     for name in dir(_testcapi):
-        if name.startswith('test_'):
+        if name.startswith('test_') and name not in skips:
             test = getattr(_testcapi, name)
             if test_support.verbose:
                 print "internal", name
             raise test_support.TestFailed, \
                   "Couldn't find main thread correctly in the list"
 
-    if threading:
+    if threading and 'TestThreadState' not in skips:
         import thread
         import time
         TestThreadState()
         t.start()
         t.join()
 
-    test_support.run_unittest(TestPendingCalls)
+    if 'TestPendingCalls' not in skips:
+        test_support.run_unittest(TestPendingCalls)
 
 if __name__ == "__main__":
     test_main()

lib-python/2.7/test/test_itertools.py

         self.assertEqual(list(izip()), zip())
         self.assertRaises(TypeError, izip, 3)
         self.assertRaises(TypeError, izip, range(3), 3)
-
         self.assertEqual([tuple(list(pair)) for pair in izip('abc', 'def')],
                          zip('abc', 'def'))
         self.assertEqual([pair for pair in izip('abc', 'def')],
                          zip('abc', 'def'))
+
     @test_support.impl_detail("tuple reuse is specific to CPython")
     def test_izip_tuple_reuse(self):
         ids = map(id, izip('abc', 'def'))
                          zip('abc', 'def'))
         self.assertEqual([pair for pair in izip_longest('abc', 'def')],
                          zip('abc', 'def'))
+
     @test_support.impl_detail("tuple reuse is specific to CPython")
     def test_izip_longest_tuple_reuse(self):
         ids = map(id, izip_longest('abc', 'def'))

lib-python/2.7/test/test_support.py

     else:
         runner = BasicTestRunner()
 
-
     result = runner.run(suite)
     if not result.wasSuccessful():
         if len(result.errors) == 1 and not result.failures:

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="not applicable"),
+    RegrTest('test_capi.py'),
     RegrTest('test_cd.py'),
     RegrTest('test_cfgparser.py'),
     RegrTest('test_cgi.py'),

pypy/module/cpyext/api.py

             kwds["link_extra"] = ["msvcrt.lib"]
         elif sys.platform.startswith('linux'):
             compile_extra.append("-Werror=implicit-function-declaration")
+            compile_extra.append('-g')
         export_symbols_eci.append('pypyAPI')
-        compile_extra.append('-g')
     else:
         kwds["includes"] = ['Python.h'] # this is our Python.h
 

pypy/module/thread/test/support.py

 import time
 import thread
 import os
+import errno
 
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.module.thread import gil
     def kill():
         for x in range(delay * 10):
             time.sleep(0.1)
-            os.kill(pid, 0)
+            try:
+                os.kill(pid, 0)
+            except OSError, e:
+                if e.errno == errno.ESRCH: # no such process
+                    return
+                raise
         os.kill(pid, 9)
         print "process %s killed!" % (pid,)
     thread.start_new_thread(kill, ())

pypy/module/thread/test/test_fork.py

 from pypy.module.thread.test.support import GenericTestThread
 
 class AppTestFork(GenericTestThread):
-    def test_fork(self):
+    def test_fork_with_thread(self):
         # XXX This test depends on a multicore machine, as busy_thread must
         # aquire the GIL the instant that the main thread releases it.
         # It will incorrectly pass if the GIL is not grabbed in time.
         if not hasattr(os, 'fork'):
             skip("No fork on this platform")
 
-        run = True
-        done = []
         def busy_thread():
             while run:
                 time.sleep(0)
             done.append(None)
 
-        try:
-            thread.start_new(busy_thread, ())
+        for i in range(1):
+            run = True
+            done = []
+            try:
+                thread.start_new(busy_thread, ())
+                print 'sleep'
 
-            pid = os.fork()
-
-            if pid == 0:
-                os._exit(0)
-
-            else:
-                time.sleep(1)
-                spid, status = os.waitpid(pid, os.WNOHANG)
-                assert spid == pid
-        finally:
-            run = False
-            self.waitfor(lambda: done)
+                pid = os.fork()
+                if pid == 0:
+                    os._exit(0)
+                else:
+                    self.timeout_killer(pid, 5)
+                    exitcode = os.waitpid(pid, 0)[1]
+                    assert exitcode == 0 # if 9, process was killed by timer!
+            finally:
+                run = False
+                self.waitfor(lambda: done)
+                assert done
 
     def test_forked_can_thread(self):
         "Checks that a forked interpreter can start a thread"
-        import os, thread, time
+        import thread
+        import os
 
         if not hasattr(os, 'fork'):
             skip("No fork on this platform")
 
-        # pre-allocate some locks
-        thread.start_new_thread(lambda: None, ())
+        for i in range(10):
+            # pre-allocate some locks
+            thread.start_new_thread(lambda: None, ())
+            print 'sleep'
 
-        pid = os.fork()
-        if pid == 0:
-            print 'in child'
-            thread.start_new_thread(lambda: None, ())
-            os._exit(0)
-        else:
-            self.timeout_killer(pid, 5)
-            exitcode = os.waitpid(pid, 0)[1]
-            assert exitcode == 0 # if 9, process was killed by timer!
+            pid = os.fork()
+            if pid == 0:
+                thread.start_new_thread(lambda: None, ())
+                os._exit(0)
+            else:
+                self.timeout_killer(pid, 5)
+                exitcode = os.waitpid(pid, 0)[1]
+                assert exitcode == 0 # if 9, process was killed by timer!

rpython/jit/metainterp/optimizeopt/rewrite.py

 
     def optimize_GUARD_VALUE(self, op):
         value = self.getvalue(op.getarg(0))
+        if value.is_virtual():
+            raise InvalidLoop('A promote of a virtual (a recently allocated object) never makes sense!')
         if value.last_guard:
             # there already has been a guard_nonnull or guard_class or
             # guard_nonnull_class on this value, which is rather silly.

rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py

         jump(p2)
         """
         self.raises(InvalidLoop, self.optimize_loop,
-                       ops, ops)
+                       ops, "crash!")
 
     def test_invalid_loop_2(self):
         ops = """
         jump(p2)
         """
         self.raises(InvalidLoop, self.optimize_loop,
-                       ops, ops)
+                       ops, "crash!")
 
     def test_invalid_loop_3(self):
         ops = """
         setfield_gc(p3, p4, descr=nextdescr)
         jump(p3)
         """
-        self.raises(InvalidLoop, self.optimize_loop, ops, ops)
-
+        self.raises(InvalidLoop, self.optimize_loop, ops, "crash!")
+
+    def test_invalid_loop_guard_value_of_virtual(self):
+        ops = """
+        [p1]
+        p2 = new_with_vtable(ConstClass(node_vtable))
+        guard_value(p2, ConstPtr(myptr)) []
+        jump(p2)
+        """
+        self.raises(InvalidLoop, self.optimize_loop,
+                       ops, "crash!")
 
     def test_merge_guard_class_guard_value(self):
         ops = """

rpython/translator/c/src/thread_nt.c

 /*
  * Thread support.
  */
+/* In rpython, this file is pulled in by thread.c */
 
 typedef struct RPyOpaque_ThreadLock NRMUTEX, *PNRMUTEX;
 

rpython/translator/c/src/thread_nt.h

 } NRMUTEX, *PNRMUTEX;
 
 /* prototypes */
+long RPyThreadGetIdent(void);
 long RPyThreadStart(void (*func)(void));
 int RPyThreadLockInit(struct RPyOpaque_ThreadLock *lock);
 void RPyOpaqueDealloc_ThreadLock(struct RPyOpaque_ThreadLock *lock);