Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-cffi for openSUSE:Factory 
checked in at 2022-08-04 13:23:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-cffi (Old)
 and      /work/SRC/openSUSE:Factory/.python-cffi.new.1521 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-cffi"

Thu Aug  4 13:23:13 2022 rev:38 rq:990222 version:1.15.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-cffi/python-cffi.changes  2021-11-09 
23:54:19.431943861 +0100
+++ /work/SRC/openSUSE:Factory/.python-cffi.new.1521/python-cffi.changes        
2022-08-04 13:23:26.396494655 +0200
@@ -1,0 +2,9 @@
+Tue Jul 19 11:31:46 UTC 2022 - Dirk M??ller <[email protected]>
+
+- update to 1.15.1:
+  * If you call ffi.embedding_api() but don???t write any extern ???Python??? 
function
+    there, then the resulting C code would fail an assert. Fixed.
+  * Updated Windows/arm64 embedded libffi static lib to v3.4.2, and scripted to
+    ease future updates (thanks Niyas Sait!)
+
+-------------------------------------------------------------------

Old:
----
  cffi-1.15.0.tar.gz

New:
----
  cffi-1.15.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-cffi.spec ++++++
--- /var/tmp/diff_new_pack.VGPFI1/_old  2022-08-04 13:23:26.892496063 +0200
+++ /var/tmp/diff_new_pack.VGPFI1/_new  2022-08-04 13:23:26.896496074 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-cffi
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-cffi
-Version:        1.15.0
+Version:        1.15.1
 Release:        0
 Summary:        Foreign Function Interface for Python calling C code
 License:        MIT

++++++ cffi-1.15.0.tar.gz -> cffi-1.15.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/PKG-INFO new/cffi-1.15.1/PKG-INFO
--- old/cffi-1.15.0/PKG-INFO    2021-10-13 01:59:36.445747400 +0200
+++ new/cffi-1.15.1/PKG-INFO    2022-06-30 18:38:57.722142200 +0200
@@ -1,12 +1,11 @@
 Metadata-Version: 2.1
 Name: cffi
-Version: 1.15.0
+Version: 1.15.1
 Summary: Foreign Function Interface for Python calling C code.
 Home-page: http://cffi.readthedocs.org
 Author: Armin Rigo, Maciej Fijalkowski
 Author-email: [email protected]
 License: MIT
-Platform: UNKNOWN
 Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 2
 Classifier: Programming Language :: Python :: 2.7
@@ -32,5 +31,3 @@
 -------
 
 `Mailing list <https://groups.google.com/forum/#!forum/python-cffi>`_
-
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/c/_cffi_backend.c 
new/cffi-1.15.1/c/_cffi_backend.c
--- old/cffi-1.15.0/c/_cffi_backend.c   2021-10-13 01:59:28.000000000 +0200
+++ new/cffi-1.15.1/c/_cffi_backend.c   2022-06-30 18:38:43.000000000 +0200
@@ -2,7 +2,7 @@
 #include <Python.h>
 #include "structmember.h"
 
-#define CFFI_VERSION  "1.15.0"
+#define CFFI_VERSION  "1.15.1"
 
 #ifdef MS_WIN32
 #include <windows.h>
@@ -2197,7 +2197,7 @@
     }
 }
 
-static PyObject *cdataowning_repr(CDataObject *cd)
+static Py_ssize_t cdataowning_size_bytes(CDataObject *cd)
 {
     Py_ssize_t size = _cdata_var_byte_size(cd);
     if (size < 0) {
@@ -2208,6 +2208,12 @@
         else
             size = cd->c_type->ct_size;
     }
+    return size;
+}
+
+static PyObject *cdataowning_repr(CDataObject *cd)
+{
+    Py_ssize_t size = cdataowning_size_bytes(cd);
     return PyText_FromFormat("<cdata '%s' owning %zd bytes>",
                              cd->c_type->ct_name, size);
 }
@@ -4603,7 +4609,7 @@
            array      [ctype, length]
            funcptr    [ctresult, ellipsis+abi, num_args, ctargs...]
     */
-    PyObject *key, *y;
+    PyObject *key, *y, *res;
     void *pkey;
 
     key = PyBytes_FromStringAndSize(NULL, keylength * sizeof(void *));
@@ -4635,8 +4641,9 @@
     /* the 'value' in unique_cache doesn't count as 1, but don't use
        Py_DECREF(x) here because it will confuse debug builds into thinking
        there was an extra DECREF in total. */
-    ((PyObject *)x)->ob_refcnt--;
-    return (PyObject *)x;
+    res = (PyObject *)x;
+    Py_SET_REFCNT(res, Py_REFCNT(res) - 1);
+    return res;
 
  error:
     Py_DECREF(x);
@@ -5665,7 +5672,8 @@
     }
 }
 
-#define ALIGN_ARG(n)  ((n) + 7) & ~7
+#define ALIGN_TO(n, a)  ((n) + ((a)-1)) & ~((a)-1)
+#define ALIGN_ARG(n)    ALIGN_TO(n, 8)
 
 static int fb_build(struct funcbuilder_s *fb, PyObject *fargs,
                     CTypeDescrObject *fresult)
@@ -5690,10 +5698,12 @@
         /* exchange data size */
         /* first, enough room for an array of 'nargs' pointers */
         exchange_offset = nargs * sizeof(void*);
+        /* then enough room for the result --- which means at least
+           sizeof(ffi_arg), according to the ffi docs, but we also
+           align according to the result type, for issue #531 */
+        exchange_offset = ALIGN_TO(exchange_offset, fb->rtype->alignment);
         exchange_offset = ALIGN_ARG(exchange_offset);
         cif_descr->exchange_offset_arg[0] = exchange_offset;
-        /* then enough room for the result --- which means at least
-           sizeof(ffi_arg), according to the ffi docs */
         i = fb->rtype->size;
         if (i < (Py_ssize_t)sizeof(ffi_arg))
             i = sizeof(ffi_arg);
@@ -5721,6 +5731,7 @@
         if (fb->atypes != NULL) {
             fb->atypes[i] = atype;
             /* exchange data size */
+            exchange_offset = ALIGN_TO(exchange_offset, atype->alignment);
             exchange_offset = ALIGN_ARG(exchange_offset);
             cif_descr->exchange_offset_arg[1 + i] = exchange_offset;
             exchange_offset += atype->size;
@@ -5737,6 +5748,7 @@
 }
 
 #undef ALIGN_ARG
