Author: svn-role
Date: Fri Nov 3 04:00:03 2023
New Revision: 1913547
URL: http://svn.apache.org/viewvc?rev=1913547&view=rev
Log:
Merge the r1912724 group from trunk:
* r1912724, r1912743
Python bindings error handling
Justification:
Improve documentation and error message. Issue #1778
Votes:
+1: dsahlberg, jamessan
Modified:
subversion/branches/1.14.x/ (props changed)
subversion/branches/1.14.x/STATUS
subversion/branches/1.14.x/subversion/bindings/swig/python/svn/fs.py
subversion/branches/1.14.x/subversion/bindings/swig/python/tests/fs.py
Propchange: subversion/branches/1.14.x/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1912724,1912743
Modified: subversion/branches/1.14.x/STATUS
URL:
http://svn.apache.org/viewvc/subversion/branches/1.14.x/STATUS?rev=1913547&r1=1913546&r2=1913547&view=diff
==============================================================================
--- subversion/branches/1.14.x/STATUS (original)
+++ subversion/branches/1.14.x/STATUS Fri Nov 3 04:00:03 2023
@@ -42,11 +42,3 @@ Veto-blocked changes:
Approved changes:
=================
-
- * r1912724, r1912743
- Python bindings error handling
- Justification:
- Improve documentation and error message. Issue #1778
- Votes:
- +1: dsahlberg, jamessan
-
Modified: subversion/branches/1.14.x/subversion/bindings/swig/python/svn/fs.py
URL:
http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/bindings/swig/python/svn/fs.py?rev=1913547&r1=1913546&r2=1913547&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/bindings/swig/python/svn/fs.py
(original)
+++ subversion/branches/1.14.x/subversion/bindings/swig/python/svn/fs.py Fri
Nov 3 04:00:03 2023
@@ -23,6 +23,7 @@
# under the License.
######################################################################
+import errno
from libsvn.fs import *
from svn.core import _unprefix_names, Pool, _as_list
_unprefix_names(locals(), 'svn_fs_')
@@ -130,6 +131,18 @@ class FileDiff:
return self.tempfile1, self.tempfile2
def get_pipe(self):
+ """Perform diff and return a file object from which the output can
+ be read.
+
+ When DIFFOPTIONS is None (the default), use svn's internal diff.
+
+ With any other DIFFOPTIONS, exec the external diff found on PATH,
+ passing it DIFFOPTIONS. On Windows, exec diff.exe rather than
+ diff. If a diff utility is not installed or found on PATH, throws
+ FileNotFoundError. Caveat: On some systems, including Windows, an
+ external diff may not be available unless installed and added to
+ PATH manually.
+ """
self.get_files()
# If diffoptions were provided, then the diff command needs to be
@@ -142,8 +155,17 @@ class FileDiff:
+ [self.tempfile1, self.tempfile2]
# open the pipe, and return the file object for reading from the child.
- p = _subprocess.Popen(cmd, stdout=_subprocess.PIPE, bufsize=-1,
- close_fds=_sys.platform != "win32")
+ try:
+ p = _subprocess.Popen(cmd, stdout=_subprocess.PIPE, bufsize=-1,
+ close_fds=_sys.platform != "win32")
+ # When removing Python 2 support: Change to FileNotFoundError and
+ # remove check for ENOENT (FileNotFoundError "Corresponds to errno
+ # ENOENT" according to documentation)
+ except OSError as err:
+ if err.errno == errno.ENOENT:
+ err.strerror = "External diff command not found in PATH"
+ raise err
+
return _PopenStdoutWrapper(p)
else:
Modified: subversion/branches/1.14.x/subversion/bindings/swig/python/tests/fs.py
URL:
http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/bindings/swig/python/tests/fs.py?rev=1913547&r1=1913546&r2=1913547&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/bindings/swig/python/tests/fs.py
(original)
+++ subversion/branches/1.14.x/subversion/bindings/swig/python/tests/fs.py Fri
Nov 3 04:00:03 2023
@@ -107,6 +107,9 @@ class SubversionFSTestCase(unittest.Test
try:
diffout, differr = Popen(["diff"], stdin=PIPE, stderr=PIPE).communicate()
+ # When removing Python 2 support: Change to FileNotFoundError and
+ # remove check for ENOENT (FileNotFoundError "Corresponds to errno
+ # ENOENT" according to documentation)
except OSError as err:
if err.errno == errno.ENOENT:
self.skipTest("'diff' command not present")