Author: Armin Rigo <[email protected]>
Branch: release-1.0
Changeset: r2086:da5b4cdae2ad
Date: 2015-05-22 12:57 +0200
http://bitbucket.org/cffi/cffi/changeset/da5b4cdae2ad/
Log: hg merge default
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -6050,7 +6050,7 @@
if (v == NULL || PyModule_AddObject(m, "_C_API", v) < 0)
INITERROR;
- v = PyText_FromString("1.0.1");
+ v = PyText_FromString("1.0.2");
if (v == NULL || PyModule_AddObject(m, "__version__", v) < 0)
INITERROR;
diff --git a/c/misc_win32.h b/c/misc_win32.h
--- a/c/misc_win32.h
+++ b/c/misc_win32.h
@@ -218,7 +218,7 @@
static int dlclose(void *handle)
{
- return !FreeLibrary((HMODULE)handle);
+ return FreeLibrary((HMODULE)handle) ? 0 : -1;
}
static const char *dlerror(void)
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -3346,4 +3346,4 @@
def test_version():
# this test is here mostly for PyPy
- assert __version__ == "1.0.1"
+ assert __version__ == "1.0.2"
diff --git a/cffi/__init__.py b/cffi/__init__.py
--- a/cffi/__init__.py
+++ b/cffi/__init__.py
@@ -4,8 +4,8 @@
from .api import FFI, CDefError, FFIError
from .ffiplatform import VerificationError, VerificationMissing
-__version__ = "1.0.1"
-__version_info__ = (1, 0, 1)
+__version__ = "1.0.2"
+__version_info__ = (1, 0, 2)
# 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 --git a/cffi/_cffi_include.h b/cffi/_cffi_include.h
--- a/cffi/_cffi_include.h
+++ b/cffi/_cffi_include.h
@@ -1,3 +1,4 @@
+#define _CFFI_
#include <Python.h>
#ifdef __cplusplus
extern "C" {
@@ -6,7 +7,8 @@
#include "parse_c_type.h"
/* this block of #ifs should be kept exactly identical between
- c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py */
+ c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py
+ and cffi/_cffi_include.h */
#if defined(_MSC_VER)
# include <malloc.h> /* for alloca() */
# if _MSC_VER < 1600 /* MSVC < 2010 */
diff --git a/cffi/parse_c_type.h b/cffi/parse_c_type.h
--- a/cffi/parse_c_type.h
+++ b/cffi/parse_c_type.h
@@ -1,5 +1,5 @@
-/* See doc/parse_c_type.rst in the source of CFFI for more information */
+/* See doc/misc/parse_c_type.rst in the source of CFFI for more information */
typedef void *_cffi_opcode_t;
diff --git a/cffi/recompiler.py b/cffi/recompiler.py
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -581,10 +581,11 @@
def _generate_cpy_function_collecttype(self, tp, name):
self._do_collect_type(tp.as_raw_function())
- if tp.ellipsis:
+ if tp.ellipsis and not self.target_is_python:
self._do_collect_type(tp)
def _generate_cpy_function_decl(self, tp, name):
+ assert not self.target_is_python
assert isinstance(tp, model.FunctionPtrType)
if tp.ellipsis:
# cannot support vararg functions better than this: check for its
@@ -702,7 +703,7 @@
prnt()
def _generate_cpy_function_ctx(self, tp, name):
- if tp.ellipsis:
+ if tp.ellipsis and not self.target_is_python:
self._generate_cpy_constant_ctx(tp, name)
return
type_index = self._typesdict[tp.as_raw_function()]
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -47,7 +47,7 @@
# The short X.Y version.
version = '1.0'
# The full version, including alpha/beta/rc tags.
-release = '1.0.1'
+release = '1.0.2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/doc/source/installation.rst b/doc/source/installation.rst
--- a/doc/source/installation.rst
+++ b/doc/source/installation.rst
@@ -51,13 +51,13 @@
Download and Installation:
-* http://pypi.python.org/packages/source/c/cffi/cffi-1.0.1.tar.gz
+* http://pypi.python.org/packages/source/c/cffi/cffi-1.0.2.tar.gz
- Or grab the most current version by following the instructions below.
- - MD5: 77d0dbe608a58765d2fdeed31e6afb21
+ - MD5: ...
- - SHA: 2bfa58d8fdc9e47f203a9f78e2e5f7e079f40928
+ - SHA: ...
* Or get it from the `Bitbucket page`_:
``hg clone https://bitbucket.org/cffi/cffi``
diff --git a/doc/source/overview.rst b/doc/source/overview.rst
--- a/doc/source/overview.rst
+++ b/doc/source/overview.rst
@@ -58,6 +58,9 @@
# file "simple_example_build.py"
+ # Note: this particular example fails before version 1.0.2
+ # because it combines variadic function and ABI level.
+
from cffi import FFI
ffi = FFI()
diff --git a/doc/source/whatsnew.rst b/doc/source/whatsnew.rst
--- a/doc/source/whatsnew.rst
+++ b/doc/source/whatsnew.rst
@@ -3,6 +3,16 @@
======================
+1.0.2
+=====
+
+* Variadic C functions (ending in a "..." argument) were not supported
+ in the out-of-line ABI mode. This was a bug---there was even a
+ (non-working) example__ doing exactly that!
+
+.. __: overview.html#out-of-line-abi-level
+
+
1.0.1
=====
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -115,19 +115,20 @@
if __name__ == '__main__':
- from setuptools import setup, Extension
- ext_modules = []
- if '__pypy__' not in sys.builtin_module_names:
- ext_modules.append(Extension(
- name='_cffi_backend',
- include_dirs=include_dirs,
- sources=sources,
- libraries=libraries,
- define_macros=define_macros,
- library_dirs=library_dirs,
- extra_compile_args=extra_compile_args,
- extra_link_args=extra_link_args,
- ))
+ from setuptools import setup, Distribution, Extension
+
+ class CFFIDistribution(Distribution):
+ def has_ext_modules(self):
+ # Event if we don't have extension modules (e.g. on PyPy) we want
to
+ # claim that we do so that wheels get properly tagged as Python
+ # specific. (thanks dstufft!)
+ return True
+
+ # On PyPy, cffi is preinstalled and it is not possible, at least for now,
+ # to install a different version. We work around it by making the setup()
+ # arguments mostly empty in this case.
+ cpython = ('_cffi_backend' not in sys.builtin_module_names)
+
setup(
name='cffi',
description='Foreign Function Interface for Python calling C code.',
@@ -143,9 +144,10 @@
`Mailing list <https://groups.google.com/forum/#!forum/python-cffi>`_
""",
- version='1.0.1',
- packages=['cffi'],
- package_data={'cffi': ['_cffi_include.h', 'parse_c_type.h']},
+ version='1.0.2',
+ packages=['cffi'] if cpython else [],
+ package_data={'cffi': ['_cffi_include.h', 'parse_c_type.h']}
+ if cpython else {},
zip_safe=False,
url='http://cffi.readthedocs.org',
@@ -154,17 +156,27 @@
license='MIT',
- ext_modules=ext_modules,
+ distclass=CFFIDistribution,
+ ext_modules=[Extension(
+ name='_cffi_backend',
+ include_dirs=include_dirs,
+ sources=sources,
+ libraries=libraries,
+ define_macros=define_macros,
+ library_dirs=library_dirs,
+ extra_compile_args=extra_compile_args,
+ extra_link_args=extra_link_args,
+ )] if cpython else [],
install_requires=[
'pycparser',
- ],
+ ] if cpython else [],
entry_points = {
"distutils.setup_keywords": [
"cffi_modules = cffi.setuptools_ext:cffi_modules",
],
- },
+ } if cpython else {},
classifiers=[
'Programming Language :: Python',
diff --git a/testing/cffi1/test_re_python.py b/testing/cffi1/test_re_python.py
--- a/testing/cffi1/test_re_python.py
+++ b/testing/cffi1/test_re_python.py
@@ -12,6 +12,7 @@
#define BIGPOS 420000000000L
#define BIGNEG -420000000000L
int add42(int x) { return x + 42; }
+ int add43(int x, ...) { return x; }
int globalvar42 = 1234;
struct foo_s;
typedef struct bar_s { int x; signed char a[]; } bar_t;
@@ -37,6 +38,7 @@
#define BIGPOS 420000000000L
#define BIGNEG -420000000000L
int add42(int);
+ int add43(int, ...);
int globalvar42;
int no_such_function(int);
int no_such_globalvar;
@@ -68,6 +70,13 @@
assert lib.add42(-10) == 32
assert type(lib.add42) is _cffi_backend.FFI.CData
+def test_function_with_varargs():
+ import _cffi_backend
+ from re_python_pysrc import ffi
+ lib = ffi.dlopen(extmod)
+ assert lib.add43(45, ffi.cast("int", -5)) == 45
+ assert type(lib.add43) is _cffi_backend.FFI.CData
+
def test_dlclose():
import _cffi_backend
from re_python_pysrc import ffi
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
--- a/testing/cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -761,3 +761,18 @@
py.test.raises(AttributeError, ffi.addressof, lib, 'unknown_var')
py.test.raises(AttributeError, ffi.addressof, lib, "FOOBAR")
assert ffi.addressof(lib, 'FetchRectBottom') == lib.FetchRectBottom
+
+def test_defines__CFFI_():
+ # Check that we define the macro _CFFI_ automatically.
+ # It should be done before including Python.h, so that PyPy's Python.h
+ # can check for it.
+ ffi = FFI()
+ ffi.cdef("""
+ #define CORRECT 1
+ """)
+ lib = verify(ffi, "test_defines__CFFI_", """
+ #ifdef _CFFI_
+ # define CORRECT 1
+ #endif
+ """)
+ assert lib.CORRECT == 1
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit