[pypy-commit] pypy numpy-dtype-refactor: merged default in

alex_gaynor noreply at buildbot.pypy.org
Wed Nov 30 16:50:47 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: numpy-dtype-refactor
Changeset: r50015:2e67585de373
Date: 2011-11-29 16:14 -0500
http://bitbucket.org/pypy/pypy/changeset/2e67585de373/

Log:	merged default in

diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -304,5 +304,14 @@
   never a dictionary as it sometimes is in CPython. Assigning to
   ``__builtins__`` has no effect.
 
+* directly calling the internal magic methods of a few built-in types
+  with invalid arguments may have a slightly different result.  For
+  example, ``[].__add__(None)`` and ``(2).__add__(None)`` both return
+  ``NotImplemented`` on PyPy; on CPython, only the later does, and the
+  former raises ``TypeError``.  (Of course, ``[]+None`` and ``2+None``
+  both raise ``TypeError`` everywhere.)  This difference is an
+  implementation detail that shows up because of internal C-level slots
+  that PyPy does not have.
+
 
 .. include:: _ref.txt
diff --git a/pypy/rlib/test/test_rstacklet.py b/pypy/rlib/test/test_rstacklet.py
--- a/pypy/rlib/test/test_rstacklet.py
+++ b/pypy/rlib/test/test_rstacklet.py
@@ -65,6 +65,15 @@
             self.tasks[0].withdepth(self.random.genrand32() % 50)
             assert len(self.tasks[0].lst) == 0
 
+    @here_is_a_test
+    def test_destroy(self):
+        # this used to give MemoryError in shadowstack tests
+        for i in range(100000):
+            self.status = 0
+            h = self.sthread.new(switchbackonce_callback,
+                                 rffi.cast(llmemory.Address, 321))
+            self.sthread.destroy(h)
+
     def any_alive(self):
         for task in self.tasks:
             if task.h:
diff --git a/pypy/rpython/memory/gctransform/shadowstack.py b/pypy/rpython/memory/gctransform/shadowstack.py
--- a/pypy/rpython/memory/gctransform/shadowstack.py
+++ b/pypy/rpython/memory/gctransform/shadowstack.py
@@ -307,7 +307,7 @@
                   "restore_state_from: broken shadowstack")
         self.gcdata.root_stack_base = shadowstackref.base
         self.gcdata.root_stack_top  = shadowstackref.top
-        self.destroy(shadowstackref)
+        self._cleanup(shadowstackref)
 
     def start_fresh_new_state(self):
         self.gcdata.root_stack_base = self.unused_full_stack
@@ -315,6 +315,10 @@
         self.unused_full_stack = llmemory.NULL
 
     def destroy(self, shadowstackref):
+        llmemory.raw_free(shadowstackref.base)
+        self._cleanup(shadowstackref)
+
+    def _cleanup(self, shadowstackref):
         shadowstackref.base = llmemory.NULL
         shadowstackref.top = llmemory.NULL
         shadowstackref.context = llmemory.NULL


More information about the pypy-commit mailing list