Hi,
I've read BRANCH-README on swig-py3 branch and thead starting from
https://mail-archives.apache.org/mod_mbox/subversion-dev/201803.mbox/%3c20180323081026.cqgbhdzfxv2lwm24@tarpaulin.shahaf.local2%3e
so I've tried to fix it.
Here is a patch against typemap file core.i, try to change
svn_stream_read*() and svn_stream_write() interface to use
bytes object.
As a result of this, it is also need to modify Stream.read(),
and perhaps test for file contents also need to modify.
(It is expected that the result object read from file is
a bytes object, isn't it?)
At least after patched version returns OK for "make check-swig-py"
on both of Python 2.7 and Python 3.7.
diff --git a/subversion/bindings/swig/core.i b/subversion/bindings/swig/core.i
--- a/subversion/bindings/swig/core.i
+++ b/subversion/bindings/swig/core.i
@@ -420,7 +422,7 @@
#ifdef SWIGPYTHON
%typemap(argout) (char *buffer, apr_size_t *len) {
- %append_output(PyStr_FromStringAndSize($1, *$2));
+ %append_output(PyBytes_FromStringAndSize($1, *$2));
free($1);
}
#endif
@@ -447,7 +449,9 @@
"expecting a string for the buffer");
SWIG_fail;
}
- $1 = PyStr_AsUTF8AndSize($input, &temp);
+ if (PyBytes_AsStringAndSize($input, &$1, &temp) == -1) {
+ SWIG_fail;
+ }
$2 = ($2_ltype)&temp;
}
#endif
diff --git a/subversion/bindings/swig/python/svn/core.py
b/subversion/bindings/swig/python/svn/core.py
--- a/subversion/bindings/swig/python/svn/core.py
+++ b/subversion/bindings/swig/python/svn/core.py
@@ -185,7 +185,7 @@ class Stream:
if not data:
break
chunks.append(data)
- return ''.join(chunks)
+ return b''.join(chunks)
# read the amount specified
return svn_stream_read(self._stream, int(amt))
diff --git
a/subversion/bindings/swig/python/tests/trac/versioncontrol/tests/svn_fs.py
b/subversion/bindings/swig/python/tests/trac/versioncontrol/tests/svn_fs.py
--- a/subversion/bindings/swig/python/tests/trac/versioncontrol/tests/svn_fs.py
+++ b/subversion/bindings/swig/python/tests/trac/versioncontrol/tests/svn_fs.py
@@ -173,7 +173,7 @@ class SubversionRepositoryTestCase(unittest.TestCase):
node = self.repos.get_node('/trunk/README.txt')
self.assertEqual(8, node.content_length)
self.assertEqual('text/plain', node.content_type)
- self.assertEqual('A test.\n', node.get_content().read())
+ self.assertEqual(b'A test.\n', node.get_content().read())
def test_get_dir_properties(self):
f = self.repos.get_node('/trunk')
--
Yasuhito FUTATSUKI