summaryrefslogtreecommitdiff
path: root/Lib/python
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2015-01-14 13:45:55 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2015-01-14 13:45:55 +0000
commitefa96eb76d4f1a6b14633ab653699352936fe3d1 (patch)
tree0b13e154013ab12d06cf0eadd4740d9fd9b79731 /Lib/python
parent6d86fb173915867bd70d6780a174bce3c5b3c1df (diff)
parent4fed2e6690b1486952b0543b6bde28573eb0d132 (diff)
downloadswig-coverity-scan.tar.gz
Merge branch 'master' into coverity-scancoverity-scan
* master: (478 commits) Use -rrbconfig rather than -rmkmf to load rbconfig Add suggestion to check block delimiter Add explanatory comment to pp_unknowndirective2.i Fix PHP crash in director_finalizer Add 3.0.4 release information Fix typo Note 1.8 as the oldest supported version Fix PHP backend for default_args testcase Update html Python 3 default args fix Revert introduction of python:defaultargs feature Ruby: Replace Config::CONFIG with RbConfig::CONFIG in configure.ac Add regression test for #217 [PHP] Fix segfault in director upcall check Fix linux gcc warnings and strtol corrections Tests for Python default arguments and %pythondefaultargs. Python default arg improvements [lua/luarun] change return type from int to void on functions not returning anything Add note about delimiting blocks of Python code Fix python default_args testcase for Python 3 Fix Python default argument handing broken since swig-3.0.3 Python default argument test cases from issue #294 Wording change for missing semicolon error Handle "constexpr explicit" and "constexpr static" Allow C++11 "explicit constexpr" Improve errors for missing ; and unexpected ) Fix typo in old entry Add test coverage for unterminated %{ ... %} block When reporting an error for a construct which hasn't been terminated when the end of the file is reached, report it at the start line rather than "EOF" as then tools like editors and IDEs will take you to a generally more useful place for fixing the problem. Improve error message for extraneous '%}'. Add .gitignore for Examples/test-suite/errors/ Fix testcase name in expected output Improve error message when an unknown SWIG directive is used Update link to point to 3.0 docs Fix links to the online 1.3 docs to instead be relative Drop deprecated warnings for ancient options Fix tab to space in HTML preformatted block Provide -cppext as a general command line option Split -help output into 4 chunks instead of 3 More on Go examples [skip ci] Properly quote parameters in preinst-swig wrapper. Fix typo Bump version to 3.0.4 HTML tweaks Add 3.0.3 release information Minor tweaks to the changes file %constant and structs support for Lua Fix D examples when run 'in-source' Fix D examples clean Revert "Fix D examples clean" Fix javascript clean Let Octave 3.8 fail in Travis Fix D examples clean Fix javascript clean Tidy up Javascript build system Don't delete checked in files with 'make distclean' Reduce scope of template_default_class_parms testcase Fix abort using template default parameters Test suite warning fixes [Perl] tidy "warning: duplicate 'extern' declaration specifier" when building generated code under clang Issue #282 perl5 archlib vs archlibexp [Go] Changed link 'https://github.com/golang/go/tree/master/misc/swig' to 'https://golang.org/misc/swig' in the Go documentation. [Go] Updated Go documentation (examples, runtime.SetFinalizer, object ownership). Added auto-generated 'Examples/d/example.mk' to '.gitignore'. Warning suppressions in tests nested_scope test fixes for clang Fix use of preprocessor null directive Add testcase for nested inner class deriving from a templated base class and defined outside of the outer class. Add in missing constant_directive.i test Improve Python builtin and %constant structs fixed python global object constants Partial support for %constant and structs Ignore E402 (import not on top of file) PEP8 error. Add PEP8_FLAGS variable to the test suite Python makefile. Fix templated constructors regression Correctly detect Go1 during configure Fix regression in introduced in merge of C++11 strongly typed enums support - Guile constants bad casts generated - Go non-public enum value wrappers assert failure Document new C++11 strongly typed enumerations support. Add more docs about _global_ prefix in typemap temporary variables Add clarification on _global_ prefix. Improve Javascript Webkit detection Add c++11 strongly typed enums runtime test for Javascript Add c++11 strongly typed enums runtime test for Octave Add c++11 strongly typed enum support for Guile Add c++11 strongly typed enum support for Go Add c++11 strongly typed enum support for D Add c++11 strongly typed enum support for Lua Fix line endings in lua example Add c++11 strongly typed enums runtime test for Tcl Add c++11 strongly typed enum support for PHP Add c++11 strongly typed enums runtime test for Ruby Add c++11 strongly typed enums runtime test for Perl Enhance C++11 strongly typed enums testcase C++11 strongly typed enums runtime test for python fix for nested template defined out of class (issue #265) C++11 strongly typed enum support Add Java runtime testcases for C++11 strongly typed enums add director_nested_class to list of broken tests Add C# support for wrapping C++11 strongly typed enums Enhance strongly typed enums testcase ... Conflicts: .travis.yml
Diffstat (limited to 'Lib/python')
-rw-r--r--Lib/python/Makefile.in32
-rw-r--r--Lib/python/pyclasses.swg8
-rw-r--r--Lib/python/pycontainer.swg17
-rw-r--r--Lib/python/pyinit.swg3
-rw-r--r--Lib/python/pyiterators.swg3
-rw-r--r--Lib/python/pystrings.swg4
-rw-r--r--Lib/python/pythonkw.swg2
-rw-r--r--Lib/python/pyuserdir.swg1
-rw-r--r--Lib/python/std_map.i12
-rw-r--r--Lib/python/std_pair.i22
-rw-r--r--Lib/python/std_unordered_map.i12
11 files changed, 76 insertions, 40 deletions
diff --git a/Lib/python/Makefile.in b/Lib/python/Makefile.in
index 71effea70..27c384449 100644
--- a/Lib/python/Makefile.in
+++ b/Lib/python/Makefile.in
@@ -1,6 +1,6 @@
# ---------------------------------------------------------------
# SWIG Python Makefile
-#
+#
# This file can be used to build various Python extensions with SWIG.
# By default this file is set up for dynamic loading, but it can
# be easily customized for static extensions by modifying various
@@ -17,11 +17,11 @@
# script and should already reflect your machine.
#----------------------------------------------------------------
-SRCS =
-CXXSRCS =
-OBJCSRCS =
-OBJS =
-INTERFACE =
+SRCS =
+CXXSRCS =
+OBJCSRCS =
+OBJS =
+INTERFACE =
WRAPFILE = $(INTERFACE:.i=_wrap.c)
WRAPOBJ = $(INTERFACE:.i=_wrap.o)
TARGET = module@SO@ # Use this kind of target for dynamic loading
@@ -32,8 +32,8 @@ exec_prefix = @exec_prefix@
CC = @CC@
CXX = @CXX@
-OBJC = @CC@ -Wno-import # -Wno-import needed for gcc
-CFLAGS =
+OBJC = @CC@ -Wno-import # -Wno-import needed for gcc
+CFLAGS =
INCLUDES =
LIBS =
@@ -42,9 +42,9 @@ LIBS =
# SWIGOPT = SWIG compiler options
# SWIGCC = Compiler used to compile the wrapper file
-SWIG = $(exec_prefix)/bin/swig
-SWIGOPT = -python
-SWIGCC = $(CC)
+SWIG = $(exec_prefix)/bin/swig
+SWIGOPT = -python
+SWIGCC = $(CC)
# SWIG Library files. Uncomment if rebuilding the Python interpreter
#SWIGLIBS = -lembed.i
@@ -67,11 +67,11 @@ BUILD = @LDSHARED@
# need to provide additional link libraries (this is not always required).
#DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
- -L/usr/local/lib -lg++ -lstdc++ -lgcc
+ -L/usr/local/lib -lg++ -lstdc++ -lgcc
# Python installation
-PY_INCLUDE = -DHAVE_CONFIG_H @PYINCLUDE@
+PY_INCLUDE = -DHAVE_CONFIG_H @PYINCLUDE@
PY_LIB = @PYLIB@
# Build libraries (needed for static builds)
@@ -107,7 +107,7 @@ all: $(TARGET)
# Convert the wrapper file into an object file
$(WRAPOBJ) : $(WRAPFILE)
- $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE)
+ $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE)
$(WRAPFILE) : $(INTERFACE)
$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE)
@@ -117,7 +117,3 @@ $(TARGET): $(WRAPOBJ) $(ALLOBJS)
clean:
rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET)
-
-
-
-
diff --git a/Lib/python/pyclasses.swg b/Lib/python/pyclasses.swg
index b73ebdbb8..9d6299ff1 100644
--- a/Lib/python/pyclasses.swg
+++ b/Lib/python/pyclasses.swg
@@ -72,27 +72,35 @@ namespace swig {
SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
{
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
Py_XINCREF(_obj);
+ SWIG_PYTHON_THREAD_END_BLOCK;
}
SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
{
if (initial_ref) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
Py_XINCREF(_obj);
+ SWIG_PYTHON_THREAD_END_BLOCK;
}
}
SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item)
{
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
Py_XINCREF(item._obj);
Py_XDECREF(_obj);
_obj = item._obj;
+ SWIG_PYTHON_THREAD_END_BLOCK;
return *this;
}
~SwigPtr_PyObject()
{
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
Py_XDECREF(_obj);
+ SWIG_PYTHON_THREAD_END_BLOCK;
}
operator PyObject *() const
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index dcada87c7..e5543cd6b 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -710,7 +710,8 @@ namespace swig
#if defined(SWIGPYTHON_BUILTIN)
%feature("python:slot", "tp_iter", functype="getiterfunc") iterator;
#else
- %pythoncode {def __iter__(self): return self.iterator()}
+ %pythoncode {def __iter__(self):
+ return self.iterator()}
#endif
}
@@ -873,6 +874,13 @@ namespace swig
*(swig::getpos(self,i)) = x;
}
+#if defined(SWIGPYTHON_BUILTIN)
+ // This will be called through the mp_ass_subscript slot to delete an entry.
+ void __setitem__(difference_type i) throw (std::out_of_range) {
+ self->erase(swig::getpos(self,i));
+ }
+#endif
+
void append(const value_type& x) {
self->push_back(x);
}
@@ -891,6 +899,13 @@ namespace swig
*(swig::getpos(self,i)) = x;
}
+#if defined(SWIGPYTHON_BUILTIN)
+ // This will be called through the mp_ass_subscript slot to delete an entry.
+ void __setitem__(difference_type i) throw (std::out_of_range) {
+ self->erase(swig::getpos(self,i));
+ }
+#endif
+
void append(value_type x) {
self->push_back(x);
}
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index b44c2c893..47d3d9700 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -375,6 +375,7 @@ SWIG_init(void) {
PyObject *public_interface, *public_symbol;
PyObject *this_descr;
PyObject *thisown_descr;
+ PyObject *self = 0;
int i;
(void)builtin_pytype;
@@ -382,6 +383,7 @@ SWIG_init(void) {
(void)builtin_basetype;
(void)tuple;
(void)static_getset;
+ (void)self;
/* metatype is used to implement static member variables. */
metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type);
@@ -401,6 +403,7 @@ SWIG_init(void) {
#else
m = Py_InitModule((char *) SWIG_name, SwigMethods);
#endif
+
md = d = PyModule_GetDict(m);
(void)md;
diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg
index f93594c4c..110c431fe 100644
--- a/Lib/python/pyiterators.swg
+++ b/Lib/python/pyiterators.swg
@@ -344,7 +344,8 @@ namespace swig
%feature("python:slot", "tp_iternext", functype="iternextfunc") SwigPyIterator::__next__;
#else
%extend SwigPyIterator {
- %pythoncode {def __iter__(self): return self}
+ %pythoncode {def __iter__(self):
+ return self}
}
#endif
diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg
index f6a4eba8a..2b14547ad 100644
--- a/Lib/python/pystrings.swg
+++ b/Lib/python/pystrings.swg
@@ -89,7 +89,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void();
} else {
%#if PY_VERSION_HEX >= 0x03000000
+%#if PY_VERSION_HEX >= 0x03010000
+ return PyUnicode_DecodeUTF8(carray, %numeric_cast(size,int), "surrogateescape");
+%#else
return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int));
+%#endif
%#else
return PyString_FromStringAndSize(carray, %numeric_cast(size,int));
%#endif
diff --git a/Lib/python/pythonkw.swg b/Lib/python/pythonkw.swg
index 8ad0ef11b..2f76a664a 100644
--- a/Lib/python/pythonkw.swg
+++ b/Lib/python/pythonkw.swg
@@ -130,7 +130,7 @@ PYTHONKW(None);
/*
'self' is also a bad Name
*/
-PYTHONBN(self);
+PYTHONKW(self);
#undef PYTHONBN
#undef PYTHONKW
diff --git a/Lib/python/pyuserdir.swg b/Lib/python/pyuserdir.swg
index d3c3eb188..00aec07d5 100644
--- a/Lib/python/pyuserdir.swg
+++ b/Lib/python/pyuserdir.swg
@@ -185,7 +185,6 @@ These methods "may be called" if needed.
#define %clearpythonappend %feature("pythonappend","")
-
/* ------------------------------------------------------------------------- */
/*
%extend_smart_pointer extend the smart pointer support.
diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i
index 66ed68da5..58902bca4 100644
--- a/Lib/python/std_map.i
+++ b/Lib/python/std_map.i
@@ -176,10 +176,14 @@
#else
%extend {
- %pythoncode {def __iter__(self): return self.key_iterator()}
- %pythoncode {def iterkeys(self): return self.key_iterator()}
- %pythoncode {def itervalues(self): return self.value_iterator()}
- %pythoncode {def iteritems(self): return self.iterator()}
+ %pythoncode {def __iter__(self):
+ return self.key_iterator()}
+ %pythoncode {def iterkeys(self):
+ return self.key_iterator()}
+ %pythoncode {def itervalues(self):
+ return self.value_iterator()}
+ %pythoncode {def iteritems(self):
+ return self.iterator()}
}
#endif
diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i
index 782969574..73d47e198 100644
--- a/Lib/python/std_pair.i
+++ b/Lib/python/std_pair.i
@@ -176,18 +176,20 @@ SwigPython_std_pair_setitem (PyObject *a, Py_ssize_t b, PyObject *c)
%define %swig_pair_methods(pair...)
#if !defined(SWIGPYTHON_BUILTIN)
%extend {
-%pythoncode {def __len__(self): return 2
-def __repr__(self): return str((self.first, self.second))
+%pythoncode {def __len__(self):
+ return 2
+def __repr__(self):
+ return str((self.first, self.second))
def __getitem__(self, index):
- if not (index % 2):
- return self.first
- else:
- return self.second
+ if not (index % 2):
+ return self.first
+ else:
+ return self.second
def __setitem__(self, index, val):
- if not (index % 2):
- self.first = val
- else:
- self.second = val}
+ if not (index % 2):
+ self.first = val
+ else:
+ self.second = val}
}
#endif
%enddef
diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i
index b456035e2..737468234 100644
--- a/Lib/python/std_unordered_map.i
+++ b/Lib/python/std_unordered_map.i
@@ -231,10 +231,14 @@
return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
- %pythoncode {def __iter__(self): return self.key_iterator()}
- %pythoncode {def iterkeys(self): return self.key_iterator()}
- %pythoncode {def itervalues(self): return self.value_iterator()}
- %pythoncode {def iteritems(self): return self.iterator()}
+ %pythoncode {def __iter__(self):
+ return self.key_iterator()}
+ %pythoncode {def iterkeys(self):
+ return self.key_iterator()}
+ %pythoncode {def itervalues(self):
+ return self.value_iterator()}
+ %pythoncode {def iteritems(self):
+ return self.iterator()}
}
%enddef