Author: Spenser Bauman <saba...@gmail.com>
Branch: clean-exported-state
Changeset: r87764:7b2258eda778
Date: 2016-10-13 10:34 -0400
http://bitbucket.org/pypy/pypy/changeset/7b2258eda778/

Log:    Merge with default

diff --git a/lib-python/2.7/test/test_cmd_line.py 
b/lib-python/2.7/test/test_cmd_line.py
--- a/lib-python/2.7/test/test_cmd_line.py
+++ b/lib-python/2.7/test/test_cmd_line.py
@@ -75,7 +75,7 @@
         p.stdin.write('Timer\n')
         p.stdin.write('exit()\n')
         data = kill_python(p)
-        self.assertTrue(data.startswith('1 loop'))
+        self.assertIn('1 loop', data)
         self.assertIn('__main__.Timer', data)
 
     def test_run_code(self):
diff --git a/lib-python/2.7/test/test_timeit.py 
b/lib-python/2.7/test/test_timeit.py
--- a/lib-python/2.7/test/test_timeit.py
+++ b/lib-python/2.7/test/test_timeit.py
@@ -318,9 +318,8 @@
         s = self.run_main(seconds_per_increment=2.0, switches=['-n35', '-s', 
'print("CustomSetup")'])
         self.assertIn(dedent("""\
             WARNING: timeit is a very unreliable tool. use perf or something 
else for real measurements
-            pypy -m pip install perf
-            pypy -m perf timeit -n35 -s 'print("CustomSetup")' 'import timeit; 
timeit._fake_timer.inc()'
         """), s)
+        self.assertIn("-m pip install perf", s)
 
 
 
diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -64,8 +64,6 @@
 
     def setitem_str(self, w_dict, key, w_value):
         cell = self.getdictvalue_no_unwrapping(w_dict, key)
-        #if (key == '__package__' or key == "__path__") and cell is not None 
and w_value is not cell:
-        #    print "WARNING", key, w_value, cell, self
         return self._setitem_str_cell_known(cell, w_dict, key, w_value)
 
     def _setitem_str_cell_known(self, cell, w_dict, key, w_value):
diff --git a/rpython/jit/metainterp/optimizeopt/shortpreamble.py 
b/rpython/jit/metainterp/optimizeopt/shortpreamble.py
--- a/rpython/jit/metainterp/optimizeopt/shortpreamble.py
+++ b/rpython/jit/metainterp/optimizeopt/shortpreamble.py
@@ -81,13 +81,13 @@
         descr = self.getfield_op.getdescr()
         if rop.is_getfield(g.opnum):
             cf = optheap.field_cache(descr)
-            opinfo.setfield(preamble_op.getdescr(), self.res, pop,
+            opinfo.setfield(preamble_op.getdescr(), g.getarg(0), pop,
                             optheap, cf)
         else:
             index = g.getarg(1).getint()
             assert index >= 0
             cf = optheap.arrayitem_cache(descr, index)
-            opinfo.setitem(self.getfield_op.getdescr(), index, self.res,
+            opinfo.setitem(self.getfield_op.getdescr(), index, g.getarg(0),
                            pop, optheap, cf)
 
     def repr(self, memo):
diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -129,6 +129,9 @@
     def acquire(self, flag):
         return True
 
+    def is_acquired(self):
+        return False
+
     def release(self):
         pass
 
@@ -164,6 +167,15 @@
             res = rffi.cast(lltype.Signed, res)
             return bool(res)
 
+    def is_acquired(self):
+        """ check if the lock is acquired (does not release the GIL) """
+        res = c_thread_acquirelock_timed_NOAUTO(
+            self._lock,
+            rffi.cast(rffi.LONGLONG, 0),
+            rffi.cast(rffi.INT, 0))
+        res = rffi.cast(lltype.Signed, res)
+        return not bool(res)
+
     def acquire_timed(self, timeout):
         """Timeout is in microseconds.  Returns 0 in case of failure,
         1 in case it works, 2 if interrupted by a signal."""
diff --git a/rpython/rlib/test/test_rthread.py 
b/rpython/rlib/test/test_rthread.py
--- a/rpython/rlib/test/test_rthread.py
+++ b/rpython/rlib/test/test_rthread.py
@@ -16,6 +16,14 @@
     res = ok1 and not ok2 and ok3
     assert res == 1
 
+def test_lock_is_aquired():
+    l = allocate_lock()
+    ok1 = l.acquire(True)
+    assert l.is_acquired() == True
+    assert l.is_acquired() == True
+    l.release()
+    assert l.is_acquired() == False
+
 def test_thread_error():
     l = allocate_lock()
     try:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to