On 2019/12/13 12:11, Daniel Shahaf wrote:> With swig-py3 in trunk:
from svn.core import *
svn_config_get_user_config_path(None, '')
b'/home/daniel/.subversion'
d = _
svn_config_ensure(d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "${prefix}/lib/svn-python/libsvn/core.py", line 6014, in
svn_config_ensure
return _core.svn_config_ensure(*args)
TypeError: svn_config_ensure() argument 1 must be str or None, not bytes
svn_config_ensure(d.decode())
svn_config_get_user_config_path() returns bytes but svn_config_ensure() expects
str. I expected them both to use the same type, since in C they do:
svn_config_get_user_config_path() has a «const char **» output parameter and
svn_config_ensure() has a «const char *» input parameter.
I found a special definition for const char *config_dir in
subversion/bindings/swig/core.i:
[[[
/* Allow None to be passed as config_dir argument */
#ifdef SWIGPYTHON
%typemap(in,parse="z") const char *config_dir "";
#endif
]]]
This shoud be to allow bytes and byte like objects:
[[[
/* Allow None to be passed as config_dir argument */
#ifdef SWIGPYTHON
%typemap(in,parse="z*") const char *config_dir "";
#endif
]]]
Thus, a patch directed to fix those problem will be
[[[
Index: subversion/bindings/swig/core.i
===================================================================
--- subversion/bindings/swig/core.i (revision 1871319)
+++ subversion/bindings/swig/core.i (working copy)
@@ -362,7 +362,9 @@
/* svn_config_get */
const char *default_value,
/* svn_config_read_auth_data */
- const char *config_dir,
+ const char *config_dir,
+ /* svn_config_get_user_config_path */
+ const char *fname,
/* svn_diff_file_output_merge */
const char *conflict_original,
const char *conflict_modified,
@@ -725,7 +727,7 @@
/* Allow None to be passed as config_dir argument */
#ifdef SWIGPYTHON
-%typemap(in,parse="z") const char *config_dir "";
+%typemap(in,parse="z*") const char *config_dir "";
#endif
/* -----------------------------------------------------------------------
]]]
but not tested yet.
Cheers,
--
Yasuhito FUTATSUKI <futat...@yf.bsdclub.org> / <futat...@poem.co.jp>