Debian Codegraph @

doc/source/whatsnew.rst

raw
1 ======================
2 What's New
3 ======================
4
5 v2.1.1
6 ======
7
8 * Minimize internal Python API usage for interpreter and thread state sampling where possible.
9 Avoids breaking ABI change in Python >= 3.15.0b4. (`#269`_)
10
11 .. _`#269`: https://github.com/python-cffi/cffi/pull/269
12
13 v2.1.0
14 ======
15
16 * Added the ``cffi-gen-src`` command-line tool (also invocable as
17 ``python -m cffi.gen_src``), which generates CFFI C extension
18 source code, so that a build backend such as `meson-python`_ can build
19 the extension. See :doc:`cffi-gen-src` for details. Integrated from the
20 `cffi-buildtool`_ project by Rose Davidson. (`#241`_)
21 * Added support for arm64 iOS wheels. (`#181`_)
22 * Dropped support for Python 3.9.
23 * Added support for Python 3.15 and support for C extensions generated by CFFI
24 to target the new ``abi3t`` free-threaded ABI. (`#232`_)
25 * Avoid crashes inside of ``__delitem__``. (`#235`_)
26 * Avoid "string too big" error under MSVC. (`#167`_)
27 * Fix mingw builds. (`#198`_)
28
29 .. _`#167`: https://github.com/python-cffi/cffi/pull/167
30 .. _`#181`: https://github.com/python-cffi/cffi/pull/181
31 .. _`#198`: https://github.com/python-cffi/cffi/pull/198
32 .. _`#232`: https://github.com/python-cffi/cffi/pull/232
33 .. _`#235`: https://github.com/python-cffi/cffi/pull/235
34 .. _`#241`: https://github.com/python-cffi/cffi/pull/241
35
36 v2.0.0
37 ======
38
39 * Added support for free threaded Python. (`#178`_)
40 Note that the free-threaded build does not yet support building extensions
41 with the limited API, so you must set py_limited_api=False when building
42 extensions for the free-threaded build.
43 * Added support for Python 3.14. (`#177`_)
44
45 .. _`meson-python`: https://meson-python.readthedocs.io/
46 .. _`cffi-buildtool`: https://github.com/inklesspen/cffi-buildtool
47
48 .. _`#177`: https://github.com/python-cffi/cffi/pull/177
49 .. _`#178`: https://github.com/python-cffi/cffi/pull/178
50
51 v1.17.1
52 =======
53
54 * Fix failing ``distutils.msvc9compiler`` imports under Windows (`#118`_).
55 * ``ffibuilder.emit_python_code()`` and ``ffibuilder.emit_c_code()`` accept file-like objects (`#115`_).
56 * ``ffiplatform`` calls are bypassed by ``ffibuilder.emit_python_code()`` and ``ffibuilder.emit_c_code()`` (`#81`_).
57
58 .. _`#118`: https://github.com/python-cffi/cffi/pull/118
59 .. _`#115`: https://github.com/python-cffi/cffi/pull/115
60 .. _`#81`: https://github.com/python-cffi/cffi/pull/81
61
62 v1.17.0
63 =======
64
65 * In API mode, when you get a function from a C library by writing
66 `fn = lib.myfunc`, you get an object of a special type for performance
67 reasons, instead of a `<cdata 'C-function-type'>`. Before version 1.17
68 you could only call such objects. You could write
69 `ffi.addressof(lib, "myfunc")` in order to get a real `<cdata>` object,
70 based on the idea that in these cases in C you'd usually write `&myfunc`
71 instead of `myfunc`. In version 1.17, the special object
72 `lib.myfunc` can now be passed in many places where CFFI expects
73 a regular `<cdata>` object. For example, you can now pass
74 it as a callback to a C function call, or write it inside a C
75 structure field of the correct pointer-to-function type, or use
76 `ffi.cast()` or `ffi.typeof()` on it.
77
78 v1.16.0
79 =======
80
81 * Add support for Python 3.12. With the removal of ``distutils`` from Python 3.12, projects
82 using CFFI features that depend on ``distutils`` at runtime must add a dependency on
83 ``setuptools`` to function under Python 3.12+. CFFI does not declare a runtime ``setuptools``
84 requirement to avoid an unnecessary dependency for projects that do not require it.
85 * Drop support for end-of-life Python versions (2.7, 3.6, 3.7).
86 * Add support for PEP517 builds; ``setuptools`` is now a required build dependency.
87 * Declare ``python_requires`` metadata for Python 3.8+. This allows unsupported Pythons
88 to continue using previously released sdists and wheels.
89 * Upstream project hosting moved from Heptapod to `GitHub`_.
90
91 .. _`GitHub`: https://github.com/python-cffi/cffi
92
93 v1.15.1
94 =======
95
96 * If you call `ffi.embedding_api()` but don't write any `extern "Python"`
97 function there, then the resulting C code would fail an assert. Fixed.
98
99 * Updated Windows/arm64 embedded libffi static lib to v3.4.2, and scripted
100 to ease future updates (thanks Niyas Sait!)
101
102 v1.15.0
103 =======
104
105 * Fixed MANIFEST.in to include missing file for Windows arm64 support
106
107 * Fixed Linux wheel build to use gcc default ISA for libffi
108
109 * Updated setup.py Python trove specifiers to currently-tested Python versions
110
111 * CPython 3.10 support (including wheels)
112
113 * MacOS arm64 support (including wheels)
114
115 * Initial Windows arm64 support
116
117 * Misc. doc and test updates
118
119 v1.14.6
120 =======
121
122 * Test fixes for CPython 3.10.0b3
123
124 * Support for `sys.unraisablehook()` on Python >= 3.8
125
126 * Fix two minor memory leaks (thanks Sebastian!)
127
128 * Like many projects that had an IRC channel on freenode, we moved it to
129 ``irc.libera.chat``.
130
131 v1.14.5
132 =======
133
134 * Source fix for old gcc versions
135
136 * This and future releases should include wheels on more platforms,
137 thanks to our new release managers Matt and Matt!
138
139 v1.14.4
140 =======
141
142 Release done for pip reasons.
143
144 v1.14.3
145 =======
146
147 Release done for pip reasons.
148
149 v1.14.2
150 =======
151
152 * CPython 3 on Windows: we again try to compile with ``Py_LIMITED_API``
153 by default. This flag is not added if you run the compilation with
154 CPython 3.4, as it only works with CPython >= 3.5, but by now this
155 version of Python is quite old (and we no longer distribute cffi
156 wheels for it).
157
158 This may require that you upgrade ``virtualenv`` (requires version 16
159 or newer) or at least copy manually ``python3.dll`` into your existing
160 virtualenvs. For distributing wheels with your cffi modules, you may
161 also need to upgrade ``wheel`` to the just-released version 0.35.
162
163 You can manually disable ``Py_LIMITED_API`` by calling
164 ``ffi.set_source(..., py_limited_api=False)``.
165
166
167 v1.14.1
168 =======
169
170 * CFFI source code is now `hosted on Heptapod`_.
171
172 * Improved support for ``typedef int my_array_t[...];`` with an explicit
173 dot-dot-dot in API mode (`issue #453`_)
174
175 * Windows (32 and 64 bits): multiple fixes for ABI-mode call to functions
176 that return a structure.
177
178 * Experimental support for MacOS 11 on aarch64.
179
180 * and a few other minor changes and bug fixes.
181
182 .. _`hosted on Heptapod`: https://foss.heptapod.net/pypy/cffi/
183 .. _`issue #453`: https://foss.heptapod.net/pypy/cffi/issues/453
184
185
186 v1.14
187 =====
188
189 * ``ffi.dlopen()`` can now be called with a handle (as a ``void *``) to an
190 already-opened C library.
191
192 * CPython only: fixed a stack overflow issue for calls like
193 ``lib.myfunc([large list])``. If the function is declared as taking a
194 ``float *`` argument, for example, then the array is temporarily converted
195 into a C array of floats---however, the code used to use ``alloca()`` for
196 this temporary storage, no matter how large. This is now fixed.
197
198 The fix concerns all modes: in-line/out-of-line API/ABI. Also note that your
199 API-mode C extension modules need to be regenerated with cffi 1.14 in order
200 to get the fix; i.e. for API mode, the fix is in the generated C sources.
201 (The C sources generated from cffi 1.14 should also work when running in
202 a different environment in which we have an older version of cffi. Also,
203 this change makes no difference on PyPy.)
204
205 As a workaround that works on all versions of cffi, you can write
206 ``lib.myfunc(ffi.new("float[]", [large list]))``, which is
207 equivalent but explicitly builds the intermediate array as a regular
208 Python object on the heap.
209
210 * fixed a memory leak inside ``ffi.getwinerror()`` on CPython 3.x.
211
212
213 v1.13.2
214 =======
215
216 * re-release because the Linux wheels came with an attached version of libffi
217 that was very old and buggy (`issue #432`_).
218
219 .. _`issue #432`: https://foss.heptapod.net/pypy/cffi/-/issues/432
220
221
222
223 v1.13.1
224 =======
225
226 * deprecate the way to declare in ``cdef()`` a global variable with only
227 ``void *foo;``. You should always use a storage class, like ``extern void
228 *foo;`` or maybe ``static void *foo;``. These are all equivalent for
229 the purposes of ``cdef()``, but the reason for deprecating the bare version
230 is that (as far as I know) it would always be mistake in a real C header.
231
232 * fix the regression ``RuntimeError: found a situation in which we try
233 to build a type recursively`` (`issue #429`_).
234
235 * fixed `issue #427`_ where a multithreading mistake in the embedding logic
236 initialization code would cause deadlocks on CPython 3.7.
237
238 .. _`issue #429`: https://foss.heptapod.net/pypy/cffi/-/issues/429
239 .. _`issue #427`: https://foss.heptapod.net/pypy/cffi/-/issues/427
240
241
242 v1.13
243 =====
244
245 * ``ffi.from_buffer("type *", ..)`` is now supported, in addition to
246 ``"type[]"``. You can then write ``p.field`` to access the items, instead
247 of only ``p[0].field``. Be careful that no bounds checking is performed, so
248 ``p[n]`` might access data out of bounds.
249
250 * fix for structs containing unnamed bitfields like ``int : 1;``.
251
252 * when calling cdata of "function pointer" type, give a RuntimeError instead
253 of a crash if the pointer happens to be NULL
254
255 * support some more binary operations between constants in enum definitions
256 (PR #96)
257
258 * silence a warning incorrectly emitted if you use a quote in a preprocessor
259 line
260
261 * detect a corner case that would throw the C code into an infinite
262 recursion, with ``ffi.cdef("""struct X { void(*fnptr)(struct X); };""")``
263
264
265 Older Versions
266 ==============
267
268 v1.12.3
269 -------
270
271 * Fix for nested struct types that end in a var-sized array (#405).
272
273 * Add support for using ``U`` and ``L`` characters at the end of integer
274 constants in ``ffi.cdef()`` (thanks Guillaume).
275
276 * More 3.8 fixes.
277
278
279 v1.12.2
280 -------
281
282 * Added temporary workaround to compile on CPython 3.8.0a2.
283
284
285 v1.12.1
286 -------
287
288 * CPython 3 on Windows: we again no longer compile with ``Py_LIMITED_API``
289 by default because such modules *still* cannot be used with virtualenv.
290 The problem is that it doesn't work in CPython <= 3.4, and for
291 technical reason we can't enable this flag automatically based on the
292 version of Python.
293
294 Like before, `Issue #350`_ mentions a workaround if you still want
295 the ``Py_LIMITED_API`` flag and *either* you are not concerned about
296 virtualenv *or* you are sure your module will not be used on CPython
297 <= 3.4: pass ``define_macros=[("Py_LIMITED_API", None)]`` as a keyword to the
298 ``ffibuilder.set_source()`` call.
299
300
301 v1.12
302 -----
303
304 * `Direct support for pkg-config`__.
305
306 * ``ffi.from_buffer()`` takes a new optional *first* argument that gives
307 the array type of the result. It also takes an optional keyword argument
308 ``require_writable`` to refuse read-only Python buffers.
309
310 * ``ffi.new()``, ``ffi.gc()`` or ``ffi.from_buffer()`` cdata objects
311 can now be released at known times, either by using the ``with``
312 keyword or by calling the new ``ffi.release()``.
313
314 * Windows, CPython 3.x: cffi modules are linked with ``python3.dll``
315 again. This makes them independent on the exact CPython version,
316 like they are on other platforms. **It requires virtualenv 16.0.0.**
317
318 * Accept an expression like ``ffi.new("int[4]", p)`` if ``p`` is itself
319 another cdata ``int[4]``.
320
321 * CPython 2.x: ``ffi.dlopen()`` failed with non-ascii file names on Posix
322
323 * CPython: if a thread is started from C and then runs Python code (with
324 callbacks or with the embedding solution), then previous versions of
325 cffi would contain possible crashes and/or memory leaks. Hopefully,
326 this has been fixed (see `issue #362`_).
327
328 * Support for ``ffi.cdef(..., pack=N)`` where N is a power of two.
329 Means to emulate ``#pragma pack(N)`` on MSVC. Also, the default on
330 Windows is now ``pack=8``, like on MSVC. This might make a difference
331 in corner cases, although I can't think of one in the context of CFFI.
332 The old way ``ffi.cdef(..., packed=True)`` remains and is equivalent
333 to ``pack=1`` (saying e.g. that fields like ``int`` should be aligned
334 to 1 byte instead of 4).
335
336 .. __: cdef.html#pkgconfig
337 .. _`issue #362`: https://foss.heptapod.net/pypy/cffi/-/issues/362
338
339
340 v1.11.5
341 -------
342
343 * `Issue #357`_: fix ``ffi.emit_python_code()`` which generated a buggy
344 Python file if you are using a ``struct`` with an anonymous ``union``
345 field or vice-versa.
346
347 * Windows: ``ffi.dlopen()`` should now handle unicode filenames.
348
349 * ABI mode: implemented ``ffi.dlclose()`` for the in-line case (it used
350 to be present only in the out-of-line case).
351
352 * Fixed a corner case for ``setup.py install --record=xx --root=yy``
353 with an out-of-line ABI module. Also fixed `Issue #345`_.
354
355 * More hacks on Windows for running CFFI's own ``setup.py``.
356
357 * `Issue #358`_: in embedding, to protect against (the rare case of)
358 Python initialization from several threads in parallel, we have to use
359 a spin-lock. On CPython 3 it is worse because it might spin-lock for
360 a long time (execution of ``Py_InitializeEx()``). Sadly, recent
361 changes to CPython make that solution needed on CPython 2 too.
362
363 * CPython 3 on Windows: we no longer compile with ``Py_LIMITED_API``
364 by default because such modules cannot be used with virtualenv.
365 `Issue #350`_ mentions a workaround if you still want that and are not
366 concerned about virtualenv: pass ``define_macros=[("Py_LIMITED_API",
367 None)]`` as a keyword to the ``ffibuilder.set_source()`` call.
368
369 .. _`Issue #345`: https://foss.heptapod.net/pypy/cffi/-/issues/345
370 .. _`Issue #350`: https://foss.heptapod.net/pypy/cffi/-/issues/350
371 .. _`Issue #358`: https://foss.heptapod.net/pypy/cffi/-/issues/358
372 .. _`Issue #357`: https://foss.heptapod.net/pypy/cffi/-/issues/357
373
374
375 v1.11.4
376 -------
377
378 * Windows: reverted linking with ``python3.dll``, because
379 virtualenv does not make this DLL available to virtual environments
380 for now. See `Issue #355`_. On Windows only, the C extension
381 modules created by cffi follow for now the standard naming scheme
382 ``foo.cp36-win32.pyd``, to make it clear that they are regular
383 CPython modules depending on ``python36.dll``.
384
385 .. _`Issue #355`: https://foss.heptapod.net/pypy/cffi/-/issues/355
386
387
388 v1.11.3
389 -------
390
391 * Fix on CPython 3.x: reading the attributes ``__loader__`` or
392 ``__spec__`` from the cffi-generated lib modules gave a buggy
393 SystemError. (These attributes are always None, and provided only to
394 help compatibility with tools that expect them in all modules.)
395
396 * More Windows fixes: workaround for MSVC not supporting large
397 literal strings in C code (from
398 ``ffi.embedding_init_code(large_string)``); and an issue with
399 ``Py_LIMITED_API`` linking with ``python35.dll/python36.dll`` instead
400 of ``python3.dll``.
401
402 * Small documentation improvements.
403
404
405 v1.11.2
406 -------
407
408 * Fix Windows issue with managing the thread-state on CPython 3.0 to 3.5
409
410
411 v1.11.1
412 -------
413
414 * Fix tests, remove deprecated C API usage
415
416 * Fix (hack) for 3.6.0/3.6.1/3.6.2 giving incompatible binary extensions
417 (cpython issue `#29943`_)
418
419 * Fix for 3.7.0a1+
420
421 .. _`#29943`: https://bugs.python.org/issue29943
422
423
424 v1.11
425 -----
426
427 * Support the modern standard types ``char16_t`` and ``char32_t``.
428 These work like ``wchar_t``: they represent one unicode character, or
429 when used as ``charN_t *`` or ``charN_t[]`` they represent a unicode
430 string. The difference with ``wchar_t`` is that they have a known,
431 fixed size. They should work at all places that used to work with
432 ``wchar_t`` (please report an issue if I missed something). Note
433 that with ``set_source()``, you need to make sure that these types are
434 actually defined by the C source you provide (if used in ``cdef()``).
435
436 * Support the C99 types ``float _Complex`` and ``double _Complex``.
437 Note that libffi doesn't support them, which means that in the ABI
438 mode you still cannot call C functions that take complex numbers
439 directly as arguments or return type.
440
441 * Fixed a rare race condition when creating multiple ``FFI`` instances
442 from multiple threads. (Note that you aren't meant to create many
443 ``FFI`` instances: in inline mode, you should write ``ffi =
444 cffi.FFI()`` at module level just after ``import cffi``; and in
445 out-of-line mode you don't instantiate ``FFI`` explicitly at all.)
446
447 * Windows: using callbacks can be messy because the CFFI internal error
448 messages show up to stderr---but stderr goes nowhere in many
449 applications. This makes it particularly hard to get started with the
450 embedding mode. (Once you get started, you can at least use
451 ``@ffi.def_extern(onerror=...)`` and send the error logs where it
452 makes sense for your application, or record them in log files, and so
453 on.) So what is new in CFFI is that now, on Windows CFFI will try to
454 open a non-modal MessageBox (in addition to sending raw messages to
455 stderr). The MessageBox is only visible if the process stays alive:
456 typically, console applications that crash close immediately, but that
457 is also the situation where stderr should be visible anyway.
458
459 * Progress on support for `callbacks in NetBSD`__.
460
461 * Functions returning booleans would in some case still return 0 or 1
462 instead of False or True. Fixed.
463
464 * `ffi.gc()`__ now takes an optional third parameter, which gives an
465 estimate of the size (in bytes) of the object. So far, this is only
466 used by PyPy, to make the next GC occur more quickly (`issue #320`__).
467 In the future, this might have an effect on CPython too (provided
468 the CPython `issue 31105`__ is addressed).
469
470 * Add a note to the documentation: the ABI mode gives function objects
471 that are *slower* to call than the API mode does. For some reason it
472 is often thought to be faster. It is not!
473
474 .. __: https://foss.heptapod.net/pypy/cffi/-/issues/321
475 .. __: ref.html#ffi-gc
476 .. __: https://foss.heptapod.net/pypy/cffi/-/issues/320
477 .. __: http://bugs.python.org/issue31105
478
479
480 v1.10.1
481 -------
482
483 (only released inside PyPy 5.8.0)
484
485 * Fixed the line numbers reported in case of ``cdef()`` errors.
486 Also, I just noticed, but pycparser always supported the preprocessor
487 directive ``# 42 "foo.h"`` to mean "from the next line, we're in file
488 foo.h starting from line 42", which it puts in the error messages.
489
490
491 v1.10
492 -----
493
494 * Issue #295: use calloc() directly instead of
495 PyObject_Malloc()+memset() to handle ffi.new() with a default
496 allocator. Speeds up ``ffi.new(large-array)`` where most of the time
497 you never touch most of the array.
498
499 * Some OS/X build fixes ("only with Xcode but without CLT").
500
501 * Improve a couple of error messages: when getting mismatched versions
502 of cffi and its backend; and when calling functions which cannot be
503 called with libffi because an argument is a struct that is "too
504 complicated" (and not a struct *pointer*, which always works).
505
506 * Add support for some unusual compilers (non-msvc, non-gcc, non-icc,
507 non-clang)
508
509 * Implemented the remaining cases for ``ffi.from_buffer``. Now all
510 buffer/memoryview objects can be passed. The one remaining check is
511 against passing unicode strings in Python 2. (They support the buffer
512 interface, but that gives the raw bytes behind the UTF16/UCS4 storage,
513 which is most of the times not what you expect. In Python 3 this has
514 been fixed and the unicode strings don't support the memoryview
515 interface any more.)
516
517 * The C type ``_Bool`` or ``bool`` now converts to a Python boolean
518 when reading, instead of the content of the byte as an integer. The
519 potential incompatibility here is what occurs if the byte contains a
520 value different from 0 and 1. Previously, it would just return it;
521 with this change, CFFI raises an exception in this case. But this
522 case means "undefined behavior" in C; if you really have to interface
523 with a library relying on this, don't use ``bool`` in the CFFI side.
524 Also, it is still valid to use a byte string as initializer for a
525 ``bool[]``, but now it must only contain ``\x00`` or ``\x01``. As an
526 aside, ``ffi.string()`` no longer works on ``bool[]`` (but it never
527 made much sense, as this function stops at the first zero).
528
529 * ``ffi.buffer`` is now the name of cffi's buffer type, and
530 ``ffi.buffer()`` works like before but is the constructor of that type.
531
532 * ``ffi.addressof(lib, "name")`` now works also in in-line mode, not
533 only in out-of-line mode. This is useful for taking the address of
534 global variables.
535
536 * Issue #255: ``cdata`` objects of a primitive type (integers, floats,
537 char) are now compared and ordered by value. For example, ``<cdata
538 'int' 42>`` compares equal to ``42`` and ``<cdata 'char' b'A'>``
539 compares equal to ``b'A'``. Unlike C, ``<cdata 'int' -1>`` does not
540 compare equal to ``ffi.cast("unsigned int", -1)``: it compares
541 smaller, because ``-1 < 4294967295``.
542
543 * PyPy: ``ffi.new()`` and ``ffi.new_allocator()()`` did not record
544 "memory pressure", causing the GC to run too infrequently if you call
545 ``ffi.new()`` very often and/or with large arrays. Fixed in PyPy 5.7.
546
547 * Support in ``ffi.cdef()`` for numeric expressions with ``+`` or
548 ``-``. Assumes that there is no overflow; it should be fixed first
549 before we add more general support for arbitrary arithmetic on
550 constants.
551
552
553 v1.9
554 ----
555
556 * Structs with variable-sized arrays as their last field: now we track
557 the length of the array after ``ffi.new()`` is called, just like we
558 always tracked the length of ``ffi.new("int[]", 42)``. This lets us
559 detect out-of-range accesses to array items. This also lets us
560 display a better ``repr()``, and have the total size returned by
561 ``ffi.sizeof()`` and ``ffi.buffer()``. Previously both functions
562 would return a result based on the size of the declared structure
563 type, with an assumed empty array. (Thanks andrew for starting this
564 refactoring.)
565
566 * Add support in ``cdef()/set_source()`` for unspecified-length arrays
567 in typedefs: ``typedef int foo_t[...];``. It was already supported
568 for global variables or structure fields.
569
570 * I turned in v1.8 a warning from ``cffi/model.py`` into an error:
571 ``'enum xxx' has no values explicitly defined: refusing to guess which
572 integer type it is meant to be (unsigned/signed, int/long)``. Now I'm
573 turning it back to a warning again; it seems that guessing that the
574 enum has size ``int`` is a 99%-safe bet. (But not 100%, so it stays
575 as a warning.)
576
577 * Fix leaks in the code handling ``FILE *`` arguments. In CPython 3
578 there is a remaining issue that is hard to fix: if you pass a Python
579 file object to a ``FILE *`` argument, then ``os.dup()`` is used and
580 the new file descriptor is only closed when the GC reclaims the Python
581 file object---and not at the earlier time when you call ``close()``,
582 which only closes the original file descriptor. If this is an issue,
583 you should avoid this automatic conversion of Python file objects:
584 instead, explicitly manipulate file descriptors and call ``fdopen()``
585 from C (...via cffi).
586
587
588 v1.8.3
589 ------
590
591 * When passing a ``void *`` argument to a function with a different
592 pointer type, or vice-versa, the cast occurs automatically, like in C.
593 The same occurs for initialization with ``ffi.new()`` and a few other
594 places. However, I thought that ``char *`` had the same
595 property---but I was mistaken. In C you get the usual warning if you
596 try to give a ``char *`` to a ``char **`` argument, for example.
597 Sorry about the confusion. This has been fixed in CFFI by giving for
598 now a warning, too. It will turn into an error in a future version.
599
600
601 v1.8.2
602 ------
603
604 * Issue #283: fixed ``ffi.new()`` on structures/unions with nested
605 anonymous structures/unions, when there is at least one union in
606 the mix. When initialized with a list or a dict, it should now
607 behave more closely like the ``{ }`` syntax does in GCC.
608
609
610 v1.8.1
611 ------
612
613 * CPython 3.x: experimental: the generated C extension modules now use
614 the "limited API", which means that, as a compiled .so/.dll, it should
615 work directly on any version of CPython >= 3.2. The name produced by
616 distutils is still version-specific. To get the version-independent
617 name, you can rename it manually to ``NAME.abi3.so``, or use the very
618 recent setuptools 26.
619
620 * Added ``ffi.compile(debug=...)``, similar to ``python setup.py build
621 --debug`` but defaulting to True if we are running a debugging
622 version of Python itself.
623
624
625 v1.8
626 ----
627
628 * Removed the restriction that ``ffi.from_buffer()`` cannot be used on
629 byte strings. Now you can get a ``char *`` out of a byte string,
630 which is valid as long as the string object is kept alive. (But
631 don't use it to *modify* the string object! If you need this, use
632 ``bytearray`` or other official techniques.)
633
634 * PyPy 5.4 can now pass a byte string directly to a ``char *``
635 argument (in older versions, a copy would be made). This used to be
636 a CPython-only optimization.
637
638
639 v1.7
640 ----
641
642 * ``ffi.gc(p, None)`` removes the destructor on an object previously
643 created by another call to ``ffi.gc()``
644
645 * ``bool(ffi.cast("primitive type", x))`` now returns False if the
646 value is zero (including ``-0.0``), and True otherwise. Previously
647 this would only return False for cdata objects of a pointer type when
648 the pointer is NULL.
649
650 * bytearrays: ``ffi.from_buffer(bytearray-object)`` is now supported.
651 (The reason it was not supported was that it was hard to do in PyPy,
652 but it works since PyPy 5.3.) To call a C function with a ``char *``
653 argument from a buffer object---now including bytearrays---you write
654 ``lib.foo(ffi.from_buffer(x))``. Additionally, this is now supported:
655 ``p[0:length] = bytearray-object``. The problem with this was that a
656 iterating over bytearrays gives *numbers* instead of *characters*.
657 (Now it is implemented with just a memcpy, of course, not actually
658 iterating over the characters.)
659
660 * C++: compiling the generated C code with C++ was supposed to work,
661 but failed if you make use the ``bool`` type (because that is rendered
662 as the C ``_Bool`` type, which doesn't exist in C++).
663
664 * ``help(lib)`` and ``help(lib.myfunc)`` now give useful information,
665 as well as ``dir(p)`` where ``p`` is a struct or pointer-to-struct.
666
667
668 v1.6
669 ----
670
671 * `ffi.list_types()`_
672
673 * `ffi.unpack()`_
674
675 * `extern "Python+C"`_
676
677 * in API mode, ``lib.foo.__doc__`` contains the C signature now. On
678 CPython you can say ``help(lib.foo)``, but for some reason
679 ``help(lib)`` (or ``help(lib.foo)`` on PyPy) is still useless; I
680 haven't yet figured out the hacks needed to convince ``pydoc`` to
681 show more. (You can use ``dir(lib)`` but it is not most helpful.)
682
683 * Yet another attempt at robustness of ``ffi.def_extern()`` against
684 CPython's interpreter shutdown logic.
685
686 .. _`ffi.list_types()`: ref.html#ffi-list-types
687 .. _`ffi.unpack()`: ref.html#ffi-unpack
688 .. _`extern "Python+C"`: using.html#extern-python-c
689
690
691 v1.5.2
692 ------
693
694 * Fix 1.5.1 for Python 2.6.
695
696
697 v1.5.1
698 ------
699
700 * A few installation-time tweaks (thanks Stefano!)
701
702 * Issue #245: Win32: ``__stdcall`` was never generated for
703 ``extern "Python"`` functions
704
705 * Issue #246: trying to be more robust against CPython's fragile
706 interpreter shutdown logic
707
708
709 v1.5.0
710 ------
711
712 * Support for `using CFFI for embedding`__.
713
714 .. __: embedding.html
715
716
717 v1.4.2
718 ------
719
720 Nothing changed from v1.4.1.
721
722
723 v1.4.1
724 ------
725
726 * Fix the compilation failure of cffi on CPython 3.5.0. (3.5.1 works;
727 some detail changed that makes some underscore-starting macros
728 disappear from view of extension modules, and I worked around it,
729 thinking it changed in all 3.5 versions---but no: it was only in
730 3.5.1.)
731
732
733 v1.4.0
734 ------
735
736 * A `better way to do callbacks`__ has been added (faster and more
737 portable, and usually cleaner). It is a mechanism for the
738 out-of-line API mode that replaces the dynamic creation of callback
739 objects (i.e. C functions that invoke Python) with the static
740 declaration in ``cdef()`` of which callbacks are needed. This is
741 more C-like, in that you have to structure your code around the idea
742 that you get a fixed number of function pointers, instead of
743 creating them on-the-fly.
744
745 * ``ffi.compile()`` now takes an optional ``verbose`` argument. When
746 ``True``, distutils prints the calls to the compiler.
747
748 * ``ffi.compile()`` used to fail if given ``sources`` with a path that
749 includes ``".."``. Fixed.
750
751 * ``ffi.init_once()`` added. See docs__.
752
753 * ``dir(lib)`` now works on libs returned by ``ffi.dlopen()`` too.
754
755 * Cleaned up and modernized the content of the ``demo`` subdirectory
756 in the sources (thanks matti!).
757
758 * ``ffi.new_handle()`` is now guaranteed to return unique ``void *``
759 values, even if called twice on the same object. Previously, in
760 that case, CPython would return two ``cdata`` objects with the same
761 ``void *`` value. This change is useful to add and remove handles
762 from a global dict (or set) without worrying about duplicates.
763 It already used to work like that on PyPy.
764 *This change can break code that used to work on CPython by relying
765 on the object to be kept alive by other means than keeping the
766 result of ffi.new_handle() alive.* (The corresponding `warning in
767 the docs`__ of ``ffi.new_handle()`` has been here since v0.8!)
768
769 .. __: using.html#extern-python
770 .. __: ref.html#ffi-init-once
771 .. __: ref.html#ffi-new-handle
772
773
774 v1.3.1
775 ------
776
777 * The optional typedefs (``bool``, ``FILE`` and all Windows types) were
778 not always available from out-of-line FFI objects.
779
780 * Opaque enums are phased out from the cdefs: they now give a warning,
781 instead of (possibly wrongly) being assumed equal to ``unsigned int``.
782 Please report if you get a reasonable use case for them.
783
784 * Some parsing details, notably ``volatile`` is passed along like
785 ``const`` and ``restrict``. Also, older versions of pycparser
786 mis-parse some pointer-to-pointer types like ``char * const *``: the
787 "const" ends up at the wrong place. Added a workaround.
788
789
790 v1.3.0
791 ------
792
793 * Added `ffi.memmove()`_.
794
795 * Pull request #64: out-of-line API mode: we can now declare
796 floating-point types with ``typedef float... foo_t;``. This only
797 works if ``foo_t`` is a float or a double, not ``long double``.
798
799 * Issue #217: fix possible unaligned pointer manipulation, which crashes
800 on some architectures (64-bit, non-x86).
801
802 * Issues #64 and #126: when using ``set_source()`` or ``verify()``,
803 the ``const`` and ``restrict`` keywords are copied from the cdef
804 to the generated C code; this fixes warnings by the C compiler.
805 It also fixes corner cases like ``typedef const int T; T a;``
806 which would previously not consider ``a`` as a constant. (The
807 cdata objects themselves are never ``const``.)
808
809 * Win32: support for ``__stdcall``. For callbacks and function
810 pointers; regular C functions still don't need to have their `calling
811 convention`_ declared.
812
813 * Windows: CPython 2.7 distutils doesn't work with Microsoft's official
814 Visual Studio for Python, and I'm told this is `not a bug`__. For
815 ffi.compile(), we `removed a workaround`__ that was inside cffi but
816 which had unwanted side-effects. Try saying ``import setuptools``
817 first, which patches distutils...
818
819 .. _`ffi.memmove()`: ref.html#ffi-memmove
820 .. __: https://bugs.python.org/issue23246
821 .. __: https://bitbucket.org/cffi/cffi/pull-requests/65/remove-_hack_at_distutils-which-imports/diff
822 .. _`calling convention`: using.html#windows-calling-conventions
823
824
825 v1.2.1
826 ------
827
828 Nothing changed from v1.2.0.
829
830
831 v1.2.0
832 ------
833
834 * Out-of-line mode: ``int a[][...];`` can be used to declare a structure
835 field or global variable which is, simultaneously, of total length
836 unknown to the C compiler (the ``a[]`` part) and each element is
837 itself an array of N integers, where the value of N *is* known to the
838 C compiler (the ``int`` and ``[...]`` parts around it). Similarly,
839 ``int a[5][...];`` is supported (but probably less useful: remember
840 that in C it means ``int (a[5])[...];``).
841
842 * PyPy: the ``lib.some_function`` objects were missing the attributes
843 ``__name__``, ``__module__`` and ``__doc__`` that are expected e.g. by
844 some decorators-management functions from ``functools``.
845
846 * Out-of-line API mode: you can now do ``from _example.lib import x``
847 to import the name ``x`` from ``_example.lib``, even though the
848 ``lib`` object is not a standard module object. (Also works in ``from
849 _example.lib import *``, but this is even more of a hack and will fail
850 if ``lib`` happens to declare a name called ``__all__``. Note that
851 ``*`` excludes the global variables; only the functions and constants
852 make sense to import like this.)
853
854 * ``lib.__dict__`` works again and gives you a copy of the
855 dict---assuming that ``lib`` has got no symbol called precisely
856 ``__dict__``. (In general, it is safer to use ``dir(lib)``.)
857
858 * Out-of-line API mode: global variables are now fetched on demand at
859 every access. It fixes issue #212 (Windows DLL variables), and also
860 allows variables that are defined as dynamic macros (like ``errno``)
861 or ``__thread`` -local variables. (This change might also tighten
862 the C compiler's check on the variables' type.)
863
864 * Issue #209: dereferencing NULL pointers now raises RuntimeError
865 instead of segfaulting. Meant as a debugging aid. The check is
866 only for NULL: if you dereference random or dead pointers you might
867 still get segfaults.
868
869 * Issue #152: callbacks__: added an argument ``ffi.callback(...,
870 onerror=...)``. If the main callback function raises an exception
871 and ``onerror`` is provided, then ``onerror(exception, exc_value,
872 traceback)`` is called. This is similar to writing a ``try:
873 except:`` in the main callback function, but in some cases (e.g. a
874 signal) an exception can occur at the very start of the callback
875 function---before it had time to enter the ``try: except:`` block.
876
877 * Issue #115: added ``ffi.new_allocator()``, which officializes
878 support for `alternative allocators`__.
879
880 .. __: using.html#callbacks
881 .. __: ref.html#ffi-new-allocator
882
883
884 v1.1.2
885 ------
886
887 * ``ffi.gc()``: fixed a race condition in multithreaded programs
888 introduced in 1.1.1
889
890
891 v1.1.1
892 ------
893
894 * Out-of-line mode: ``ffi.string()``, ``ffi.buffer()`` and
895 ``ffi.getwinerror()`` didn't accept their arguments as keyword
896 arguments, unlike their in-line mode equivalent. (It worked in PyPy.)
897
898 * Out-of-line ABI mode: documented a restriction__ of ``ffi.dlopen()``
899 when compared to the in-line mode.
900
901 * ``ffi.gc()``: when called several times with equal pointers, it was
902 accidentally registering only the last destructor, or even none at
903 all depending on details. (It was correctly registering all of them
904 only in PyPy, and only with the out-of-line FFIs.)
905
906 .. __: cdef.html#dlopen-note
907
908
909 v1.1.0
910 ------
911
912 * Out-of-line API mode: we can now declare integer types with
913 ``typedef int... foo_t;``. The exact size and signedness of ``foo_t``
914 is figured out by the compiler.
915
916 * Out-of-line API mode: we can now declare multidimensional arrays
917 (as fields or as globals) with ``int n[...][...]``. Before, only the
918 outermost dimension would support the ``...`` syntax.
919
920 * Out-of-line ABI mode: we now support any constant declaration,
921 instead of only integers whose value is given in the cdef. Such "new"
922 constants, i.e. either non-integers or without a value given in the
923 cdef, must correspond to actual symbols in the lib. At runtime they
924 are looked up the first time we access them. This is useful if the
925 library defines ``extern const sometype somename;``.
926
927 * ``ffi.addressof(lib, "func_name")`` now returns a regular cdata object
928 of type "pointer to function". You can use it on any function from a
929 library in API mode (in ABI mode, all functions are already regular
930 cdata objects). To support this, you need to recompile your cffi
931 modules.
932
933 * Issue #198: in API mode, if you declare constants of a ``struct``
934 type, what you saw from lib.CONSTANT was corrupted.
935
936 * Issue #196: ``ffi.set_source("package._ffi", None)`` would
937 incorrectly generate the Python source to ``package._ffi.py`` instead
938 of ``package/_ffi.py``. Also fixed: in some cases, if the C file was
939 in ``build/foo.c``, the .o file would be put in ``build/build/foo.o``.
940
941
942 v1.0.3
943 ------
944
945 * Same as 1.0.2, apart from doc and test fixes on some platforms.
946
947
948 v1.0.2
949 ------
950
951 * Variadic C functions (ending in a "..." argument) were not supported
952 in the out-of-line ABI mode. This was a bug---there was even a
953 (non-working) example__ doing exactly that!
954
955 .. __: overview.html#out-of-line-abi-level
956
957
958 v1.0.1
959 ------
960
961 * ``ffi.set_source()`` crashed if passed a ``sources=[..]`` argument.
962 Fixed by chrippa on pull request #60.
963
964 * Issue #193: if we use a struct between the first cdef() where it is
965 declared and another cdef() where its fields are defined, then this
966 definition was ignored.
967
968 * Enums were buggy if you used too many "..." in their definition.
969
970
971 v1.0.0
972 ------
973
974 * The main news item is out-of-line module generation:
975
976 * `for ABI level`_, with ``ffi.dlopen()``
977
978 * `for API level`_, which used to be with ``ffi.verify()``, now deprecated
979
980 * (this page will list what is new from all versions from 1.0.0
981 forward.)
982
983 .. _`for ABI level`: overview.html#out-of-line-abi-level
984 .. _`for API level`: overview.html#out-of-line-api-level