+#undef ALIGN_TO
 
 static void fb_cat_name(struct funcbuilder_s *fb, const char *piece,
                         int piecelen)
@@ -7010,12 +7022,14 @@
     /* this is the constructor of the type implemented in minibuffer.h */
     CDataObject *cd;
     Py_ssize_t size = -1;
+    int explicit_size;
     static char *keywords[] = {"cdata", "size", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|n:buffer", keywords,
                                      &CData_Type, &cd, &size))
         return NULL;
 
+    explicit_size = size >= 0;
     if (size < 0)
         size = _cdata_var_byte_size(cd);
 
@@ -7039,6 +7053,20 @@
                      cd->c_type->ct_name);
         return NULL;
     }
+
+    if (explicit_size && CDataOwn_Check(cd)) {
+        Py_ssize_t size_max = cdataowning_size_bytes(cd);
+        if (size > size_max) {
+            char msg[256];
+            sprintf(msg, "ffi.buffer(cdata, bytes): creating a buffer of %llu "
+                         "bytes over a cdata that owns only %llu bytes.  This "
+                         "will crash if you access the extra memory",
+                         (unsigned PY_LONG_LONG)size,
+                         (unsigned PY_LONG_LONG)size_max);
+            if (PyErr_WarnEx(PyExc_UserWarning, msg, 1))
+                return NULL;
+        }
+    }
     /*WRITE(cd->c_data, size)*/
     return minibuffer_new(cd->c_data, size, (PyObject *)cd);
 }
Binary files old/cffi-1.15.0/c/libffi_arm64/ffi.lib and 
new/cffi-1.15.1/c/libffi_arm64/ffi.lib differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/c/libffi_arm64/include/ffi.h 
new/cffi-1.15.1/c/libffi_arm64/include/ffi.h
--- old/cffi-1.15.0/c/libffi_arm64/include/ffi.h        2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/c/libffi_arm64/include/ffi.h        2022-06-30 
18:38:43.000000000 +0200
@@ -1,6 +1,7 @@
 /* -----------------------------------------------------------------*-C-*-
-   libffi 3.3-rc0 - Copyright (c) 2011, 2014 Anthony Green
-                    - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
+   libffi 3.4.2
+     - Copyright (c) 2011, 2014, 2019, 2021 Anthony Green
+     - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
 
    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation
@@ -217,7 +218,8 @@
 typedef enum {
   FFI_OK = 0,
   FFI_BAD_TYPEDEF,
-  FFI_BAD_ABI
+  FFI_BAD_ABI,
+  FFI_BAD_ARGTYPE
 } ffi_status;
 
 typedef struct {
@@ -269,7 +271,7 @@
 #endif
 
 
-FFI_API 
+FFI_API
 void ffi_raw_call (ffi_cif *cif,
                   void (*fn)(void),
                   void *rvalue,
@@ -288,15 +290,15 @@
 void ffi_java_raw_call (ffi_cif *cif,
                        void (*fn)(void),
                        void *rvalue,
-                       ffi_java_raw *avalue);
+                       ffi_java_raw *avalue) __attribute__((deprecated));
 #endif
 
 FFI_API
-void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw);
+void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) 
__attribute__((deprecated));
 FFI_API
-void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args);
+void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args) 
__attribute__((deprecated));
 FFI_API
-size_t ffi_java_raw_size (ffi_cif *cif);
+size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated));
 
 /* ---- Definitions for closures ----------------------------------------- */
 
@@ -310,7 +312,10 @@
   void *trampoline_table;
   void *trampoline_table_entry;
 #else
-  char tramp[FFI_TRAMPOLINE_SIZE];
+  union {
+    char tramp[FFI_TRAMPOLINE_SIZE];
+    void *ftramp;
+  };
 #endif
   ffi_cif   *cif;
   void     (*fun)(ffi_cif*,void*,void**,void*);
@@ -330,6 +335,14 @@
 FFI_API void *ffi_closure_alloc (size_t size, void **code);
 FFI_API void ffi_closure_free (void *);
 
+#if defined(PA_LINUX) || defined(PA_HPUX)
+#define FFI_CLOSURE_PTR(X) ((void *)((unsigned int)(X) | 2))
+#define FFI_RESTORE_PTR(X) ((void *)((unsigned int)(X) & ~3))
+#else
+#define FFI_CLOSURE_PTR(X) (X)
+#define FFI_RESTORE_PTR(X) (X)
+#endif
+
 FFI_API ffi_status
 ffi_prep_closure (ffi_closure*,
                  ffi_cif *,
@@ -363,8 +376,8 @@
 
 #if !FFI_NATIVE_RAW_API
 
-  /* If this is enabled, then a raw closure has the same layout 
-     as a regular closure.  We use this to install an intermediate 
+  /* If this is enabled, then a raw closure has the same layout
+     as a regular closure.  We use this to install an intermediate
      handler to do the transaltion, void** -> ffi_raw*.  */
 
   void     (*translate_args)(ffi_cif*,void*,void**,void*);
@@ -389,8 +402,8 @@
 
 #if !FFI_NATIVE_RAW_API
 
-  /* If this is enabled, then a raw closure has the same layout 
-     as a regular closure.  We use this to install an intermediate 
+  /* If this is enabled, then a raw closure has the same layout
+     as a regular closure.  We use this to install an intermediate
      handler to do the translation, void** -> ffi_raw*.  */
 
   void     (*translate_args)(ffi_cif*,void*,void**,void*);
@@ -421,14 +434,14 @@
 ffi_prep_java_raw_closure (ffi_java_raw_closure*,
                           ffi_cif *cif,
                           void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
-                          void *user_data);
+                          void *user_data) __attribute__((deprecated));
 
 FFI_API ffi_status
 ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,
                               ffi_cif *cif,
                               void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
                               void *user_data,
-                              void *codeloc);
+                              void *codeloc) __attribute__((deprecated));
 #endif
 
 #endif /* FFI_CLOSURES */
@@ -451,7 +464,7 @@
 
 /* ---- Public interface definition -------------------------------------- */
 
-FFI_API 
+FFI_API
 ffi_status ffi_prep_cif(ffi_cif *cif,
                        ffi_abi abi,
                        unsigned int nargs,
@@ -484,18 +497,18 @@
 #endif
 
 /* If these change, update src/mips/ffitarget.h. */
-#define FFI_TYPE_VOID       0    
+#define FFI_TYPE_VOID       0
 #define FFI_TYPE_INT        1
-#define FFI_TYPE_FLOAT      2    
+#define FFI_TYPE_FLOAT      2
 #define FFI_TYPE_DOUBLE     3
 #if 0
 #define FFI_TYPE_LONGDOUBLE 4
 #else
 #define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
 #endif
-#define FFI_TYPE_UINT8      5   
+#define FFI_TYPE_UINT8      5
 #define FFI_TYPE_SINT8      6
-#define FFI_TYPE_UINT16     7 
+#define FFI_TYPE_UINT16     7
 #define FFI_TYPE_SINT16     8
 #define FFI_TYPE_UINT32     9
 #define FFI_TYPE_SINT32     10
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/c/libffi_arm64/include/fficonfig.h 
new/cffi-1.15.1/c/libffi_arm64/include/fficonfig.h
--- old/cffi-1.15.0/c/libffi_arm64/include/fficonfig.h  2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/c/libffi_arm64/include/fficonfig.h  2022-06-30 
18:38:43.000000000 +0200
@@ -18,6 +18,9 @@
 /* Define this if you want extra debugging. */
 /* #undef FFI_DEBUG */
 
+/* Define this if you want statically defined trampolines */
+/* #undef FFI_EXEC_STATIC_TRAMP */
+
 /* Cannot use PROT_EXEC on this target, so, we revert to alternative means */
 /* #undef FFI_EXEC_TRAMPOLINE_TABLE */
 
@@ -77,12 +80,18 @@
 /* Define to 1 if you have the `memcpy' function. */
 /* #undef HAVE_MEMCPY */
 
+/* Define to 1 if you have the `memfd_create' function. */
+/* #undef HAVE_MEMFD_CREATE */
+
 /* Define to 1 if you have the <memory.h> header file. */
 #define HAVE_MEMORY_H 1
 
 /* Define to 1 if you have the `mkostemp' function. */
 /* #undef HAVE_MKOSTEMP */
 
+/* Define to 1 if you have the `mkstemp' function. */
+/* #undef HAVE_MKSTEMP */
+
 /* Define to 1 if you have the `mmap' function. */
 /* #undef HAVE_MMAP */
 
@@ -95,6 +104,9 @@
 /* Define if read-only mmap of a plain file works. */
 /* #undef HAVE_MMAP_FILE */
 
+/* Define if your compiler supports pointer authentication. */
+/* #undef HAVE_PTRAUTH */
+
 /* Define if .eh_frame sections should be read-only. */
 /* #undef HAVE_RO_EH_FRAME */
 
@@ -110,6 +122,9 @@
 /* Define to 1 if you have the <string.h> header file. */
 #define HAVE_STRING_H 1
 
+/* Define to 1 if you have the <sys/memfd.h> header file. */
+/* #undef HAVE_SYS_MEMFD_H */
+
 /* Define to 1 if you have the <sys/mman.h> header file. */
 /* #undef HAVE_SYS_MMAN_H */
 
@@ -138,7 +153,7 @@
 #define PACKAGE_NAME "libffi"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libffi 3.3-rc0"
+#define PACKAGE_STRING "libffi 3.4.2"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "libffi"
@@ -147,7 +162,7 @@
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "3.3-rc0"
+#define PACKAGE_VERSION "3.4.2"
 
 /* The size of `double', as computed by sizeof. */
 #define SIZEOF_DOUBLE 8
@@ -177,7 +192,7 @@
 /* #undef USING_PURIFY */
 
 /* Version number of package */
-#define VERSION "3.3-rc0"
+#define VERSION "3.4.2"
 
 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
    significant byte first (like Motorola and SPARC, unlike Intel). */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/c/libffi_arm64/include/ffitarget.h 
new/cffi-1.15.1/c/libffi_arm64/include/ffitarget.h
--- old/cffi-1.15.0/c/libffi_arm64/include/ffitarget.h  2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/c/libffi_arm64/include/ffitarget.h  2022-06-30 
18:38:43.000000000 +0200
@@ -32,7 +32,7 @@
 #define FFI_SIZEOF_JAVA_RAW  4
 typedef unsigned long long ffi_arg;
 typedef signed long long ffi_sarg;
-#elif defined(_M_ARM64)
+#elif defined(_WIN32)
 #define FFI_SIZEOF_ARG 8
 typedef unsigned long long ffi_arg;
 typedef signed long long ffi_sarg;
@@ -45,8 +45,13 @@
   {
     FFI_FIRST_ABI = 0,
     FFI_SYSV,
+    FFI_WIN64,
     FFI_LAST_ABI,
+#if defined(_WIN32)
+    FFI_DEFAULT_ABI = FFI_WIN64
+#else
     FFI_DEFAULT_ABI = FFI_SYSV
+#endif
   } ffi_abi;
 #endif
 
@@ -69,22 +74,22 @@
 #define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE
 #endif
 
-#ifdef _M_ARM64
+#ifdef _WIN32
 #define FFI_EXTRA_CIF_FIELDS unsigned is_variadic
 #endif
+#define FFI_TARGET_SPECIFIC_VARIADIC
 
 /* ---- Internal ---- */
 
 #if defined (__APPLE__)
-#define FFI_TARGET_SPECIFIC_VARIADIC
 #define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs
-#elif !defined(_M_ARM64)
+#elif !defined(_WIN32)
 /* iOS and Windows reserve x18 for the system.  Disable Go closures until
    a new static chain is chosen.  */
 #define FFI_GO_CLOSURES 1
 #endif
 
-#ifndef _M_ARM64
+#ifndef _WIN32
 /* No complex type on Windows */
 #define FFI_TARGET_HAS_COMPLEX_TYPE
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/c/test_c.py new/cffi-1.15.1/c/test_c.py
--- old/cffi-1.15.0/c/test_c.py 2021-10-13 01:59:28.000000000 +0200
+++ new/cffi-1.15.1/c/test_c.py 2022-06-30 18:38:43.000000000 +0200
@@ -1,5 +1,15 @@
 import py
 import pytest
+import sys
+
+is_musl = False
+if sys.platform == 'linux':
+    try:
+        from packaging.tags import platform_tags
+        is_musl = any(t.startswith('musllinux') for t in platform_tags())
+        del platform_tags
+    except ImportError:
+        pass
 
 def _setup_path():
     import os, sys
@@ -17,7 +27,7 @@
 # ____________________________________________________________
 
 import sys
-assert __version__ == "1.15.0", ("This test_c.py file is for testing a version"
+assert __version__ == "1.15.1", ("This test_c.py file is for testing a version"
                                  " of cffi that differs from the one that we"
                                  " get from 'import _cffi_backend'")
 if sys.version_info < (3,):
@@ -93,7 +103,8 @@
     if sys.platform.startswith("linux"):
         RTLD_NODELETE
         RTLD_NOLOAD
-        RTLD_DEEPBIND
+        if not is_musl:
+            RTLD_DEEPBIND
 
 def test_new_primitive_type():
     py.test.raises(KeyError, new_primitive_type, "foo")
@@ -1296,7 +1307,7 @@
 def test_write_variable():
     ## FIXME: this test assumes glibc specific behavior, it's not compliant 
with C standard
     ## https://bugs.pypy.org/issue1643
-    if not sys.platform.startswith("linux"):
+    if not sys.platform.startswith("linux") or is_musl:
         py.test.skip("untested")
     BVoidP = new_pointer_type(new_void_type())
     ll = find_and_load_library('c')
@@ -1331,9 +1342,11 @@
     except ImportError:
         import io as cStringIO    # Python 3
     import linecache
-    def matches(istr, ipattern, ipattern38):
+    def matches(istr, ipattern, ipattern38, ipattern311):
         if sys.version_info >= (3, 8):
             ipattern = ipattern38
+        if sys.version_info >= (3, 11):
+            ipattern = ipattern311
         str, pattern = istr, ipattern
         while '$' in pattern:
             i = pattern.index('$')
@@ -1387,6 +1400,16 @@
   File "$", line $, in check_value
     $
 ValueError: 42
+""", """\
+Exception ignored from cffi callback <function$Zcb1 at 0x$>:
+Traceback (most recent call last):
+  File "$", line $, in Zcb1
+    $
+    $
+  File "$", line $, in check_value
+    $
+    $
+ValueError: 42
 """)
         sys.stderr = cStringIO.StringIO()
         bigvalue = 20000
@@ -1401,6 +1424,13 @@
   File "$", line $, in test_callback_exception
     $
 OverflowError: integer 60000 does not fit 'short'
+""", """\
+Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert 
the result back to C:
+Traceback (most recent call last):
+  File "$", line $, in test_callback_exception
+    $
+    $
+OverflowError: integer 60000 does not fit 'short'
 """)
         sys.stderr = cStringIO.StringIO()
         bigvalue = 20000
@@ -1449,6 +1479,19 @@
   File "$", line $, in test_callback_exception
     $
 TypeError: $integer$
+""", """\
+Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert 
the result back to C:
+Traceback (most recent call last):
+  File "$", line $, in test_callback_exception
+    $
+    $
+OverflowError: integer 60000 does not fit 'short'
+Exception ignored during handling of the above exception by 'onerror':
+Traceback (most recent call last):
+  File "$", line $, in test_callback_exception
+    $
+    $
+TypeError: $integer$
 """)
         #
         sys.stderr = cStringIO.StringIO()
@@ -1478,6 +1521,19 @@
   File "$", line $, in oops
     $
 AttributeError: 'str' object has no attribute 'append$
+""", """\
+Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert 
the result back to C:
+Traceback (most recent call last):
+  File "$", line $, in test_callback_exception
+    $
+    $
+OverflowError: integer 60000 does not fit 'short'
+Exception ignored during handling of the above exception by 'onerror':
+Traceback (most recent call last):
+  File "$", line $, in oops
+    $
+    $
+AttributeError: 'str' object has no attribute 'append$
 """)
     finally:
         sys.stderr = orig_stderr
