Imported Upstream version 0.29.13 upstream/0.29.13
authorDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 31 Dec 2020 03:05:45 +0000 (12:05 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 31 Dec 2020 03:05:45 +0000 (12:05 +0900)
CHANGES.rst
Cython/Compiler/Options.py
Cython/Includes/cpython/pystate.pxd
Cython/Includes/posix/mman.pxd
Cython/Shadow.py
Cython/Utility/MemoryView.pyx
tests/memoryview/memoryview.pyx
tests/run/cpython_capi.pyx

index 25fb97f1241b4458ea9bbda827de8d68ea185c67..97cb89c3524fe6eb8c1fbbb2f63cd71690e46cb1 100644 (file)
@@ -2,6 +2,26 @@
 Cython Changelog
 ================
 
+0.29.13 (2019-07-26)
+====================
+
+Bugs fixed
+----------
+
+* A reference leak for ``None`` was fixed when converting a memoryview
+  to a Python object.  (Github issue #3023)
+
+* The declaration of ``PyGILState_STATE`` in ``cpython.pystate`` was unusable.
+  Patch by Kirill Smelkov.  (Github issue #2997)
+
+
+Other changes
+-------------
+
+* The declarations in ``posix.mman`` were extended.
+  Patches by Kirill Smelkov.  (Github issues #2893, #2894, #3012)
+
+
 0.29.12 (2019-07-07)
 ====================
 
index 78e144fc67d32d346bba52575a42b5e0fa6dade4..a634aaf56738be000f652883189a2d3bee39d493 100644 (file)
@@ -58,8 +58,12 @@ pre_import = None
 
 #: Decref global variables in each module on exit for garbage collection.
 #: 0: None, 1+: interned objects, 2+: cdef globals, 3+: types objects
-#: Mostly for reducing noise in Valgrind, only executes at process exit
+#: Mostly for reducing noise in Valgrind as it typically executes at process exit
 #: (when all memory will be reclaimed anyways).
+#: Note that directly or indirectly executed cleanup code that makes use of global
+#: variables or types may no longer be safe when enabling the respective level since
+#: there is no guaranteed order in which the (reference counted) objects will
+#: be cleaned up.  The order can change due to live references and reference cycles.
 generate_cleanup_code = False
 
 #: Should tp_clear() set object fields to None instead of clearing them to NULL?
index dfe19a191ea9764f43aca0f841914eae5384ab3a..1af63079313fc7ff6cdbb825c3c27f29a99810cc 100644 (file)
@@ -20,7 +20,8 @@ cdef extern from "Python.h":
 
     # This is not actually a struct, but make sure it can never be coerced to
     # an int or used in arithmetic expressions
-    ctypedef struct PyGILState_STATE
+    ctypedef struct PyGILState_STATE:
+        pass
 
     # The type of the trace function registered using PyEval_SetProfile() and
     # PyEval_SetTrace().
index 909e3019aa5d9571bc4b6a6dc8e654a2c92a1bd7..c810f431b3dd1b29f4c7a8cc5f88d8ab98d4f58e 100644 (file)
@@ -24,6 +24,8 @@ cdef extern from "<sys/mman.h>" nogil:
     enum: MAP_NOCORE                #  Typically available only on BSD
     enum: MAP_NOSYNC
 
+    void *MAP_FAILED
+
     void *mmap(void *addr, size_t Len, int prot, int flags, int fd, off_t off)
     int   munmap(void *addr, size_t Len)
     int   mprotect(void *addr, size_t Len, int prot)
@@ -46,17 +48,34 @@ cdef extern from "<sys/mman.h>" nogil:
     int   munlock(const void *addr, size_t Len)
     int   mlockall(int flags)
     int   munlockall()
+    # Linux-specific
+    enum: MLOCK_ONFAULT
+    enum: MCL_ONFAULT
+    int   mlock2(const void *addr, size_t len, int flags)
 
     int shm_open(const char *name, int oflag, mode_t mode)
     int shm_unlink(const char *name)
 
     # often available
-    enum: MADV_REMOVE               # pre-POSIX advice flags; often available
+    enum: MADV_NORMAL               # pre-POSIX advice flags; should translate 1-1 to POSIX_*
+    enum: MADV_RANDOM               # but in practice it is not always the same.
+    enum: MADV_SEQUENTIAL
+    enum: MADV_WILLNEED
+    enum: MADV_DONTNEED
+    enum: MADV_REMOVE               # other pre-POSIX advice flags; often available
     enum: MADV_DONTFORK
     enum: MADV_DOFORK
     enum: MADV_HWPOISON
     enum: MADV_MERGEABLE,
     enum: MADV_UNMERGEABLE
+    enum: MADV_SOFT_OFFLINE
+    enum: MADV_HUGEPAGE
+    enum: MADV_NOHUGEPAGE
+    enum: MADV_DONTDUMP
+    enum: MADV_DODUMP
+    enum: MADV_FREE
+    enum: MADV_WIPEONFORK
+    enum: MADV_KEEPONFORK
     int   madvise(void *addr, size_t Len, int advice)
 
     # sometimes available
index b7cea05619ad352d401bb1d857e111c7ee3ae998..b72467bc928d641338f95beec1d453c370453e6d 100644 (file)
@@ -1,7 +1,7 @@
 # cython.* namespace for pure mode.
 from __future__ import absolute_import
 
-__version__ = "0.29.12"
+__version__ = "0.29.13"
 
 try:
     from __builtin__ import basestring
index d03fddb8653c761c7dc15fb4e7f9aee859722b6c..930c2db70f0c669d7f3fd4715a704e81f4a00d89 100644 (file)
@@ -372,6 +372,10 @@ cdef class memoryview(object):
     def __dealloc__(memoryview self):
         if self.obj is not None:
             __Pyx_ReleaseBuffer(&self.view)
+        elif (<__pyx_buffer *> &self.view).obj == Py_None:
+            # Undo the incref in __cinit__() above.
+            (<__pyx_buffer *> &self.view).obj = NULL
+            Py_DECREF(Py_None)
 
         cdef int i
         global __pyx_memoryview_thread_locks_used
index a4ca02230eb39b3d3f985c0f7e00fcdb471190d9..15c71d481a4d1722596fc7cd2a3bf3c72ecf3395 100644 (file)
@@ -698,6 +698,16 @@ def assign_temporary_to_object(object[:] mslice):
     buf = mslice
     buf[1] = {3-2: 2+(2*4)-2}
 
+
+def test_pyview_of_memview(int[:] ints):
+    """
+    >>> A = IntMockBuffer(None, [1, 2, 3])
+    >>> len(test_pyview_of_memview(A))
+    3
+    """
+    return ints
+
+
 def test_generic_slicing(arg, indirect=False):
     """
     Test simple slicing
index db9af7446088b61431bf5e5832b762930401f15d..62100ed7f83bcc35bdc32b16270eaf8d8bc163e9 100644 (file)
@@ -2,6 +2,7 @@
 # tag: c-api
 
 from cpython cimport mem
+from cpython.pystate cimport PyGILState_Ensure, PyGILState_Release, PyGILState_STATE
 
 
 def test_pymalloc():
@@ -47,3 +48,17 @@ def test_pymalloc_raw():
             mem.PyMem_RawFree(m)
     assert m2
     return retval
+
+
+def test_gilstate():
+    """
+    >>> test_gilstate()
+    'ok'
+    """
+
+    # cython used to have invalid definition for PyGILState_STATE, which was
+    # making the following code fail to compile
+    cdef PyGILState_STATE gstate = PyGILState_Ensure()
+    # TODO assert that GIL is taken
+    PyGILState_Release(gstate)
+    return 'ok'