subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From futat...@apache.org
Subject svn commit: r1851888 - in /subversion/branches/swig-py3/subversion/bindings/swig/python: libsvn_swig_py/swigutil_py.c tests/wc.py
Date Wed, 23 Jan 2019 07:43:31 GMT
Author: futatuki
Date: Wed Jan 23 07:43:30 2019
New Revision: 1851888

URL: http://svn.apache.org/viewvc?rev=1851888&view=rev
Log:
On branch swig-py3: Fix Python exception handling in callback function

* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
 (svn_swig_py_status_func2): Clear python exception if it caused in Python
  call back function. (To avoid crash in py3) 

* subversion/bindings/swig/python/tests/wc.py
 (SubversionWorkingCopyTestCase.test_status_editor): Remove an assertion
  from call back because it takes no effect, and check result after 
  svn_wc_get_status_editor2() API call instead.
 (SubversionWorkingCopyTestCase.test_status_editor_callback_exception):
  New test case for Python exception within svn_wc_status_func2 call back.
   
Patch by: Jun Omae <jun66j5 at gmail.com>
          (Tweaked by me.)

Modified:
    subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
    subversion/branches/swig-py3/subversion/bindings/swig/python/tests/wc.py

Modified: subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c?rev=1851888&r1=1851887&r2=1851888&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
(original)
+++ subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
Wed Jan 23 07:43:30 2019
@@ -2986,7 +2986,10 @@ void svn_swig_py_status_func2(void *bato
 
   /* Our error has no place to go. :-( */
   if (err)
-    svn_error_clear(err);
+    {
+      svn_error_clear(err);
+      PyErr_Clear();
+    }
 
   svn_swig_py_release_py_lock();
 }

Modified: subversion/branches/swig-py3/subversion/bindings/swig/python/tests/wc.py
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/bindings/swig/python/tests/wc.py?rev=1851888&r1=1851887&r2=1851888&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/bindings/swig/python/tests/wc.py (original)
+++ subversion/branches/swig-py3/subversion/bindings/swig/python/tests/wc.py Wed Jan 23 07:43:30
2019
@@ -159,7 +159,6 @@ class SubversionWorkingCopyTestCase(unit
   def test_status_editor(self):
       paths = []
       def status_func(target, status):
-        self.assertTrue(target.startswith(self.path))
         paths.append(target)
 
       (anchor_access, target_access,
@@ -177,6 +176,30 @@ class SubversionWorkingCopyTestCase(unit
                                               )
       editor.close_edit(edit_baton)
       self.assertTrue(len(paths) > 0)
+      for target in paths:
+        self.assertTrue(target.startswith(self.path))
+
+  def test_status_editor_callback_exception(self):
+      """test case for status_editor call back not to be crashed by Python exception"""
+      def status_func(target, status):
+        # Note: exception with in this call back doesn't propagate to 
+        # the caller
+        raise AssertionError('intentional exception')
+
+      (anchor_access, target_access,
+       target) = wc.adm_open_anchor(self.path, False, -1, None)
+      (editor, edit_baton, set_locks_baton,
+       edit_revision) = wc.get_status_editor2(anchor_access,
+                                              target,
+                                              None,  # SvnConfig
+                                              True,  # recursive
+                                              True, # get_all
+                                              False, # no_ignore
+                                              status_func,
+                                              None,  # cancel_func
+                                              None,  # traversal_info
+                                              )
+      editor.close_edit(edit_baton)
 
   def test_is_normal_prop(self):
       self.assertFalse(wc.is_normal_prop(b'svn:wc:foo:bar'))



Mime
View raw message