@@ -3453,6 +3509,18 @@
     _test_bitfield_details(flag=SF_GCC_X86_BITFIELDS|SF_GCC_BIG_ENDIAN)
 
 
+def buffer_warning(cdata):
+    import warnings
+    buf = buffer(cdata)
+    bytes = len(buf)
+    with warnings.catch_warnings(record=True) as w:
+        warnings.simplefilter("always")
+        buffer(cdata, bytes)
+        assert len(w) == 0
+        buffer(cdata, bytes + 1)
+        assert len(w) <= 1
+        return len(w) == 1
+
 def test_struct_array_no_length():
     BInt = new_primitive_type("int")
     BIntP = new_pointer_type(BInt)
@@ -3567,6 +3635,7 @@
     assert p.a[1] == 20
     assert p.a[2] == 30
     assert p.a[3] == 0
+    assert buffer_warning(p)
     #
     # struct of struct of varsized array
     BStruct2 = new_struct_type("bar")
@@ -3575,6 +3644,20 @@
     for i in range(2):   # try to detect heap overwrites
         p = newp(new_pointer_type(BStruct2), [100, [200, list(range(50))]])
         assert p.tail.y[49] == 49
+    assert buffer_warning(p)
+    assert not buffer_warning(cast(new_pointer_type(BStruct2), p))
+    assert not buffer_warning(cast(BIntP, p))
+
+def test_more_buffer_warning():
+    BChar = new_primitive_type("unsigned char")
+    BCharP = new_pointer_type(BChar)
+    BArray = new_array_type(BCharP, 10)   # char[10]
+    p = newp(BArray)
+    assert buffer_warning(p)
+    assert not buffer_warning(cast(BCharP, p))
+    p = newp(BCharP)
+    assert buffer_warning(p)
+    assert not buffer_warning(cast(BCharP, p))
 
 
 def test_struct_array_no_length_explicit_position():
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/cffi/__init__.py 
new/cffi-1.15.1/cffi/__init__.py
--- old/cffi-1.15.0/cffi/__init__.py    2021-10-13 01:59:28.000000000 +0200
+++ new/cffi-1.15.1/cffi/__init__.py    2022-06-30 18:38:43.000000000 +0200
@@ -5,8 +5,8 @@
 from .error import CDefError, FFIError, VerificationError, VerificationMissing
 from .error import PkgConfigError
 
