summaryrefslogtreecommitdiff
path: root/Lib/python
diff options
context:
space:
mode:
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