Author: Matti Picus <matti.pi...@gmail.com>
Branch: py3.6
Changeset: r97447:26d040d0bd1f
Date: 2019-09-11 19:57 +0300
http://bitbucket.org/pypy/pypy/changeset/26d040d0bd1f/

Log:    merge default into branch

diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -87,7 +87,6 @@
         failures = create_cffi_import_libraries(
             str(pypy_c), options, str(basedir),
             embed_dependencies=options.embed_dependencies,
-            rebuild=True,
         )
 
         for key, module in failures:
diff --git a/rpython/rlib/buffer.py b/rpython/rlib/buffer.py
--- a/rpython/rlib/buffer.py
+++ b/rpython/rlib/buffer.py
@@ -123,7 +123,7 @@
 
 class RawBuffer(Buffer):
     """
-    A buffer which is baked by a raw, non-movable memory area. It implementes
+    A buffer which is backed by a raw, non-movable memory area. It implementes
     typed_read and typed_write in terms of get_raw_address(), llop.raw_load,
     llop.raw_store.
 
@@ -157,7 +157,7 @@
 
 class GCBuffer(Buffer):
     """
-    Base class for a buffer which is baked by a GC-managed memory area. You
+    Base class for a buffer which is backed by a GC-managed memory area. You
     MUST also decorate the class with @GCBuffer.decorate: it implements
     typed_read and typed_write in terms of llop.gc_load_indexed and
     llop.gc_store_indexed.
@@ -250,6 +250,14 @@
     def setitem(self, index, char):
         self.data[index] = char
 
+    def getslice(self, start, stop, step, size):
+        if step == 1:
+            assert 0 <= start <= stop
+            if start == 0 and stop == len(self.data):
+                return "".join(self.data)
+            return "".join(self.data[start:stop])
+        return Buffer.getslice(self, start, stop, step, size)
+
     def get_raw_address(self):
         return nonmoving_raw_ptr_for_resizable_list(self.data)
 
diff --git a/rpython/rlib/test/test_buffer.py b/rpython/rlib/test/test_buffer.py
--- a/rpython/rlib/test/test_buffer.py
+++ b/rpython/rlib/test/test_buffer.py
@@ -197,6 +197,12 @@
         assert buf.typed_read(rffi.USHORT, 0) == 0x1234
         assert buf.typed_read(rffi.USHORT, 2) == 0x5678
 
+    def test_getslice_shortcut(self):
+        buf = ByteBuffer(4)
+        buf.setslice(0, b"data")
+        buf.getitem = None
+        assert buf.getslice(0, 2, 1, 2) == b"da" # no crash!
+
 
 class TestJIT(LLJitMixin):
 
diff --git a/rpython/translator/c/src/thread_pthread.c 
b/rpython/translator/c/src/thread_pthread.c
--- a/rpython/translator/c/src/thread_pthread.c
+++ b/rpython/translator/c/src/thread_pthread.c
@@ -454,13 +454,13 @@
 
        lock->locked = 0;
 
-       status = pthread_mutex_unlock( &lock->mut );
-       CHECK_STATUS("pthread_mutex_unlock[3]");
-
        /* wake up someone (anyone, if any) waiting on the lock */
        status = pthread_cond_signal( &lock->lock_released );
        CHECK_STATUS("pthread_cond_signal");
 
+       status = pthread_mutex_unlock( &lock->mut );
+       CHECK_STATUS("pthread_mutex_unlock[3]");
+
         return result;
 }
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to