svn commit: r1921523 - in /subversion/branches/1.14.x-r1921505: ./ subversion/bindings/swig/include/svn_types.swg subversion/bindings/swig/python/tests/client.py subversion/bindings/swig/python/tests/core.py

[email protected]
Newsgroups gmane.comp.version-control.subversion.svn
Message-ID <[email protected]>
Author: jun66j5
Date: Thu Oct 24 03:11:00 2024
New Revision: 1921523

URL: http://svn.apache.org/viewvc?rev=1921523&view=rev
Log:
On the 1.14.x-r1921505 branch: Merge r1921505 from trunk without changes for
`%typemap() svn_error_t * SVN_ERR_WITH_ATTRS`.

Modified:
    subversion/branches/1.14.x-r1921505/   (props changed)
    subversion/branches/1.14.x-r1921505/subversion/bindings/swig/include/svn_types.swg
    subversion/branches/1.14.x-r1921505/subversion/bindings/swig/python/tests/client.py
    subversion/branches/1.14.x-r1921505/subversion/bindings/swig/python/tests/core.py

Propchange: subversion/branches/1.14.x-r1921505/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1921505

Modified: subversion/branches/1.14.x-r1921505/subversion/bindings/swig/include/svn_types.swg
URL: http://svn.apache.org/viewvc/subversion/branches/1.14.x-r1921505/subversion/bindings/swig/include/svn_types.swg?rev=1921523&r1=1921522&r2=1921523&view=diff
==============================================================================
--- subversion/branches/1.14.x-r1921505/subversion/bindings/swig/include/svn_types.swg (original)
+++ subversion/branches/1.14.x-r1921505/subversion/bindings/swig/include/svn_types.swg Thu Oct 24 03:11:00 2024
@@ -435,8 +435,31 @@ svn_ ## TYPE ## _swig_rb_closed(VALUE se
             svn_error_clear($1);
         SWIG_fail;
     }
-    Py_INCREF(Py_None);
-    $result = Py_None;
+    Py_XDECREF($result);
+    $result = PyList_New(0);
+}
+
+%typemap(ret) svn_error_t * {
+    if ($result == NULL) {
+      $result = Py_None;
+      Py_INCREF($result);
+    }
+    else {
+      switch (PyList_Size($result)) {
+        case 0:
+          $result = Py_None;
+          Py_INCREF($result);
+          break;
+        case 1:
+          {
+            PyObject *tmp = $result;
+            $result = PyList_GetItem(tmp, 0);
+            Py_INCREF($result);
+            Py_DECREF(tmp);
+          }
+          break;
+      }
+    }
 }
 #endif
 

Modified: subversion/branches/1.14.x-r1921505/subversion/bindings/swig/python/tests/client.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.14.x-r1921505/subversion/bindings/swig/python/tests/client.py?rev=1921523&r1=1921522&r2=1921523&view=diff
==============================================================================
--- subversion/branches/1.14.x-r1921505/subversion/bindings/swig/python/tests/client.py (original)
+++ subversion/branches/1.14.x-r1921505/subversion/bindings/swig/python/tests/client.py Thu Oct 24 03:11:00 2024
@@ -172,7 +172,9 @@ class SubversionClientTestCase(unittest.
 
     path = self.temper.alloc_empty_dir('-checkout')
 
-    self.assertRaises(ValueError, client.checkout2,
+    # TypeError is raised since SWIG 4.3.0
+    self.assertRaises((ValueError, TypeError), r'Received a NULL pointer',
+                      client.checkout2,
                       self.repos_uri, path, None, None, True, True,
                       self.client_ctx)
 
@@ -526,7 +528,9 @@ class SubversionClientTestCase(unittest.
 
     path = self.temper.alloc_empty_dir('-update')
 
-    self.assertRaises(ValueError, client.checkout2,
+    # TypeError is raised since SWIG 4.3.0
+    self.assertRaises((ValueError, TypeError), r'Received a NULL pointer',
+                      client.checkout2,
                       self.repos_uri, path, None, None, True, True,
                       self.client_ctx)
 

Modified: subversion/branches/1.14.x-r1921505/subversion/bindings/swig/python/tests/core.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.14.x-r1921505/subversion/bindings/swig/python/tests/core.py?rev=1921523&r1=1921522&r2=1921523&view=diff
==============================================================================
--- subversion/branches/1.14.x-r1921505/subversion/bindings/swig/python/tests/core.py (original)
+++ subversion/branches/1.14.x-r1921505/subversion/bindings/swig/python/tests/core.py Thu Oct 24 03:11:00 2024
@@ -333,6 +333,34 @@ class SubversionCoreTestCase(unittest.Te
                      [b'', 1])
     svn.core.svn_stream_close(stream)
 
+  def test_svn_rangelist_diff(self):
+    """
+    SWIG incorrectly handles return values when the first %append_output() is
+    invoked with a list instance. svn.core.svn_rangelist_diff() is in the case.
+    We test whether the workaround for it is working.
+    """
+
+    def from_args(start, end, inheritable):
+      instance = svn.core.svn_merge_range_t()
+      instance.start = start
+      instance.end = end
+      instance.inheritable = inheritable
+      return instance
+
+    def to_args(instance):
+      return [instance.start, instance.end, instance.inheritable]
+
+    def map_list(f, iterator):
+      return list(map(f, iterator))
+
+    from_ = [from_args(4, 5, True), from_args(9, 13, True)]
+    to = [from_args(7, 11, True)]
+    rv = svn.core.svn_rangelist_diff(from_, to, True)
+    self.assertIsInstance(rv, (list, tuple))
+    deleted, added = rv
+    self.assertEqual([[7, 9, True]], map_list(to_args, added))
+    self.assertEqual([[4, 5, True], [11, 13, True]],map_list(to_args, deleted))
+
 
 def suite():
     return unittest.defaultTestLoader.loadTestsFromTestCase(
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.