-__version__ = "1.15.0"
-__version_info__ = (1, 15, 0)
+__version__ = "1.15.1"
+__version_info__ = (1, 15, 1)
 
 # The verifier module file names are based on the CRC32 of a string that
 # contains the following version number.  It may be older than __version__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/cffi/_embedding.h 
new/cffi-1.15.1/cffi/_embedding.h
--- old/cffi-1.15.0/cffi/_embedding.h   2021-10-13 01:59:28.000000000 +0200
+++ new/cffi-1.15.1/cffi/_embedding.h   2022-06-30 18:38:43.000000000 +0200
@@ -22,7 +22,8 @@
 
    * _cffi_call_python_org, which on CPython is actually part of the
      _cffi_exports[] array, is the function pointer copied from
-     _cffi_backend.
+     _cffi_backend.  If _cffi_start_python() fails, then this is set
+     to NULL; otherwise, it should never be NULL.
 
    After initialization is complete, both are equal.  However, the
    first one remains equal to &_cffi_start_and_call_python until the
@@ -224,7 +225,7 @@
 
         if (f != NULL && f != Py_None) {
             PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
-                               "\ncompiled with cffi version: 1.15.0"
+                               "\ncompiled with cffi version: 1.15.1"
                                "\n_cffi_backend module: ", f);
             modules = PyImport_GetModuleDict();
             mod = PyDict_GetItemString(modules, "_cffi_backend");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/cffi/recompiler.py 
new/cffi-1.15.1/cffi/recompiler.py
--- old/cffi-1.15.0/cffi/recompiler.py  2021-10-13 01:59:28.000000000 +0200
+++ new/cffi-1.15.1/cffi/recompiler.py  2022-06-30 18:38:43.000000000 +0200
@@ -407,7 +407,7 @@
             prnt('  NULL,  /* no includes */')
         prnt('  %d,  /* num_types */' % (len(self.cffi_types),))
         flags = 0
-        if self._num_externpy:
+        if self._num_externpy > 0 or self.ffi._embedding is not None:
             flags |= 1     # set to mean that we use extern "Python"
         prnt('  %d,  /* flags */' % flags)
         prnt('};')
@@ -422,7 +422,7 @@
         prnt('PyMODINIT_FUNC')
         prnt('_cffi_pypyinit_%s(const void *p[])' % (base_module_name,))
         prnt('{')
-        if self._num_externpy:
+        if flags & 1:
             prnt('    if (((intptr_t)p[0]) >= 0x0A03) {')
             prnt('        _cffi_call_python_org = '
                  '(void(*)(struct _cffi_externpy_s *, char *))p[1];')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/cffi.egg-info/PKG-INFO 
new/cffi-1.15.1/cffi.egg-info/PKG-INFO
--- old/cffi-1.15.0/cffi.egg-info/PKG-INFO      2021-10-13 01:59:36.000000000 
+0200
+++ new/cffi-1.15.1/cffi.egg-info/PKG-INFO      2022-06-30 18:38:57.000000000 
+0200
@@ -1,12 +1,11 @@
 Metadata-Version: 2.1
 Name: cffi
-Version: 1.15.0
+Version: 1.15.1
 Summary: Foreign Function Interface for Python calling C code.
 Home-page: http://cffi.readthedocs.org
 Author: Armin Rigo, Maciej Fijalkowski
 Author-email: [email protected]
 License: MIT
-Platform: UNKNOWN
 Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 2
 Classifier: Programming Language :: Python :: 2.7
@@ -32,5 +31,3 @@
 -------
 
 `Mailing list <https://groups.google.com/forum/#!forum/python-cffi>`_
-
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/cffi.egg-info/SOURCES.txt 
new/cffi-1.15.1/cffi.egg-info/SOURCES.txt
--- old/cffi-1.15.0/cffi.egg-info/SOURCES.txt   2021-10-13 01:59:36.000000000 
+0200
+++ new/cffi-1.15.1/cffi.egg-info/SOURCES.txt   2022-06-30 18:38:57.000000000 
+0200
@@ -176,6 +176,7 @@
 testing/embedding/add3.py
 testing/embedding/add_recursive-test.c
 testing/embedding/add_recursive.py
+testing/embedding/empty-test.c
 testing/embedding/empty.py
 testing/embedding/initerror.py
 testing/embedding/perf-test.c
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/cffi.egg-info/entry_points.txt 
new/cffi-1.15.1/cffi.egg-info/entry_points.txt
--- old/cffi-1.15.0/cffi.egg-info/entry_points.txt      2021-10-13 
01:59:36.000000000 +0200
+++ new/cffi-1.15.1/cffi.egg-info/entry_points.txt      2022-06-30 
18:38:57.000000000 +0200
@@ -1,3 +1,2 @@
 [distutils.setup_keywords]
 cffi_modules = cffi.setuptools_ext:cffi_modules
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/doc/source/conf.py 
new/cffi-1.15.1/doc/source/conf.py
--- old/cffi-1.15.0/doc/source/conf.py  2021-10-13 01:59:28.000000000 +0200
+++ new/cffi-1.15.1/doc/source/conf.py  2022-06-30 18:38:43.000000000 +0200
@@ -47,7 +47,7 @@
 # The short X.Y version.
 version = '1.15'
 # The full version, including alpha/beta/rc tags.
-release = '1.15.0'
+release = '1.15.1'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/doc/source/installation.rst 
new/cffi-1.15.1/doc/source/installation.rst
--- old/cffi-1.15.0/doc/source/installation.rst 2021-10-13 01:59:28.000000000 
+0200
+++ new/cffi-1.15.1/doc/source/installation.rst 2022-06-30 18:38:43.000000000 
+0200
@@ -52,7 +52,7 @@
 
 * https://pypi.python.org/pypi/cffi
 
