Index: pobyso.py
===================================================================
--- pobyso.py	(revision 116)
+++ pobyso.py	(revision 117)
@@ -147,6 +147,24 @@
     return(resultSo)
 # End pobyso_chebyshevform_so_so.
 
+def pobyso_clear_taylorform_sa_so(taylorFormSaSo):
+    """
+    This method is necessary to correctly clean up the memory from Taylor forms.
+    These are made of a Sollya object, a Sollya object list, a Sollya object.
+    For no clearly understood reason, sollya_lib_clear_object_list crashed 
+    when applied to the object list.
+    Here, we decompose it into Sage list of Sollya objects references and we
+     clear them one by one. 
+    """
+    sollya_lib_clear_obj(taylorFormSaSo[0])
+    (coefficientsErrorsListSaSo, numElementsSa, isEndEllipticSa) = \
+        pobyso_get_list_elements_so_so(taylorFormSaSo[1])
+    for element in coefficientsErrorsListSaSo:
+        sollya_lib_clear_obj(element)
+    sollya_lib_clear_obj(taylorFormSaSo[1])
+    sollya_lib_clear_obj(taylorFormSaSo[2])
+# End pobyso_clear_taylorform_sa_so 
+
 def pobyso_cmp(rnArgSa, cteSo):
     """
     Compare the MPFR value a RealNumber with that of a Sollya constant.
@@ -262,7 +280,7 @@
 
 def pobyso_constant_from_int_so_sa(constSo):
     """
-    Get Sage int from a Sollya int constant.
+    Get a Sage int from a Sollya int constant.
     Usefull for precision or powers in polynomials.
     """
     constSa = c_int(0)
@@ -479,7 +497,7 @@
     """ Legacy function. See pobyso_get_list_elements_so_so. """
     return(pobyso_get_list_elements_so_so(soObj))
  
-def pobyso_get_list_elements_so_so(objSo):
+def pobyso_get_list_elements_so_so(objectListSo):
     """
     Get the list elements as a Sage/Python array of Sollya objects.
     The other data returned are Sage/Python objects.
@@ -487,16 +505,20 @@
     listAddress = POINTER(c_longlong)()
     numElements = c_int(0)
     isEndElliptic = c_int(0)
-    listAsList = []
+    listAsSageList = []
     result = sollya_lib_get_list_elements(byref(listAddress),\
                                           byref(numElements),\
                                           byref(isEndElliptic),\
-                                          objSo)
+                                          objectListSo)
     if result == 0 :
         return None
     for i in xrange(0, numElements.value, 1):
-       listAsList.append(sollya_lib_copy_obj(listAddress[i]))
-    return(listAsList, numElements.value, isEndElliptic.value)
+       listAsSageList.append(sollya_lib_copy_obj(listAddress[i]))
+       # Clear each of the elements returned by Sollya.
+       sollya_lib_clear_obj(listAddress[i])
+    # Free the list itself.   
+    sollya_lib_free(listAddress)
+    return(listAsSageList, numElements.value, isEndElliptic.value)
 
 def pobyso_get_max_prec_of_exp(soExp):
     """ Legacy function. See pobyso_get_max_prec_of_exp_so_sa. """
@@ -988,6 +1010,9 @@
     taylorFormSo = sollya_lib_taylorform(functionSo, degreeSo, \
                                          intervalCenterSo, \
                                          rangeSo, errorTypeSo, None)
+    # taylorFormListSaSo is a Python list of Sollya objects references that 
+    # are copies of the elements of taylorFormSo.
+    # pobyso_get_list_elements_so_so clears taylorFormSo.
     (taylorFormListSo, numElements, isEndElliptic) = \
         pobyso_get_list_elements_so_so(taylorFormSo)
     polySo = taylorFormListSo[0]
@@ -1009,8 +1034,8 @@
     return((polyVarChangedSo, intervalCenterSo, maxErrorSo))
 # end pobyso_taylor_expansion_with_change_var_so_so
 
-def pobyso_taylor_expansion_no_change_var_so_so(functionSo, degreeSo, rangeSo, \
-                                                errorTypeSo=None, \
+def pobyso_taylor_expansion_no_change_var_so_so(functionSo, degreeSo, rangeSo,
+                                                errorTypeSo=None, 
                                                 sollyaPrecSo=None):
     """
     Compute the Taylor expansion without the variable change
@@ -1026,18 +1051,19 @@
         errorTypeSo = sollya_lib_absolute(None)
     else:
         errorTypeIsNone = False
-    intervalCenterSo = sollya_lib_mid(rangeSo)
-    taylorFormSo = sollya_lib_taylorform(functionSo, degreeSo, \
-                                         intervalCenterSo, \
+    intervalCenterSo = sollya_lib_mid(rangeSo, None)
+    taylorFormSo = sollya_lib_taylorform(functionSo, degreeSo,
+                                         intervalCenterSo,
                                          rangeSo, errorTypeSo, None)
     # taylorFormListSaSo is a Python list of Sollya objects references that 
     # are copies of the elements of taylorFormSo.
     # pobyso_get_list_elements_so_so clears taylorFormSo.
     (taylorFormListSaSo, numElementsSa, isEndEllipticSa) = \
         pobyso_get_list_elements_so_so(taylorFormSo)
+    sollya_lib_clear_obj(taylorFormSo)
     polySo = sollya_lib_copy_obj(taylorFormListSaSo[0])
+    #polySo = taylorFormListSaSo[0]
     #errorRangeSo = sollya_lib_copy_obj(taylorFormListSaSo[2])
-    #polySo = taylorFormListSaSo[0]
     errorRangeSo = taylorFormListSaSo[2]
     # No copy_obj needed here: a new object is created.
     maxErrorSo = sollya_lib_sup(errorRangeSo)
@@ -1047,8 +1073,7 @@
         sollya_lib_clear_obj(initialPrecSo)
     if errorTypeIsNone:
         sollya_lib_clear_obj(errorTypeSo)
-    for element in taylorFormListSaSo:
-        sollya_lib_clear_obj(element)
+    pobyso_clear_taylorform_sa_so(taylorFormListSaSo)
     return((polySo, intervalCenterSo, maxErrorSo))
 # end pobyso_taylor_expansion_no_change_var_so_so
 
