Python 3.5, -builtin, excess elements in struct initializer
Fix incorrect director_classic_runme.py test Python SystemError fix with -builtin size_type-correction for SwigPySequence_Cont Python use Py_ssize_t instead of int for better portability Add python inplace-operator caveats to pyopers.swg
This commit is contained in:
parent
dade8d0afe
commit
033e781f79
33
swig.spec
33
swig.spec
@ -33,7 +33,7 @@
|
|||||||
Summary: Connects C/C++/Objective C to some high-level programming languages
|
Summary: Connects C/C++/Objective C to some high-level programming languages
|
||||||
Name: swig
|
Name: swig
|
||||||
Version: 3.0.7
|
Version: 3.0.7
|
||||||
Release: 8%{?dist}
|
Release: 9%{?dist}
|
||||||
License: GPLv3+ and BSD
|
License: GPLv3+ and BSD
|
||||||
URL: http://swig.sourceforge.net/
|
URL: http://swig.sourceforge.net/
|
||||||
Source0: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-%{version}.tar.gz
|
Source0: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-%{version}.tar.gz
|
||||||
@ -46,6 +46,23 @@ Patch2: swig307-Ruby-trackings-patch-tidy-up.patch
|
|||||||
Patch3: swig307-Ruby-trackings-support-for-1.8.patch
|
Patch3: swig307-Ruby-trackings-support-for-1.8.patch
|
||||||
Patch4: swig-ccache-conflict-fix.patch
|
Patch4: swig-ccache-conflict-fix.patch
|
||||||
|
|
||||||
|
### Python 3.5 patches, will be part of SWIG 3.0.8
|
||||||
|
### https://github.com/swig/swig/issues/539 and more.
|
||||||
|
#
|
||||||
|
# https://github.com/swig/swig/commit/ef001de5240c1e05494e23b933b687f3f266045c
|
||||||
|
Patch10: swig307-Python35-fix-builtin.patch
|
||||||
|
# https://github.com/swig/swig/commit/3e9854d308b56488e3bcae69acb4618253b49a94
|
||||||
|
Patch11: swig307-Fix-incorrect-director_classic_runme-py-test.patch
|
||||||
|
# https://github.com/swig/swig/commit/4e8ea4e853efeca6782e905a75f83a5e704a5fb0
|
||||||
|
Patch12: swig307-Python-SystemError-fix-with-builtin.patch
|
||||||
|
# https://github.com/swig/swig/commit/327b59a574c81437f79b168655feff04b12ce56d
|
||||||
|
Patch13: swig307-size_type-correction-for-SwigPySequence_Cont.patch
|
||||||
|
# https://github.com/swig/swig/commit/c5322a9ecb2b9b13ad6300cf1675192a54f952c1
|
||||||
|
Patch14: swig307-Python-use-Py_ssize_t-instead-of-int-for-better-portability.patch
|
||||||
|
# https://github.com/swig/swig/commit/625a405b8e42f944fdc1a87e36725f03b8817a85
|
||||||
|
Patch15: swig307-Add-python-inplace-operator-caveats-to-pyopers-swg.patch
|
||||||
|
|
||||||
|
|
||||||
BuildRequires: perl, python2-devel, pcre-devel
|
BuildRequires: perl, python2-devel, pcre-devel
|
||||||
BuildRequires: autoconf, automake, gawk, dos2unix
|
BuildRequires: autoconf, automake, gawk, dos2unix
|
||||||
BuildRequires: gcc-c++
|
BuildRequires: gcc-c++
|
||||||
@ -112,6 +129,12 @@ This package contains documentation for SWIG and useful examples
|
|||||||
%patch2 -p1 -b .rubytidyup
|
%patch2 -p1 -b .rubytidyup
|
||||||
%patch3 -p1 -b .ruby18
|
%patch3 -p1 -b .ruby18
|
||||||
%patch4 -p1 -b .ccache-conflict
|
%patch4 -p1 -b .ccache-conflict
|
||||||
|
%patch10 -p1 -b .python35-builtin
|
||||||
|
%patch11 -p1 -b .python35-incorrect-director
|
||||||
|
%patch12 -p1 -b .python35-systemerror-with-builtin
|
||||||
|
%patch13 -p1 -b .python35-size_type-correction
|
||||||
|
%patch14 -p1 -b .python35-use-Py_ssize_t
|
||||||
|
%patch15 -p1 -b .python35-inplace-operator-caveats
|
||||||
|
|
||||||
for all in CHANGES README; do
|
for all in CHANGES README; do
|
||||||
iconv -f ISO88591 -t UTF8 < $all > $all.new
|
iconv -f ISO88591 -t UTF8 < $all > $all.new
|
||||||
@ -211,6 +234,14 @@ ln -fs ../../bin/ccache-swig %{buildroot}%{_libdir}/ccache/swig
|
|||||||
%doc Doc Examples COPYRIGHT
|
%doc Doc Examples COPYRIGHT
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sun Dec 06 2015 Björn Esser <fedora@besser82.io> - 3.0.7-9
|
||||||
|
- add Patch10: Python 3.5, -builtin, excess elements in struct initializer
|
||||||
|
- add Patch11: Fix incorrect director_classic_runme.py test
|
||||||
|
- add Patch12: Python SystemError fix with -builtin
|
||||||
|
- add Patch13: size_type-correction for SwigPySequence_Cont
|
||||||
|
- add Patch14: Python use Py_ssize_t instead of int for better portability
|
||||||
|
- add Patch15: Add python inplace-operator caveats to pyopers.swg
|
||||||
|
|
||||||
* Wed Oct 21 2015 David Sommerseth <davids@redhat.com> - 3.0.7-8
|
* Wed Oct 21 2015 David Sommerseth <davids@redhat.com> - 3.0.7-8
|
||||||
- Ignore locally installed ccache when running CCache unit tests
|
- Ignore locally installed ccache when running CCache unit tests
|
||||||
- Resolves: bz#1274031
|
- Resolves: bz#1274031
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
From 625a405b8e42f944fdc1a87e36725f03b8817a85 Mon Sep 17 00:00:00 2001
|
||||||
|
From: William S Fulton <wsf@fultondesigns.co.uk>
|
||||||
|
Date: Sat, 5 Dec 2015 19:23:14 +0000
|
||||||
|
Subject: [PATCH] Add python inplace operator caveats to pyopers.swg
|
||||||
|
|
||||||
|
Observations reported in issue #562
|
||||||
|
---
|
||||||
|
Lib/python/pyopers.swg | 16 +++++++++++-----
|
||||||
|
1 file changed, 11 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg
|
||||||
|
index ecbe783..80a0d68 100644
|
||||||
|
--- a/Lib/python/pyopers.swg
|
||||||
|
+++ b/Lib/python/pyopers.swg
|
||||||
|
@@ -151,11 +151,11 @@ __bool__ = __nonzero__
|
||||||
|
|
||||||
|
They translate the inplace C++ operators (+=, -=, ...) into the
|
||||||
|
corresponding python equivalents(__iadd__,__isub__), etc,
|
||||||
|
- disabling the ownership of the input 'self' pointer, and assigning
|
||||||
|
+ disabling the ownership of the input 'this' pointer, and assigning
|
||||||
|
it to the returning object:
|
||||||
|
|
||||||
|
- %feature("del") *::Operator;
|
||||||
|
- %feature("new") *::Operator;
|
||||||
|
+ %feature("del") *::Operator; // disables ownership by generating SWIG_POINTER_DISOWN
|
||||||
|
+ %feature("new") *::Operator; // claims ownership by generating SWIG_POINTER_OWN
|
||||||
|
|
||||||
|
This makes the most common case safe, ie:
|
||||||
|
|
||||||
|
@@ -174,8 +174,8 @@ __bool__ = __nonzero__
|
||||||
|
that never get deleted (maybe, not sure, it depends). But if that is
|
||||||
|
the case, you could recover the old behaviour using
|
||||||
|
|
||||||
|
- %feature("del","") A::operator+=;
|
||||||
|
- %feature("new","") A::operator+=;
|
||||||
|
+ %feature("del","0") A::operator+=;
|
||||||
|
+ %feature("new","0") A::operator+=;
|
||||||
|
|
||||||
|
which recovers the old behaviour for the class 'A', or if you are
|
||||||
|
100% sure your entire system works fine in the old way, use:
|
||||||
|
@@ -183,6 +183,12 @@ __bool__ = __nonzero__
|
||||||
|
%feature("del","") *::operator+=;
|
||||||
|
%feature("new","") *::operator+=;
|
||||||
|
|
||||||
|
+ The default behaviour assumes that the 'this' pointer's memory is
|
||||||
|
+ already owned by the SWIG object; it relinquishes ownership then
|
||||||
|
+ takes it back. This may not be the case though as the SWIG object
|
||||||
|
+ might be owned by memory managed elsewhere, eg after calling a
|
||||||
|
+ function that returns a C++ reference. In such case you will need
|
||||||
|
+ to use the features above to recover the old behaviour too.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(SWIGPYTHON_BUILTIN)
|
24
swig307-Fix-incorrect-director_classic_runme-py-test.patch
Normal file
24
swig307-Fix-incorrect-director_classic_runme-py-test.patch
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
From 3e9854d308b56488e3bcae69acb4618253b49a94 Mon Sep 17 00:00:00 2001
|
||||||
|
From: William S Fulton <wsf@fultondesigns.co.uk>
|
||||||
|
Date: Sat, 10 Oct 2015 01:17:32 +0100
|
||||||
|
Subject: [PATCH] Fix incorrect director_classic_runme.py test
|
||||||
|
|
||||||
|
Python 3.5 and -builtin threw an error as the incorrect base was being
|
||||||
|
initialized.
|
||||||
|
---
|
||||||
|
Examples/test-suite/python/director_classic_runme.py | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/Examples/test-suite/python/director_classic_runme.py b/Examples/test-suite/python/director_classic_runme.py
|
||||||
|
index 9dd5f59..a4d78f1 100644
|
||||||
|
--- a/Examples/test-suite/python/director_classic_runme.py
|
||||||
|
+++ b/Examples/test-suite/python/director_classic_runme.py
|
||||||
|
@@ -69,7 +69,7 @@ def id(self):
|
||||||
|
class TargetLangOrphanChild(OrphanChild):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
- Child.__init__(self)
|
||||||
|
+ OrphanChild.__init__(self)
|
||||||
|
|
||||||
|
def id(self):
|
||||||
|
identifier = "TargetLangOrphanChild"
|
28
swig307-Python-SystemError-fix-with-builtin.patch
Normal file
28
swig307-Python-SystemError-fix-with-builtin.patch
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
From 4e8ea4e853efeca6782e905a75f83a5e704a5fb0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: William S Fulton <wsf@fultondesigns.co.uk>
|
||||||
|
Date: Sat, 14 Nov 2015 22:14:32 +0000
|
||||||
|
Subject: [PATCH] Python SystemError fix with -builtin
|
||||||
|
|
||||||
|
Fix error when append on a SWIG Object with -builtin:
|
||||||
|
|
||||||
|
x.append(10)
|
||||||
|
SystemError: error return without exception set
|
||||||
|
|
||||||
|
Having append and next methods on a SWIG object by default doesn't seem
|
||||||
|
right to me though.
|
||||||
|
---
|
||||||
|
Lib/python/pyrun.swg | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
|
||||||
|
index 5eedca4..d43b752 100644
|
||||||
|
--- a/Lib/python/pyrun.swg
|
||||||
|
+++ b/Lib/python/pyrun.swg
|
||||||
|
@@ -569,6 +569,7 @@ SwigPyObject_append(PyObject* v, PyObject* next)
|
||||||
|
next = tmp;
|
||||||
|
#endif
|
||||||
|
if (!SwigPyObject_Check(next)) {
|
||||||
|
+ PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
sobj->next = next;
|
@ -0,0 +1,404 @@
|
|||||||
|
From c5322a9ecb2b9b13ad6300cf1675192a54f952c1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: William S Fulton <wsf@fultondesigns.co.uk>
|
||||||
|
Date: Fri, 4 Dec 2015 23:32:46 +0000
|
||||||
|
Subject: [PATCH] Python use Py_ssize_t instead of int for better portability
|
||||||
|
|
||||||
|
---
|
||||||
|
Lib/python/pycontainer.swg | 25 ++++++++++++-------------
|
||||||
|
Lib/python/pyrun.swg | 12 +++++-------
|
||||||
|
Lib/python/pystrings.swg | 6 +++---
|
||||||
|
Lib/python/pywstrings.swg | 2 +-
|
||||||
|
Lib/python/std_map.i | 26 +++++++++++---------------
|
||||||
|
Lib/python/std_multimap.i | 5 ++---
|
||||||
|
Lib/python/std_unordered_map.i | 26 +++++++++++---------------
|
||||||
|
Lib/python/std_unordered_multimap.i | 5 ++---
|
||||||
|
Source/Modules/python.cxx | 6 +++---
|
||||||
|
9 files changed, 50 insertions(+), 63 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
|
||||||
|
index ceb3b66..46d0438 100644
|
||||||
|
--- a/Lib/python/pycontainer.swg
|
||||||
|
+++ b/Lib/python/pycontainer.swg
|
||||||
|
@@ -415,7 +415,7 @@ namespace swig
|
||||||
|
template <class T>
|
||||||
|
struct SwigPySequence_Ref
|
||||||
|
{
|
||||||
|
- SwigPySequence_Ref(PyObject* seq, int index)
|
||||||
|
+ SwigPySequence_Ref(PyObject* seq, Py_ssize_t index)
|
||||||
|
: _seq(seq), _index(index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@@ -427,7 +427,7 @@ namespace swig
|
||||||
|
return swig::as<T>(item, true);
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
char msg[1024];
|
||||||
|
- sprintf(msg, "in sequence element %d ", _index);
|
||||||
|
+ sprintf(msg, "in sequence element %d ", (int)_index);
|
||||||
|
if (!PyErr_Occurred()) {
|
||||||
|
::%type_error(swig::type_name<T>());
|
||||||
|
}
|
||||||
|
@@ -445,7 +445,7 @@ namespace swig
|
||||||
|
|
||||||
|
private:
|
||||||
|
PyObject* _seq;
|
||||||
|
- int _index;
|
||||||
|
+ Py_ssize_t _index;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
@@ -466,13 +466,13 @@ namespace swig
|
||||||
|
typedef Reference reference;
|
||||||
|
typedef T value_type;
|
||||||
|
typedef T* pointer;
|
||||||
|
- typedef int difference_type;
|
||||||
|
+ typedef Py_ssize_t difference_type;
|
||||||
|
|
||||||
|
SwigPySequence_InputIterator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
- SwigPySequence_InputIterator(PyObject* seq, int index)
|
||||||
|
+ SwigPySequence_InputIterator(PyObject* seq, Py_ssize_t index)
|
||||||
|
: _seq(seq), _index(index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@@ -559,7 +559,7 @@ namespace swig
|
||||||
|
typedef const SwigPySequence_Ref<T> const_reference;
|
||||||
|
typedef T value_type;
|
||||||
|
typedef T* pointer;
|
||||||
|
- typedef int difference_type;
|
||||||
|
+ typedef Py_ssize_t difference_type;
|
||||||
|
typedef size_t size_type;
|
||||||
|
typedef const pointer const_pointer;
|
||||||
|
typedef SwigPySequence_InputIterator<T, reference> iterator;
|
||||||
|
@@ -621,13 +621,13 @@ namespace swig
|
||||||
|
|
||||||
|
bool check(bool set_err = true) const
|
||||||
|
{
|
||||||
|
- int s = size();
|
||||||
|
- for (int i = 0; i < s; ++i) {
|
||||||
|
+ Py_ssize_t s = size();
|
||||||
|
+ for (Py_ssize_t i = 0; i < s; ++i) {
|
||||||
|
swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i);
|
||||||
|
if (!swig::check<value_type>(item)) {
|
||||||
|
if (set_err) {
|
||||||
|
char msg[1024];
|
||||||
|
- sprintf(msg, "in sequence element %d", i);
|
||||||
|
+ sprintf(msg, "in sequence element %d", (int)i);
|
||||||
|
SWIG_Error(SWIG_RuntimeError, msg);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
@@ -988,10 +988,9 @@ namespace swig {
|
||||||
|
%#endif
|
||||||
|
size_type size = seq.size();
|
||||||
|
if (size <= (size_type)INT_MAX) {
|
||||||
|
- PyObject *obj = PyTuple_New((int)size);
|
||||||
|
- int i = 0;
|
||||||
|
- for (const_iterator it = seq.begin();
|
||||||
|
- it != seq.end(); ++it, ++i) {
|
||||||
|
+ PyObject *obj = PyTuple_New((Py_ssize_t)size);
|
||||||
|
+ Py_ssize_t i = 0;
|
||||||
|
+ for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) {
|
||||||
|
PyTuple_SetItem(obj,i,swig::from<value_type>(*it));
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
|
||||||
|
index d43b752..85ff276 100644
|
||||||
|
--- a/Lib/python/pyrun.swg
|
||||||
|
+++ b/Lib/python/pyrun.swg
|
||||||
|
@@ -161,7 +161,7 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
|
||||||
|
|
||||||
|
/* Unpack the argument tuple */
|
||||||
|
|
||||||
|
-SWIGINTERN int
|
||||||
|
+SWIGINTERN Py_ssize_t
|
||||||
|
SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
|
||||||
|
{
|
||||||
|
if (!args) {
|
||||||
|
@@ -175,7 +175,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
|
||||||
|
}
|
||||||
|
if (!PyTuple_Check(args)) {
|
||||||
|
if (min <= 1 && max >= 1) {
|
||||||
|
- int i;
|
||||||
|
+ Py_ssize_t i;
|
||||||
|
objs[0] = args;
|
||||||
|
for (i = 1; i < max; ++i) {
|
||||||
|
objs[i] = 0;
|
||||||
|
@@ -195,7 +195,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
|
||||||
|
name, (min == max ? "" : "at most "), (int)max, (int)l);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
- int i;
|
||||||
|
+ Py_ssize_t i;
|
||||||
|
for (i = 0; i < l; ++i) {
|
||||||
|
objs[i] = PyTuple_GET_ITEM(args, i);
|
||||||
|
}
|
||||||
|
@@ -1515,13 +1515,11 @@ PyModule_AddObject(PyObject *m, char *name, PyObject *o)
|
||||||
|
{
|
||||||
|
PyObject *dict;
|
||||||
|
if (!PyModule_Check(m)) {
|
||||||
|
- PyErr_SetString(PyExc_TypeError,
|
||||||
|
- "PyModule_AddObject() needs module as first arg");
|
||||||
|
+ PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg");
|
||||||
|
return SWIG_ERROR;
|
||||||
|
}
|
||||||
|
if (!o) {
|
||||||
|
- PyErr_SetString(PyExc_TypeError,
|
||||||
|
- "PyModule_AddObject() needs non-NULL value");
|
||||||
|
+ PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value");
|
||||||
|
return SWIG_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg
|
||||||
|
index 2b14547..2eefaef 100644
|
||||||
|
--- a/Lib/python/pystrings.swg
|
||||||
|
+++ b/Lib/python/pystrings.swg
|
||||||
|
@@ -90,12 +90,12 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
||||||
|
} else {
|
||||||
|
%#if PY_VERSION_HEX >= 0x03000000
|
||||||
|
%#if PY_VERSION_HEX >= 0x03010000
|
||||||
|
- return PyUnicode_DecodeUTF8(carray, %numeric_cast(size,int), "surrogateescape");
|
||||||
|
+ return PyUnicode_DecodeUTF8(carray, %numeric_cast(size, Py_ssize_t), "surrogateescape");
|
||||||
|
%#else
|
||||||
|
- return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int));
|
||||||
|
+ return PyUnicode_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t));
|
||||||
|
%#endif
|
||||||
|
%#else
|
||||||
|
- return PyString_FromStringAndSize(carray, %numeric_cast(size,int));
|
||||||
|
+ return PyString_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t));
|
||||||
|
%#endif
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg
|
||||||
|
index 864376b..79f193b 100644
|
||||||
|
--- a/Lib/python/pywstrings.swg
|
||||||
|
+++ b/Lib/python/pywstrings.swg
|
||||||
|
@@ -58,7 +58,7 @@ SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
|
||||||
|
return pwchar_descriptor ?
|
||||||
|
SWIG_InternalNewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : SWIG_Py_Void();
|
||||||
|
} else {
|
||||||
|
- return PyUnicode_FromWideChar(carray, %numeric_cast(size,int));
|
||||||
|
+ return PyUnicode_FromWideChar(carray, %numeric_cast(size, Py_ssize_t));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return SWIG_Py_Void();
|
||||||
|
diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i
|
||||||
|
index 454e821..65dd91d 100644
|
||||||
|
--- a/Lib/python/std_map.i
|
||||||
|
+++ b/Lib/python/std_map.i
|
||||||
|
@@ -119,10 +119,9 @@
|
||||||
|
static PyObject *asdict(const map_type& map) {
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
size_type size = map.size();
|
||||||
|
- int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
+ Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1;
|
||||||
|
if (pysize < 0) {
|
||||||
|
- PyErr_SetString(PyExc_OverflowError,
|
||||||
|
- "map size not valid in python");
|
||||||
|
+ PyErr_SetString(PyExc_OverflowError, "map size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@@ -211,17 +210,16 @@
|
||||||
|
|
||||||
|
PyObject* keys() {
|
||||||
|
Map::size_type size = self->size();
|
||||||
|
- int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
+ Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
if (pysize < 0) {
|
||||||
|
- PyErr_SetString(PyExc_OverflowError,
|
||||||
|
- "map size not valid in python");
|
||||||
|
+ PyErr_SetString(PyExc_OverflowError, "map size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
PyObject* keyList = PyList_New(pysize);
|
||||||
|
Map::const_iterator i = self->begin();
|
||||||
|
- for (int j = 0; j < pysize; ++i, ++j) {
|
||||||
|
+ for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
|
||||||
|
PyList_SET_ITEM(keyList, j, swig::from(i->first));
|
||||||
|
}
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
@@ -230,17 +228,16 @@
|
||||||
|
|
||||||
|
PyObject* values() {
|
||||||
|
Map::size_type size = self->size();
|
||||||
|
- int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
+ Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
if (pysize < 0) {
|
||||||
|
- PyErr_SetString(PyExc_OverflowError,
|
||||||
|
- "map size not valid in python");
|
||||||
|
+ PyErr_SetString(PyExc_OverflowError, "map size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
PyObject* valList = PyList_New(pysize);
|
||||||
|
Map::const_iterator i = self->begin();
|
||||||
|
- for (int j = 0; j < pysize; ++i, ++j) {
|
||||||
|
+ for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
|
||||||
|
PyList_SET_ITEM(valList, j, swig::from(i->second));
|
||||||
|
}
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
@@ -249,17 +246,16 @@
|
||||||
|
|
||||||
|
PyObject* items() {
|
||||||
|
Map::size_type size = self->size();
|
||||||
|
- int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
+ Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
if (pysize < 0) {
|
||||||
|
- PyErr_SetString(PyExc_OverflowError,
|
||||||
|
- "map size not valid in python");
|
||||||
|
+ PyErr_SetString(PyExc_OverflowError, "map size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
PyObject* itemList = PyList_New(pysize);
|
||||||
|
Map::const_iterator i = self->begin();
|
||||||
|
- for (int j = 0; j < pysize; ++i, ++j) {
|
||||||
|
+ for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
|
||||||
|
PyList_SET_ITEM(itemList, j, swig::from(*i));
|
||||||
|
}
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i
|
||||||
|
index c81e2ac..2c539cf 100644
|
||||||
|
--- a/Lib/python/std_multimap.i
|
||||||
|
+++ b/Lib/python/std_multimap.i
|
||||||
|
@@ -45,11 +45,10 @@
|
||||||
|
return SWIG_InternalNewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN);
|
||||||
|
} else {
|
||||||
|
size_type size = multimap.size();
|
||||||
|
- int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
+ Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1;
|
||||||
|
if (pysize < 0) {
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
- PyErr_SetString(PyExc_OverflowError,
|
||||||
|
- "multimap size not valid in python");
|
||||||
|
+ PyErr_SetString(PyExc_OverflowError, "multimap size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i
|
||||||
|
index e58a4e9..f956f4f 100644
|
||||||
|
--- a/Lib/python/std_unordered_map.i
|
||||||
|
+++ b/Lib/python/std_unordered_map.i
|
||||||
|
@@ -48,11 +48,10 @@
|
||||||
|
return SWIG_NewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN);
|
||||||
|
} else {
|
||||||
|
size_type size = unordered_map.size();
|
||||||
|
- int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
+ Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1;
|
||||||
|
if (pysize < 0) {
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
- PyErr_SetString(PyExc_OverflowError,
|
||||||
|
- "unordered_map size not valid in python");
|
||||||
|
+ PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@@ -164,17 +163,16 @@
|
||||||
|
|
||||||
|
PyObject* keys() {
|
||||||
|
Map::size_type size = self->size();
|
||||||
|
- int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
+ Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
|
||||||
|
if (pysize < 0) {
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
- PyErr_SetString(PyExc_OverflowError,
|
||||||
|
- "unordered_map size not valid in python");
|
||||||
|
+ PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
PyObject* keyList = PyList_New(pysize);
|
||||||
|
Map::const_iterator i = self->begin();
|
||||||
|
- for (int j = 0; j < pysize; ++i, ++j) {
|
||||||
|
+ for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
|
||||||
|
PyList_SET_ITEM(keyList, j, swig::from(i->first));
|
||||||
|
}
|
||||||
|
return keyList;
|
||||||
|
@@ -182,17 +180,16 @@
|
||||||
|
|
||||||
|
PyObject* values() {
|
||||||
|
Map::size_type size = self->size();
|
||||||
|
- int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
+ Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
|
||||||
|
if (pysize < 0) {
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
- PyErr_SetString(PyExc_OverflowError,
|
||||||
|
- "unordered_map size not valid in python");
|
||||||
|
+ PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
PyObject* valList = PyList_New(pysize);
|
||||||
|
Map::const_iterator i = self->begin();
|
||||||
|
- for (int j = 0; j < pysize; ++i, ++j) {
|
||||||
|
+ for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
|
||||||
|
PyList_SET_ITEM(valList, j, swig::from(i->second));
|
||||||
|
}
|
||||||
|
return valList;
|
||||||
|
@@ -200,17 +197,16 @@
|
||||||
|
|
||||||
|
PyObject* items() {
|
||||||
|
Map::size_type size = self->size();
|
||||||
|
- int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
+ Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
|
||||||
|
if (pysize < 0) {
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
- PyErr_SetString(PyExc_OverflowError,
|
||||||
|
- "unordered_map size not valid in python");
|
||||||
|
+ PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
PyObject* itemList = PyList_New(pysize);
|
||||||
|
Map::const_iterator i = self->begin();
|
||||||
|
- for (int j = 0; j < pysize; ++i, ++j) {
|
||||||
|
+ for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
|
||||||
|
PyList_SET_ITEM(itemList, j, swig::from(*i));
|
||||||
|
}
|
||||||
|
return itemList;
|
||||||
|
diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i
|
||||||
|
index adf86f2..b3b7236 100644
|
||||||
|
--- a/Lib/python/std_unordered_multimap.i
|
||||||
|
+++ b/Lib/python/std_unordered_multimap.i
|
||||||
|
@@ -45,11 +45,10 @@
|
||||||
|
return SWIG_NewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN);
|
||||||
|
} else {
|
||||||
|
size_type size = unordered_multimap.size();
|
||||||
|
- int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
+ Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1;
|
||||||
|
if (pysize < 0) {
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
- PyErr_SetString(PyExc_OverflowError,
|
||||||
|
- "unordered_multimap size not valid in python");
|
||||||
|
+ PyErr_SetString(PyExc_OverflowError, "unordered_multimap size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
|
||||||
|
index 570f8fa..e91047a 100644
|
||||||
|
--- a/Source/Modules/python.cxx
|
||||||
|
+++ b/Source/Modules/python.cxx
|
||||||
|
@@ -2473,15 +2473,15 @@ class PYTHON:public Language {
|
||||||
|
|
||||||
|
Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args) {", NIL);
|
||||||
|
|
||||||
|
- Wrapper_add_local(f, "argc", "int argc");
|
||||||
|
+ Wrapper_add_local(f, "argc", "Py_ssize_t argc");
|
||||||
|
Printf(tmp, "PyObject *argv[%d] = {0}", maxargs + 1);
|
||||||
|
Wrapper_add_local(f, "argv", tmp);
|
||||||
|
|
||||||
|
if (!fastunpack) {
|
||||||
|
- Wrapper_add_local(f, "ii", "int ii");
|
||||||
|
+ Wrapper_add_local(f, "ii", "Py_ssize_t ii");
|
||||||
|
if (maxargs - (add_self ? 1 : 0) > 0)
|
||||||
|
Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n");
|
||||||
|
- Append(f->code, "argc = args ? (int)PyObject_Length(args) : 0;\n");
|
||||||
|
+ Append(f->code, "argc = args ? PyObject_Length(args) : 0;\n");
|
||||||
|
if (add_self)
|
||||||
|
Append(f->code, "argv[0] = self;\n");
|
||||||
|
Printf(f->code, "for (ii = 0; (ii < %d) && (ii < argc); ii++) {\n", add_self ? maxargs - 1 : maxargs);
|
28
swig307-Python35-fix-builtin.patch
Normal file
28
swig307-Python35-fix-builtin.patch
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
From ef001de5240c1e05494e23b933b687f3f266045c Mon Sep 17 00:00:00 2001
|
||||||
|
From: William S Fulton <wsf@fultondesigns.co.uk>
|
||||||
|
Date: Sat, 10 Oct 2015 00:38:52 +0100
|
||||||
|
Subject: [PATCH] Support Python 3.5 and -builtin.
|
||||||
|
|
||||||
|
PyAsyncMethods is a new member in PyHeapTypeObject.
|
||||||
|
Closes#539
|
||||||
|
|
||||||
|
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
|
||||||
|
index 7bc5658..3395ebe 100644
|
||||||
|
--- a/Source/Modules/python.cxx
|
||||||
|
+++ b/Source/Modules/python.cxx
|
||||||
|
@@ -4053,6 +4053,15 @@ class PYTHON:public Language {
|
||||||
|
Printv(f, "#endif\n", NIL);
|
||||||
|
Printf(f, " },\n");
|
||||||
|
|
||||||
|
+ // PyAsyncMethods as_async
|
||||||
|
+ Printv(f, "#if PY_VERSION_HEX >= 0x03050000\n", NIL);
|
||||||
|
+ Printf(f, " {\n");
|
||||||
|
+ printSlot(f, getSlot(n, "feature:python:am_await"), "am_await", "unaryfunc");
|
||||||
|
+ printSlot(f, getSlot(n, "feature:python:am_aiter"), "am_aiter", "unaryfunc");
|
||||||
|
+ printSlot(f, getSlot(n, "feature:python:am_anext"), "am_anext", "unaryfunc");
|
||||||
|
+ Printf(f, " },\n");
|
||||||
|
+ Printv(f, "#endif\n", NIL);
|
||||||
|
+
|
||||||
|
// PyNumberMethods as_number
|
||||||
|
Printf(f, " {\n");
|
||||||
|
printSlot(f, getSlot(n, "feature:python:nb_add"), "nb_add", "binaryfunc");
|
22
swig307-size_type-correction-for-SwigPySequence_Cont.patch
Normal file
22
swig307-size_type-correction-for-SwigPySequence_Cont.patch
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
From 327b59a574c81437f79b168655feff04b12ce56d Mon Sep 17 00:00:00 2001
|
||||||
|
From: William S Fulton <wsf@fultondesigns.co.uk>
|
||||||
|
Date: Sat, 28 Nov 2015 23:52:32 +0000
|
||||||
|
Subject: [PATCH] size_type correction for SwigPySequence_Cont
|
||||||
|
|
||||||
|
---
|
||||||
|
Lib/python/pycontainer.swg | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
|
||||||
|
index 7c5cc37..ceb3b66 100644
|
||||||
|
--- a/Lib/python/pycontainer.swg
|
||||||
|
+++ b/Lib/python/pycontainer.swg
|
||||||
|
@@ -567,7 +567,7 @@ namespace swig
|
||||||
|
typedef T value_type;
|
||||||
|
typedef T* pointer;
|
||||||
|
typedef int difference_type;
|
||||||
|
- typedef int size_type;
|
||||||
|
+ typedef size_t size_type;
|
||||||
|
typedef const pointer const_pointer;
|
||||||
|
typedef SwigPySequence_InputIterator<T, reference> iterator;
|
||||||
|
typedef SwigPySequence_InputIterator<T, const_reference> const_iterator;
|
Loading…
Reference in New Issue
Block a user