-* Checksums of the "source" package version 1.15.0:
+* Checksums of the "source" package version 1.15.1:
 
    - MD5: ...
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/doc/source/overview.rst 
new/cffi-1.15.1/doc/source/overview.rst
--- old/cffi-1.15.0/doc/source/overview.rst     2021-10-13 01:59:28.000000000 
+0200
+++ new/cffi-1.15.1/doc/source/overview.rst     2022-06-30 18:38:43.000000000 
+0200
@@ -15,7 +15,12 @@
 
 Make sure you have `cffi installed`__.
 
+You can find these and some other complete demos in the demo__ directory
+of the repository__.
+
 .. __: installation.html
+.. __: https://foss.heptapod.net/pypy/cffi/-/tree/branch/default/demo
+.. __: https://foss.heptapod.net/pypy/cffi
 
 .. _out-of-line-api-level:
 .. _real-example:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/doc/source/ref.rst 
new/cffi-1.15.1/doc/source/ref.rst
--- old/cffi-1.15.0/doc/source/ref.rst  2021-10-13 01:59:28.000000000 +0200
+++ new/cffi-1.15.1/doc/source/ref.rst  2022-06-30 18:38:43.000000000 +0200
@@ -846,20 +846,35 @@
    argument is identical to a ``item[]`` argument (and ``ffi.cdef()``
    doesn't record the difference).  So when you call such a function,
    you can pass an argument that is accepted by either C type, like
-   for example passing a Python string to a ``char *`` argument
+   for example passing a Python byte string to a ``char *`` argument
    (because it works for ``char[]`` arguments) or a list of integers
    to a ``int *`` argument (it works for ``int[]`` arguments).  Note
    that even if you want to pass a single ``item``, you need to
    specify it in a list of length 1; for example, a ``struct point_s
    *`` argument might be passed as ``[[x, y]]`` or ``[{'x': 5, 'y':
-   10}]``.
+   10}]``.  In all these cases (including passing a byte string to
+   a ``char *`` argument), the required C data structure is created
+   just before the call is done, and freed afterwards.
 
    As an optimization, CFFI assumes that a
-   function with a ``char *`` argument to which you pass a Python
+   function with a ``char *`` argument to which you pass a Python byte
    string will not actually modify the array of characters passed in,
-   and so passes directly a pointer inside the Python string object.
+   and so it attempts to pass directly a pointer inside the Python
+   byte string object.  This still doesn't mean that the ``char *``
+   argument can be stored by the C function and inspected later.
+   The ``char *`` is only valid for the duration of the call, even if
+   the Python object is kept alive for longer.
    (On PyPy, this optimization is only available since PyPy 5.4
-   with CFFI 1.8.)
+   with CFFI 1.8.  It may fail in rare cases and fall back to making
+   a copy anyway, but only for short strings so it shouldn't be
+   noticeable.)
+
+   If you need to pass a ``char *`` that must be valid for longer than
+   just the call, you need to build it explicitly, either with ``p =
+   ffi.new("char[]", mystring)`` (which makes a copy) or by not using a
+   byte string in the first place but something else like a buffer object,
+   or a bytearray and ``ffi.from_buffer()``; or just use
+   ``ffi.new("char[]", length)`` directly if possible.
 
 `[2]` C function calls are done with the GIL released.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/doc/source/using.rst 
new/cffi-1.15.1/doc/source/using.rst
--- old/cffi-1.15.0/doc/source/using.rst        2021-10-13 01:59:28.000000000 
+0200
+++ new/cffi-1.15.1/doc/source/using.rst        2022-06-30 18:38:43.000000000 
+0200
@@ -383,6 +383,18 @@
 
     assert lib.strlen("hello") == 5
 
+(Note that there is no guarantee that the ``char *`` passed to the
+function remains valid after the call is done.  Similarly, if you write
+``lib.f(x); lib.f(x)`` where ``x`` is a variable containing a byte string,
+the two calls to ``f()`` could sometimes receive different ``char *``
+pointers, with each of them only valid during the corresponding call.  This is
+important notably for PyPy which uses many optimizations tweaking the data
+underlying a byte string object.  CFFI will not make and free a copy of
+the whole string at *every* call---it usually won't---but you *cannot*
+write code that relies on it: there are cases were that would break.
+If you need a pointer to remain valid, you need to make one explicitly,
+for example with ``ptr = ffi.new("char[]", x)``.)
+
 You can also pass unicode strings as ``wchar_t *`` or ``char16_t *`` or
 ``char32_t *`` arguments.  Note that
 the C language makes no difference between argument declarations that
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/doc/source/whatsnew.rst 
new/cffi-1.15.1/doc/source/whatsnew.rst
--- old/cffi-1.15.0/doc/source/whatsnew.rst     2021-10-13 01:59:28.000000000 
+0200
+++ new/cffi-1.15.1/doc/source/whatsnew.rst     2022-06-30 18:38:43.000000000 
+0200
@@ -2,6 +2,15 @@
 What's New
 ======================
 
+v1.15.1
+=======
+
+* If you call `ffi.embedding_api()` but don't write any `extern "Python"`
+  function there, then the resulting C code would fail an assert.  Fixed.
+
+* Updated Windows/arm64 embedded libffi static lib to v3.4.2, and scripted
+  to ease future updates (thanks Niyas Sait!)
+
 v1.15.0
 =======
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/setup.py new/cffi-1.15.1/setup.py
--- old/cffi-1.15.0/setup.py    2021-10-13 01:59:28.000000000 +0200
+++ new/cffi-1.15.1/setup.py    2022-06-30 18:38:43.000000000 +0200
@@ -11,7 +11,7 @@
 libraries = ['ffi']
 include_dirs = ['/usr/include/ffi',
                 '/usr/include/libffi']    # may be changed by pkg-config
-define_macros = []
+define_macros = [('FFI_BUILDING', '1')]   # for linking with libffi static 
library
 library_dirs = []
 extra_compile_args = []
 extra_link_args = []
@@ -156,6 +156,11 @@
     include_dirs.append('/usr/local/include')
     library_dirs.append('/usr/local/lib')
 
+forced_extra_objs = os.environ.get('CFFI_FORCE_STATIC', [])
+if forced_extra_objs:
+    forced_extra_objs = forced_extra_objs.split(';')
+
+
 if __name__ == '__main__':
     from setuptools import setup, Distribution, Extension
 
