Commit graph

34 commits

Author SHA1 Message Date
Olly Betts
0b9d4eff09 Update everything for dropping Python 3.2 support 2022-07-19 13:20:07 +12:00
Eugene Toder
f733efd3c0 Use different capsule names with and without -builtin
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
2022-03-18 13:44:54 -04:00
Olly Betts
7963807308 [python] Remove unused bogus fallback macro
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).
2022-01-27 09:32:25 +13:00
William S Fulton
57957787b7 Convert C++ comment to C comment 2020-10-10 14:53:46 +01:00
Zackery Spytz
f6d97d2338 Use PyUnicode_AsUTF8() for Python >= 3.3 2020-01-31 23:48:32 -07:00
Zackery Spytz
58e409dd2b Fix possible refleaks. 2020-01-29 10:00:22 -07:00
Zackery Spytz
6adf19b52f Check Py{Bytes,String}_AsStringAndSize() for failure
PyBytes_AsStringAndSize() and PyString_AsStringAndSize() were not
being checked for failure.

Closes #1349.
2020-01-09 21:14:12 -07:00
Olly Betts
2ea976f1d8 Always use PyCapsule
It is supported by all the Python versions we now support.
2018-06-08 11:08:31 +12:00
Olly Betts
7c034ead32 Remove special handling for Python < 2.6
See #701.
2018-06-08 09:34:48 +12:00
William S Fulton
b0e29fbdf3 Add missing checks for failures in calls to PyUnicode_AsUTF8String.
Previously a seg fault could occur when passing invalid UTF8 strings (low
surrogates), eg passing u"\udcff" to the C layer (Python 3).
2017-12-04 20:14:04 +00:00
William S Fulton
5b7c08c214 Make Python builtin types hashable by default
Default hash is the underlying C/C++ pointer.
This matches up with testing for equivalence (Py_EQ in SwigPyObject_richcompare)
which compares the pointers.
2016-08-23 19:06:36 +01:00
Olly Betts
bfe3adbd0a Remove lingering code for compatibility with Python < 1.6 2016-01-27 15:17:36 +13:00
William S Fulton
16481c999e Bug #3563647 - PyInt_FromSize_t unavailable prior to Python 2.5 for unsigned int types
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13953 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-12-09 20:49:52 +00:00
William S Fulton
68862691e6 Fix #3541744 - Missing PyInt_FromSize_t calls for Python 3
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13608 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-15 07:48:57 +00:00
William S Fulton
68a135860d Revert rev 12835 as it introduces a failure in the test-suite (primitive_types test)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12983 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-14 17:30:03 +00:00
Stefan Zager
2bf6de71b8 bug 3429388: python unsigned integer handling on 32-bit architectures.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12835 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-11-05 03:35:03 +00:00
Stefan Zager
a52612f845 Fixed PyGetSetDescr for python3.2.
Fixed memory management in special_variable_macros test.

Don't define asdict() for multimap.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12659 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-05-08 06:54:21 +00:00
Stefan Zager
17af467132 Fix for bug #3057804: migrate PyCObject to PyCapsule.
Other misc. fixes for python3.2, mostly dealing with changed
interfaces to python functions.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12620 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-09 22:07:22 +00:00
William S Fulton
71be2441c2 Fix C python < 2.5 wrappers
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12605 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-03 20:02:08 +00:00
Stefan Zager
90fe22acf7 Fix for METH_O and -compactdefaultargs, in two parts:
- Don't mark a method as METH_O if it has compactdefaultargs
  - In SWIG_Python_UnpackTuple, allow for a non-tuple 'args'.

Added compatibility for python versions 2.3 and 2.4.  These are only
partially supported; inheriting from wrapped types looks problematic.
Versions older that 2.3 are unlikely ever to work.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12590 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-02 21:40:00 +00:00
Stefan Zager
011049ffe2 Another macro define for unicode.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12447 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-10 05:04:12 +00:00
Stefan Zager
b5889b8b0f Unicode fixes for python3.
Added a few more closure types.

Guard against operator overloads outside of a class declaration.

Incorporate fix for patch #3171793.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12446 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-09 08:59:09 +00:00
Stefan Zager
62fef1bf99 python3 support; passes all regressions.
Adding argcargvtest_runme3.py, because 2to3 can't handle it.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12425 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-03 07:21:37 +00:00
Olly Betts
1c91a4a9b9 int -> Py_ssize_t to fix 64 bit Python 3 failure to compile generated code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11195 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-04-29 13:43:23 +00:00
Olly Betts
6d8ea4f7fa Fix comment typos
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11193 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-04-29 12:00:38 +00:00
Haoyu Bai
a863d31e81 Fix the memory leak related to Python 3 unicode and char * conversion.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11160 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-03-19 15:26:57 +00:00
William S Fulton
7ec3c4ae81 minor typo and formatting improvements
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10868 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-09-18 20:16:50 +00:00
Haoyu Bai
3d8ddfc442 Merged the Python 3.0 support branch. The merging progress is not so smooth, so hope this commit won't make anything broken.
This is the (incomplemete) log produced by svnmerge.py:

Merged revisions 10405-10409,10420-10422,10426,10438,10445,10451,10454-10465,10467,10473-10475,10485,10488-10489,10493-10495,10497,10509-10510,10513-10514,10517,10520,10525,10528-10529,10533-10535,10554-10557,10570,10573,10593,10614,10666-10669,10673,10678,10687,10690,10704-10706,10731,10744,10750-10752,10755,10759,10770,10775-10776,10813,10819 via svnmerge from 
https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10834 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-09-11 17:18:07 +00:00
Olly Betts
e19603cb51 Improve how/when we define Py_ssize_t to match the way the python developers
recommend, so that it works if the user includes headers from something like
numpy which also defines Py_ssize_t.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9546 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-11-12 01:33:58 +00:00
William S Fulton
d6d23465e0 Patch from Michal Marek for Python 2.5 to fix 64 bit array indexes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9289 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-09-16 09:57:26 +00:00
William S Fulton
e238bed36a remove double include of python header file
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9282 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-09-14 22:39:52 +00:00
Marcelo Matus
a2c99f619d reduce the aliasing warnings (when compiling with CFLAGS='-O2 -Wstrict-aliasing=2') to the minimum, ie, enums and pointer to functions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8883 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-23 21:43:33 +00:00
Marcelo Matus
52106b3c6e fix for Py_NotImplemented as reported by Olly and Amaury
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8862 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-22 16:59:00 +00:00
Marcelo Matus
0d6baa85ef fix -external-runtime
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8654 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-31 00:02:58 +00:00