summaryrefslogtreecommitdiff
path: root/Lib/python
Commit message (Collapse)AuthorAgeFilesLines
* Eliminate sprintf in generated python codeSeth R Johnson2022-12-061-3/+3
| | | | | | | Newer clang versions emit warnings in generated code: ``` warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations] ```
* Use more portable PyUnicode_AsUTF8* methods.Clinton Stimpson2022-11-011-1/+8
| | | | | This supports the use of Py_LIMITED_API and also uses PyUnicode_AsUTF8AndSize if Py_LIMITED_API is set to 3.10 or newer.
* [python] Avoid undefined behaviourOlly Betts2022-10-201-5/+9
| | | | | | | Cast a parameter type explicitly rather than implicitly by casting the function pointer type, as the latter is undefined behaviour. Caught by ubsan.
* Define PY_SSIZE_T_CLEAN only when not defined yetMichal Suchanek2022-10-132-2/+2
| | | | | | | | | | | Users of swig 4.0.2 and python 3.10 will likely define the PY_SSIZE_T_CLEAN macro by hand when relevant because their bindings won't build otherwise. Unconditionally defining PY_SSIZE_T_CLEAN in swig 4.10 will lead to macro redefinition warning. Signed-off-by: Michal Suchanek <msuchanek@suse.de>
* Remove dead conditional codeOlly Betts2022-10-061-6/+0
| | | | | SWIG_POINTER_EXCEPTION has had the value zero since 2006 (it's only still present for backward compatibility).
* [Python] Remove deprecated and apparently useless defarg.swgOlly Betts2022-10-062-38/+0
| | | | | | | | | | | | The only documentation is in the file itself and describes a Python wrapper around the C function defined here, but digging though the git history this Python wrapper doesn't seem to have ever actually been generated by SWIG. This file was also marked as deprecated in 2005. Fixes #2390 Fixes #2391
* Merge branch 'python_subinterpreter_issues'William S Fulton2022-10-051-7/+13
|\ | | | | | | | | | | | | | | | | | | | | * python_subinterpreter_issues: added comment in CHANGES.current always get the type_pointer from capsule instead of using a static variable as the value may change after re-initilization/due to subinterpreters added interpreter_counter to deinitialize only once in case of subinterpreters Conflicts: CHANGES.current Lib/python/pyrun.swg
| * always get the type_pointer from capsule instead of using a static variablebenjamin-sch2022-02-081-7/+7
| | | | | | | | as the value may change after re-initilization/due to subinterpreters
| * added interpreter_counter to deinitialize only once in case of subinterpretersbenjamin-sch2022-02-081-0/+6
| |
* | Add missing typecheck typemaps for std::auto_ptr and std::unique_ptrWilliam S Fulton2022-09-172-0/+12
| | | | | | | | To fix overloading when using these types.
* | Provide SWIGTYPE MOVE typemaps in swigmove.iWilliam S Fulton2022-09-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | For implementing full move semantics when passing parameters by value. Based on SWIGTYPE && and std::unique_ptr typemaps which implement move semantics. Added for all languages, but untested for: Go, Ocaml, R, Scilab (and unlikely to be fully functional for same reasons as for std::unique_ptr support). Issue #999
* | Update comments re _DEBUG redefinition before including Python.hWilliam S Fulton2022-09-091-3/+2
| |
* | Visual C++ debug builds linking to Python release buildsWilliam S Fulton2022-09-091-7/+8
| | | | | | | | | | | | | | | | | | Only use the corecrt.h workaround for #2090 when using SWIG_PYTHON_INTERPRETER_NO_DEBUG as the problem seems to only occur when undefining _DEBUG. Also extend workaround for Visual Studio 2019 version 16.10 and 16.11 as per #2174 (_MSC_VER=1929).
* | Merge pull request #2344 from clintonstimpson/py3-slice-objectWilliam S Fulton2022-09-081-14/+14
|\ \ | | | | | | Use PyObject instead of PySliceObject throughout with Python 3.2+
| * | Use PyObject instead of PySliceObject throughout with Python 3.2+Clinton Stimpson2022-09-051-14/+14
| | | | | | | | | | | | This supports use of the Py_LIMITED_API.
* | | Merge branch 'rvalue-move'William S Fulton2022-09-083-26/+26
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * rvalue-move: rvalue reference outputs Remove broken %implicitconv for const SWIGTYPE && Remove unnecessary const SWIGTYPE & typemap Temporarily remove rvalue reference python runtime test std::auto_ptr emulation fix in test case Ocaml typemap typo fix Fix Racket tests using schemerunme directory Docs on rvalue parameter changes Test/fixes to handle NULL pointer for unique_ptr/auto_ptr Octave - SWIG now marshalls a C/C++ NULL pointer into the null matrix, [] Racket - NULL pointer handling SWIGTYPE && input typemaps now assume object has been moved - Go and OCaml SWIGTYPE && input typemaps now assume object has been moved SWIGTYPE && input typemaps now assume object has been moved - Java Cosmetic stray semi-colon removal after %typemap using quotes Cosmetic stray semi-colon removal after %typemap
| * | | Cosmetic stray semi-colon removal after %typemap using quotesWilliam S Fulton2022-08-313-26/+26
| |/ /
* | | Python: Use PyType_Modified() instead of modifying flags.Clinton Stimpson2022-09-021-1/+1
|/ / | | | | | | | | Closes #2345 Also supported with Py_LIMITED_API
* | Add initialisers for additional members in PyHeapTypeObjectWilliam S Fulton2022-08-011-1/+1
| | | | | | | | (builtin mode) for Python-3.11 - _ht_tpname, _spec_cache.
* | [python] Fix inheriting from multiple director classesOlly Betts2022-07-201-0/+1
| | | | | | | | | | | | | | | | Fix mishandling of a Python class inheriting from multiple SWIG-wrapped director classes. Fixes #422 Fixes https://sourceforge.net/p/swig/bugs/1379/
* | Merge branch 'unique_ptr-inputs'William S Fulton2022-07-193-19/+54
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * unique_ptr-inputs: std::unique_ptr std::auto_ptr tidyup Add support for std::auto_ptr inputs Cosmetic formatting and doc updates in std_unique_ptr.i files Add Perl support for std::unique_ptr inputs Add Ruby support for std::unique_ptr inputs Add Python support for std::unique_ptr inputs Add C# support std::unique_ptr inputs Java unique_ptr test ownership enhancement to test Java unique_ptr enhance test for double release SWIGTYPE && input typemaps now assume object has been moved Add Java support for std::unique<T> for input parameters. Closes #692 Conflicts: CHANGES.current
| * | Add support for std::auto_ptr inputsWilliam S Fulton2022-07-181-7/+21
| | | | | | | | | | | | Ported from std::unique, behaviour is identical with regard to memory ownership/handling
| * | Cosmetic formatting and doc updates in std_unique_ptr.i filesWilliam S Fulton2022-07-171-7/+8
| | |
| * | Add Python support for std::unique_ptr inputsWilliam S Fulton2022-07-172-5/+25
| | | | | | | | | | | | Equivalent to Java/C# implementation.
* | | Update everything for dropping Python 3.2 supportOlly Betts2022-07-193-25/+3
| | |
* | | Drop support for Python 3.2Julien Schueller2022-07-191-2/+2
|/ / | | | | | | Closes #2314
* | More move semantics improvementsWilliam S Fulton2022-07-041-2/+2
| | | | | | | | | | More removal of casts in the out typemaps when copying objects to enable C++ compilers to possibly make use of move semantics.
* | Performance optimisation for directors for classes passed by valueWilliam S Fulton2022-07-041-1/+1
| | | | | | | | | | | | | | The directorin typemaps in the director methods now use std::move on the input parameter when copying the object from the stack to the heap prior to the callback into the target language, thereby taking advantage of move semantics if available.
* | Cosmetic changes to auto_ptr library filesWilliam S Fulton2022-07-021-8/+10
| |
* | Add std::unique supportWilliam S Fulton2022-07-021-0/+19
| | | | | | | | | | | | | | Simple copy of current auto_ptr support (just suppport for functions returning std::unique_ptr). Closes #1722
* | Suppress -Wregister gcc warnings in Python.hWilliam S Fulton2022-05-272-0/+24
| | | | | | | | | | | | | | Such as: /usr/include/python2.7/unicodeobject.h:534:24: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister] Closes #2227
* | Merge branch 'python'William S Fulton2022-05-272-1/+6
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | * python: Define PY_SSIZE_T_CLEAN macro Python: define PY_SSIZE_T_CLEAN Conflicts: CHANGES.current
| * | Define PY_SSIZE_T_CLEAN macroWilliam S Fulton2022-05-272-2/+2
| | | | | | | | | | | | | | | | | | before #include "Python.h" as recommended in Python 3.7 and later. Issue #2277
| * | Python: define PY_SSIZE_T_CLEANHeinrich Schuchardt2022-05-102-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is recommended to always define PY_SSIZE_T_CLEAN before including Python.h. Cf. https://docs.python.org/3/c-api/intro.html This avoids errors like: SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* | | Merge branch 'more_argcargv'William S Fulton2022-05-151-8/+5
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | * more_argcargv: Document argc argv library argcargv.i cosmetic updates Typemaps for (int ARGC, char **ARGV) fixup Fix argcargv.i in Perl5, Tcl, PHP Add missing type map for type check. Add testing of argcargv.i for Perl5, Tcl, PHP and Ruby. Add Lua test for argcargv.i Add argcargv.i to more languages: Perl 5, Tcl, PHP Add argcargv.i to Lua
| * | argcargv.i cosmetic updatesWilliam S Fulton2022-05-151-8/+5
| | |
* | | Visual C++ warning fix in Python < 3.2 builtin wrappersWilliam S Fulton2022-05-071-0/+4
| | | | | | | | | | | | | | | | | | Fixes: warning C4311: 'type cast': pointer truncation from 'void *' to 'long' warning C4302: 'type cast': truncation from 'void *' to 'long'
* | | fix white-spaceKris Thielemans2022-04-281-4/+4
| | |
* | | [Python] Replace tp_print with tp_vectorcall_offset slot for Python 3.8Kris Thielemans2022-04-212-5/+25
|/ / | | | | | | | | | | | | The tp_print slot is no longer supported and replaced with tp_vectorcall_offset. The (printfunc) cast that we used caused problems on PyPy. Fixes #2262
* | Merge branch 'feature/python-builtin-separate-runtime-data'William S Fulton2022-03-262-2/+7
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | * feature/python-builtin-separate-runtime-data: Rework swig_and_compile_multi_cpp makefile helper Different capsule names for builtin changes entry Use different capsule names with and without -builtin Conflicts: CHANGES.current
| * | Use different capsule names with and without -builtinEugene Toder2022-03-182-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | Types generated with and without -builtin are not compatible. Mixing them in a common type list leads to crashes. Avoid this by using different capsule names: "type_pointer_capsule" without -builtin and "type_pointer_capsule_builtin" with. See #1684
* | | Add Python < 3.3 support for pyabc.iWilliam S Fulton2022-03-231-8/+12
|/ / | | | | | | | | | | | | pyabc.i for abstract base classes now supports versions of Python prior to 3.3 by using the collection module for these older versions. Python-3.3 and later continue to use the collections.abc module. The -py3 option no longer has any effect on the %pythonabc feature.
* | Add some code comments about Python objects and capsule reference countingWilliam S Fulton2022-03-151-0/+3
| | | | | | | | Issue #2208
* | Fix SWIG_Py*Method_New conditionalOlly Betts2022-03-141-2/+18
| | | | | | | | | | | | | | This should be a SWIG-time conditional, but was inside %{ %} so was instead a compile-time conditional. Fix for bug in the changes in #2191
* | [Python] Fix memory leak.Olly Betts2022-03-071-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | SWIG python objects were being freed after the corresponding SWIG module information was destroyed in Python 3, causing leaks when as a result the object destructor could not be invoked. To prevent this misordering, SWIG python objects now obtain a reference to the Python capsule wrapping the module information, so that the module information is correctly destroyed after all SWIG python objects have been freed (and corresponding destructors invoked). Fixes #2154 Fixes #2208
* | Fix typos in docs and commentsOlly Betts2022-02-271-1/+1
| |
* | Renames performed by `%namewarn` with `rename=` are printed in warning messageSeth R Johnson2022-02-061-1/+1
|/ | | | | | This is necessary for regex-like renames (where you can't use the #define trick as is done in many of the %keywordwarn directives). It's now unnecessary to print the "renaming to '`x`'" code explicitly by the kw.swg files.
* [Python] Improve handling of SWIG_Py*Method_NewOlly Betts2022-02-041-0/+8
| | | | | | | | | | | | | | | The SWIG_PyInstanceMethod_New method is no longer added to wrapped classes except when it's actually needed, which is when (!builtin && fastproxy) is true (which it isn't by default). The SWIG_PyStaticMethod_New method is no longer is now similarly gated - previously only (fastproxy) was checked. Finally the C/C++ functions that implement these were always compiled into the module, but now they're only included if (!builtin && fastproxy) is true. Issue noted by vadz in #2190.
* [python] Workaround MSVC2022-related bugOlly Betts2022-02-031-0/+7
| | | | Fixes #2090
* [python] Remove unused bogus fallback macroOlly Betts2022-01-271-1/+0
| | | | | | | | | | | | | This fallback version of PyString_AS_STRING() for Python 3 makes use of PyUnicode_AS_STRING, but I can find no evidence that ever existed in Python - all references I've found are to SWIG or SWIG-generated code. The only uses of PyString_AS_STRING() in SWIG generated code are for Python 2 #if-branches, so this fallback is never used by SWIG. Because it doesn't work it can't be usefully used in user interface files either, so let's remove it to avoid potential user confusion (such as #987).