@@ -186,7 +191,7 @@
 
 `Mailing list <https://groups.google.com/forum/#!forum/python-cffi>`_
 """,
-        version='1.15.0',
+        version='1.15.1',
         packages=['cffi'] if cpython else [],
         package_data={'cffi': ['_cffi_include.h', 'parse_c_type.h', 
                                '_embedding.h', '_cffi_errors.h']}
@@ -209,6 +214,7 @@
             library_dirs=library_dirs,
             extra_compile_args=extra_compile_args,
             extra_link_args=extra_link_args,
+            extra_objects=forced_extra_objs,
         )] if cpython else [],
 
         install_requires=[
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/cffi0/test_function.py 
new/cffi-1.15.1/testing/cffi0/test_function.py
--- old/cffi-1.15.0/testing/cffi0/test_function.py      2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/testing/cffi0/test_function.py      2022-06-30 
18:38:43.000000000 +0200
@@ -5,7 +5,7 @@
 import ctypes.util
 from cffi.backend_ctypes import CTypesBackend
 from testing.udir import udir
-from testing.support import FdWriteCapture, StdErrCapture
+from testing.support import FdWriteCapture, StdErrCapture, is_musl
 from .backend_tests import needs_dlopen_none
 
 try:
@@ -13,6 +13,12 @@
 except ImportError:
     from io import StringIO
 
+try:
+    from packaging.tags import platform_tags
+    _platform_tags_cached = set(platform_tags())
+    _is_musl = any(t.startswith('musllinux') for t in _platform_tags_cached)
+except ImportError:
+    _is_musl = False
 
 lib_m = 'm'
 if sys.platform == 'win32':
@@ -20,6 +26,8 @@
     import distutils.ccompiler
     if distutils.ccompiler.get_default_compiler() == 'msvc':
         lib_m = 'msvcrt'
+elif is_musl:
+    lib_m = 'c'
 
 class TestFunction(object):
     Backend = CTypesBackend
@@ -165,11 +173,15 @@
                           ffi.cast("long long", 168))
             ffi.C.fprintf(ffi.C.stderr, b"hello %p\n", ffi.NULL)
         res = fd.getvalue()
+        if is_musl:
+            nil_repr = b'0'
+        else:
+            nil_repr = b'(nil)'
         assert res == (b"hello with no arguments\n"
                        b"hello, world!\n"
                        b"hello, world2!\n"
                        b"hello int 42 long 84 long long 168\n"
-                       b"hello (nil)\n")
+                       b"hello " + nil_repr + b"\n")
 
     def test_must_specify_type_of_vararg(self):
         ffi = FFI(backend=self.Backend())
@@ -265,7 +277,7 @@
         assert res == 5
 
     def test_write_variable(self):
-        if not sys.platform.startswith('linux'):
+        if not sys.platform.startswith('linux') or _is_musl:
             py.test.skip("probably no symbol 'stdout' in the lib")
         ffi = FFI(backend=self.Backend())
         ffi.cdef("""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/cffi0/test_ownlib.py 
new/cffi-1.15.1/testing/cffi0/test_ownlib.py
--- old/cffi-1.15.0/testing/cffi0/test_ownlib.py        2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/testing/cffi0/test_ownlib.py        2022-06-30 
18:38:43.000000000 +0200
@@ -2,7 +2,7 @@
 import subprocess, weakref
 from cffi import FFI
 from cffi.backend_ctypes import CTypesBackend
-from testing.support import u
+from testing.support import u, is_musl
 
 
 SOURCE = """\
@@ -388,7 +388,7 @@
     def test_dlopen_handle(self):
         if self.module is None:
             py.test.skip("fix the auto-generation of the tiny test lib")
-        if sys.platform == 'win32':
+        if sys.platform == 'win32' or is_musl:
             py.test.skip("uses 'dl' explicitly")
         if self.__class__.Backend is CTypesBackend:
             py.test.skip("not for the ctypes backend")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/cffi0/test_parsing.py 
new/cffi-1.15.1/testing/cffi0/test_parsing.py
--- old/cffi-1.15.0/testing/cffi0/test_parsing.py       2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/testing/cffi0/test_parsing.py       2022-06-30 
18:38:43.000000000 +0200
@@ -1,6 +1,7 @@
 import py, sys, re
 from cffi import FFI, FFIError, CDefError, VerificationError
 from .backend_tests import needs_dlopen_none
+from testing.support import is_musl
 
 
 class FakeBackend(object):
@@ -80,6 +81,9 @@
     import distutils.ccompiler
     if distutils.ccompiler.get_default_compiler() == 'msvc':
         lib_m = 'msvcrt'
+elif is_musl:
+    lib_m = 'c'
+
 
 def test_simple():
     ffi = FFI(backend=FakeBackend())
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/cffi0/test_unicode_literals.py 
new/cffi-1.15.1/testing/cffi0/test_unicode_literals.py
--- old/cffi-1.15.0/testing/cffi0/test_unicode_literals.py      2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/testing/cffi0/test_unicode_literals.py      2022-06-30 
18:38:43.000000000 +0200
@@ -9,6 +9,8 @@
 #
 import sys, math
 from cffi import FFI
+from testing.support import is_musl
+
 
 lib_m = "m"
 if sys.platform == 'win32':
@@ -16,6 +18,8 @@
     import distutils.ccompiler
     if distutils.ccompiler.get_default_compiler() == 'msvc':
         lib_m = 'msvcrt'
+elif is_musl:
+    lib_m = 'c'
 
 
 def test_cast():
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/cffi0/test_verify.py 
new/cffi-1.15.1/testing/cffi0/test_verify.py
--- old/cffi-1.15.0/testing/cffi0/test_verify.py        2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/testing/cffi0/test_verify.py        2022-06-30 
18:38:43.000000000 +0200
@@ -3,7 +3,7 @@
 import sys, os, math, weakref
 from cffi import FFI, VerificationError, VerificationMissing, model, FFIError
 from testing.support import *
-from testing.support import extra_compile_args
+from testing.support import extra_compile_args, is_musl
 
 
 lib_m = ['m']
@@ -1609,7 +1609,7 @@
     assert func() == 42
 
 def test_FILE_stored_in_stdout():
-    if not sys.platform.startswith('linux'):
+    if not sys.platform.startswith('linux') or is_musl:
         py.test.skip("likely, we cannot assign to stdout")
     ffi = FFI()
     ffi.cdef("int printf(const char *, ...); FILE *setstdout(FILE *);")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/cffi1/test_cffi_binary.py 
new/cffi-1.15.1/testing/cffi1/test_cffi_binary.py
--- old/cffi-1.15.0/testing/cffi1/test_cffi_binary.py   2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/testing/cffi1/test_cffi_binary.py   2022-06-30 
18:38:43.000000000 +0200
@@ -1,10 +1,11 @@
 import py, sys, os
 import _cffi_backend
+from testing.support import is_musl
 
 def test_no_unknown_exported_symbols():
     if not hasattr(_cffi_backend, '__file__'):
         py.test.skip("_cffi_backend module is built-in")
-    if not sys.platform.startswith('linux'):
+    if not sys.platform.startswith('linux') or is_musl:
         py.test.skip("linux-only")
     g = os.popen("objdump -T '%s'" % _cffi_backend.__file__, 'r')
     for line in g:
@@ -17,6 +18,9 @@
         name = line.split()[-1]
         if name.startswith('_') or name.startswith('.'):
             continue
-        if name not in ('init_cffi_backend', 'PyInit__cffi_backend'):
+        # a statically-linked libffi will always appear here without header 
hackage, ignore it if it's internal
+        if name.startswith('ffi_') and 'Base' in line:
+            continue
+        if name not in ('init_cffi_backend', 'PyInit__cffi_backend', 
'cffistatic_ffi_call'):
             raise Exception("Unexpected exported name %r" % (name,))
     g.close()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/cffi1/test_re_python.py 
new/cffi-1.15.1/testing/cffi1/test_re_python.py
--- old/cffi-1.15.0/testing/cffi1/test_re_python.py     2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/testing/cffi1/test_re_python.py     2022-06-30 
18:38:43.000000000 +0200
@@ -3,7 +3,7 @@
 from cffi import FFI
 from cffi import recompiler, ffiplatform, VerificationMissing
 from testing.udir import udir
-from testing.support import u
+from testing.support import u, is_musl
 
 
 def setup_module(mod):
@@ -269,7 +269,7 @@
 def test_dlopen_handle():
     import _cffi_backend
     from re_python_pysrc import ffi
-    if sys.platform == 'win32':
+    if sys.platform == 'win32' or is_musl:
         py.test.skip("uses 'dl' explicitly")
     ffi1 = FFI()
     ffi1.cdef("""void *dlopen(const char *filename, int flags);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/cffi1/test_verify1.py 
