Commit Graph

11 Commits

Author SHA1 Message Date
William S Fulton 53f4751ffa Fix undefined behaviour in directorout typemaps for void * and const char *&
if the same wrapped function is called more than once. Note that using returning
pointers in directors is still full of traps and not recommended. As such,
warning SWIGWARN_TYPEMAP_DIRECTOROUT_PTR (473) continues to be issued.

The debug Python interpreter failed 3 director testcases which have been
modified in this patch to work around unrecommended director usage
returning from director methods. These are C strings and std::string_view.

A Pyton reference count leak is chosen over undefined behaviour for
returning std::string_view.
2025-05-14 22:10:39 +01:00
William S Fulton 6226d58065 Fix for using more than one std::string_view type in a method
Fixes #2844
2024-03-27 18:58:58 +00:00
William S Fulton 67bc1cbb0f Py_XDECREF -> Py_DecRef for stable ABI compliance 2024-03-24 18:12:21 +00:00
Olly Betts 0d80357cea Document directorout std::string_view limitations
See #1567
2023-12-21 14:11:23 +13:00
William S Fulton 69b2234c41 Stable abi and std::string_view
Using directorout and string_view is dangerous. Add in warning 473.

For the stable abi < Python 3.10, leak instead of undefined behaviour.
See #2727.

Update warning 473 message text to:
  Returning a reference, pointer or pointer wrapper in a director method is not recommended.
2023-12-19 21:51:03 +00:00
William S Fulton 17ca54844c Revert mistaken directorout std::string_view typemap change 2023-12-14 07:24:12 +00:00
William S Fulton 84f6031aa5 Fix std::string_view typemaps for Py_LIMITED_API
Except for directorout typemaps which are fundamentally broken as a string_view is returned when viewing a deleted char *
2023-12-13 22:12:17 +00:00
Olly Betts 71eacdf90c Avoid setting python error for bytes input 2023-05-31 11:51:07 +12:00
Olly Betts 4f73ba8653 Remove commented out code left over from development 2023-05-31 10:51:15 +12:00
Olly Betts 51431b4b14 [python] Support bytes in std::string_view typemaps
Handle bytes or unicode where we do for std::string.
2023-05-31 10:49:39 +12:00
Olly Betts 29d1f95d0d [Python] Add string_view support
Only implemented for Python 3, at least for now.

See #1567
2023-05-26 17:45:24 +12:00