new/cffi-1.15.1/testing/cffi1/test_verify1.py
--- old/cffi-1.15.0/testing/cffi1/test_verify1.py       2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/testing/cffi1/test_verify1.py       2022-06-30 
18:38:43.000000000 +0200
@@ -4,7 +4,7 @@
 from cffi import CDefError
 from cffi import recompiler
 from testing.support import *
-from testing.support import _verify, extra_compile_args
+from testing.support import _verify, extra_compile_args, is_musl
 import _cffi_backend
 
 lib_m = ['m']
@@ -1571,7 +1571,7 @@
     assert func() == 42
 
 def test_FILE_stored_in_stdout():
-    if not sys.platform.startswith('linux'):
+    if not sys.platform.startswith('linux') or is_musl:
         py.test.skip("likely, we cannot assign to stdout")
     ffi = FFI()
     ffi.cdef("int printf(const char *, ...); FILE *setstdout(FILE *);")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/embedding/empty-test.c 
new/cffi-1.15.1/testing/embedding/empty-test.c
--- old/cffi-1.15.0/testing/embedding/empty-test.c      1970-01-01 
01:00:00.000000000 +0100
+++ new/cffi-1.15.1/testing/embedding/empty-test.c      2022-06-30 
18:38:43.000000000 +0200
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+void initialize_my_empty_cffi(void);
+
+int main(void)
+{
+    initialize_my_empty_cffi();
+    printf("OK\n");
+    return 0;
+}
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/embedding/empty.py 
new/cffi-1.15.1/testing/embedding/empty.py
--- old/cffi-1.15.0/testing/embedding/empty.py  2021-10-13 01:59:28.000000000 
+0200
+++ new/cffi-1.15.1/testing/embedding/empty.py  2022-06-30 18:38:43.000000000 
+0200
@@ -4,7 +4,14 @@
 
 ffi.embedding_api("")
 
-ffi.set_source("_empty_cffi", "")
+ffi.set_source("_empty_cffi", """
+void initialize_my_empty_cffi(void) {
+    if (cffi_start_python() != 0) {
+        printf("oops, cffi_start_python() returned non-0\\n");
+        abort();
+    }
+}
+""")
 
 fn = ffi.compile(verbose=True)
 print('FILENAME: %s' % (fn,))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/embedding/test_basic.py 
new/cffi-1.15.1/testing/embedding/test_basic.py
--- old/cffi-1.15.0/testing/embedding/test_basic.py     2021-10-13 
01:59:28.000000000 +0200
+++ new/cffi-1.15.1/testing/embedding/test_basic.py     2022-06-30 
18:38:43.000000000 +0200
@@ -180,6 +180,9 @@
 class TestBasic(EmbeddingTests):
     def test_empty(self):
         empty_cffi = self.prepare_module('empty')
+        self.compile('empty-test', [empty_cffi])
+        output = self.execute('empty-test')
+        assert output == 'OK\n'
 
     def test_basic(self):
         add1_cffi = self.prepare_module('add1')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cffi-1.15.0/testing/support.py 
new/cffi-1.15.1/testing/support.py
--- old/cffi-1.15.0/testing/support.py  2021-10-13 01:59:28.000000000 +0200
+++ new/cffi-1.15.1/testing/support.py  2022-06-30 18:38:43.000000000 +0200
@@ -117,3 +117,12 @@
         extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion',
                               '-Wno-unused-parameter',
                               '-Wno-unreachable-code']
+
+is_musl = False
+if sys.platform == 'linux':
+    try:
+        from packaging.tags import platform_tags
+        is_musl = any(t.startswith('musllinux') for t in platform_tags())
+        del platform_tags
+    except ImportError:
+        pass

Reply via email to